简体   繁体   English

Delphi xe7 android中的Messagedlg

[英]Messagedlg in Delphi xe7 android

I m just trying to execute a sample given during the installation of Delphi xe7, the MessageAlerts on android platform, unfortunately it does not working, it gives the following error message:我只是试图执行在安装 Delphi xe7 期间给出的示例,android 平台上的 MessageAlerts,不幸的是它不起作用,它给出了以下错误消息:

Blocking Dialogs not implemented in this platform阻止对话框未在此平台中实现

procedure TMessageAlertsForm.btnMultiButtonAlertClick(Sender: TObject);
begin
  { Show a multiple-button alert that triggers different code blocks according to
    your input }
  case MessageDlg('Choose a button:', System.UITypes.TMsgDlgType.mtInformation,
    [
      System.UITypes.TMsgDlgBtn.mbYes,
      System.UITypes.TMsgDlgBtn.mbNo,
      System.UITypes.TMsgDlgBtn.mbCancel
    ], 0) of
    { Detect which button was pushed and show a different message }
    mrYES:
      ShowMessage('You chose Yes');
    mrNo:
      ShowMessage('You chose No');
    mrCancel:
      ShowMessage('You chose Cancel');
  end;
end;

Any idea How to solve it?任何想法如何解决它?

This is explained in the XE7 release notes:这在 XE7 发行说明中进行了解释:

Dialog Box Methods Support Anonymous Methods to Handle Their Closing 对话框方法支持匿名方法来处理它们的关闭

In XE6, calls to dialog box methods (InputBox, InputQuery, MessageDlg, ShowMessage) were always blocking.在 XE6 中,对对话框方法(InputBox、InputQuery、MessageDlg、ShowMessage)的调用总是被阻塞。 Any code after a call to one of these methods is not executed until the dialog box closes.调用这些方法之一后的任何代码都不会执行,直到对话框关闭。 Android does not allow blocking dialog boxes, so you could not use these methods on Android. Android 不允许屏蔽对话框,因此您不能在 Android 上使用这些方法。

On XE7, InputBox, InputQuery, and MessageDlg support a new optional parameter, ACloseDialogProc .在 XE7 上,InputBox、InputQuery 和 MessageDlg 支持新的可选参数ACloseDialogProc Calls that include this new parameter work on all platforms, including Android.包含此新参数的调用适用于所有平台,包括 Android。 This new optional parameter allows you to provide an anonymous method that is called when the dialog box closes.这个新的可选参数允许您提供一个在对话框关闭时调用的匿名方法。 When you call these methods using this new parameter, your call is blocking in desktop platforms and non-blocking in mobile platforms.当您使用这个新参数调用这些方法时,您的调用在桌面平台中是阻塞的,而在移动平台中是非阻塞的。 If you need to execute code after your dialog box closes, use this new parameter to ensure that your application works as expected on all supported platforms.如果您需要在对话框关闭后执行代码,请使用此新参数来确保您的应用程序在所有支持的平台上按预期工作。

... ...

ShowMessage also gained support for Android in XE7, and calls to ShowMessage are blocking on desktop platforms and non-blocking on mobile platforms. ShowMessage 在 XE7 中也获得了对 Android 的支持,对 ShowMessage 的调用在桌面平台上是阻塞的,在移动平台上是非阻塞的。 However, ShowMessage does not provide any new parameter to handle its closing.但是,ShowMessage 不提供任何新参数来处理其关闭。 If you need to execute code after the dialog box that ShowMessage shows closes, use MessageDlg instead of ShowMessage.如果您需要在 ShowMessage 显示的对话框关闭后执行代码,请使用 MessageDlg 而不是 ShowMessage。

For example:例如:

procedure TMessageAlertsForm.btnMultiButtonAlertClick(Sender: TObject);
begin
  MessageDlg('Choose a button:', System.UITypes.TMsgDlgType.mtInformation,
    [
      System.UITypes.TMsgDlgBtn.mbYes,
      System.UITypes.TMsgDlgBtn.mbNo,
      System.UITypes.TMsgDlgBtn.mbCancel
    ], 0,
    procedure(const AResult: System.UITypes.TModalResult)
    begin
      case AResult of
        mrYES:
          ShowMessage('You chose Yes');
        mrNo:
          ShowMessage('You chose No');
        mrCancel:
          ShowMessage('You chose Cancel');
      end;
    end);
  end;
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM