Delphi XE MessageDialogAsync 和 MessageDialogSync [2] - 用法示例

Delphi XE MessageDialogAsync 和 MessageDialogSync [2] - 用法示例

1、MessageDialogAsync

//滔Roy  2022.09.30
uses
  FMX.Platform;   //  IFMXDialogServiceAsync  ,MessageDialogAsync

//MessageDialogAsync
var
  IDiaSerAsync:IFMXDialogServiceAsync;
begin
  if TPlatformServices.Current.SupportsPlatformService
    (IFMXDialogServiceAsync, IInterface(IDiaSerAsync)) then
  begin
    //这里的顺序有点要注意,和 MessageDlg 的不同,默认按钮在帮助之前   //MessageDialogAsync - 异步工作,调用立即完成,它们不会等待用户关闭对话框。
    IDiaSerAsync.MessageDialogAsync('测试 对话框 异步.', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes,0,
      procedure(const AResult:TModalResult)
      begin
         if AResult=mrYes then
          ShowMessage('yes 对话框 异步')
         else if AResult=mrNo then
          ShowMessage('No 对话框 异步');
      end
    );
  end;
end;

2、MessageDialogSync

//MessageDialogSync
var
  IDiaSerSync:IFMXDialogServiceSync;
begin
  if TPlatformServices.Current.SupportsPlatformService
    (IFMXDialogServiceSync, IInterface(IDiaSerSync)) then
  begin
    //这里的顺序有点要注意,和 MessageDlg 的不同,默认按钮在帮助之前  // MessageDialogSync - 同步工作。只有当用户关闭对话框时,才会完成对调用。
    if IDiaSerSync.MessageDialogSync('测试 对话框 同步.', TMsgDlgType.mtInformation,
        [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes,0)=mrYes then begin
      ShowMessage('yes 对话框 同步')
    end else ShowMessage('No 对话框 同步');
  end;

  

  

  

 

 

 

 

创建时间:2022.09.30  更新时间:

posted on 2022-09-30 16:34  滔Roy  阅读(150)  评论(0编辑  收藏  举报

导航