消息在Delphi xe7 android [英] Messagedlg in Delphi xe7 android

查看:399
本文介绍了消息在Delphi xe7 android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是试图在安装Delphi xe7(在Android平台上的MessageAlerts)中执行一个示例,不幸的是它不起作用,它给出以下错误消息:在此平台中未实现的阻止对话框:

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 : 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;

任何想法如何解决?

/ koul

推荐答案

这在XE7发行说明中解释:

This is explained in the XE7 release notes:

对话框方法支持匿名方法来处理他们的关闭


在XE6中,对对话框方法(InputBox,InputQuery,MessageDlg,ShowMessage)的调用总是阻塞。调用这些方法之一后的任何代码都不会执行,直到对话框关闭。 Android不允许屏蔽对话框,因此您无法在Android上使用这些方法。

在XE7,InputBox,InputQuery和MessageDlg支持一个新的可选参数 ACloseDialogProc 。包含此新参数的呼叫适用于所有平台,包括Android。此新的可选参数允许您提供在对话框关闭时调用的匿名方法。当您使用此新参数调用这些方法时,您的呼叫将在桌面平台中阻止,并在移动平台中进行非阻塞。如果您需要在对话框关闭后执行代码,请使用此新参数来确保您的应用程序在所有支持的平台上按预期方式工作。

On XE7, InputBox, InputQuery, and MessageDlg support a new optional parameter, ACloseDialogProc. Calls that include this new parameter work on all platforms, including 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在XE7中也获得了Android的支持,对ShowMessage的调用在桌面上被阻止平台和移动平台上的非阻塞。但是,ShowMessage不提供任何新的参数来处理它的关闭。 如果您需要在ShowMessage显示关闭的对话框后执行代码,请使用MessageDlg而不是ShowMessage。

ShowMessage also gained support for Android in XE7, and calls to ShowMessage are blocking on desktop platforms and non-blocking on mobile platforms. However, ShowMessage does not provide any new parameter to handle its closing. If you need to execute code after the dialog box that ShowMessage shows closes, use MessageDlg instead of ShowMessage.

例如:

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;

这篇关于消息在Delphi xe7 android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆