[英]Messagedlg in Delphi xe7 android
我只是試圖執行在安裝 Delphi xe7 期間給出的示例,android 平台上的 MessageAlerts,不幸的是它不起作用,它給出了以下錯誤消息:
阻止對話框未在此平台中實現
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;
任何想法如何解決它?
這在 XE7 發行說明中進行了解釋:
在 XE6 中,對對話框方法(InputBox、InputQuery、MessageDlg、ShowMessage)的調用總是被阻塞。 調用這些方法之一后的任何代碼都不會執行,直到對話框關閉。 Android 不允許屏蔽對話框,因此您不能在 Android 上使用這些方法。
在 XE7 上,InputBox、InputQuery 和 MessageDlg 支持新的可選參數ACloseDialogProc 。 包含此新參數的調用適用於所有平台,包括 Android。 這個新的可選參數允許您提供一個在對話框關閉時調用的匿名方法。 當您使用這個新參數調用這些方法時,您的調用在桌面平台中是阻塞的,而在移動平台中是非阻塞的。 如果您需要在對話框關閉后執行代碼,請使用此新參數來確保您的應用程序在所有支持的平台上按預期工作。
...
ShowMessage 在 XE7 中也獲得了對 Android 的支持,對 ShowMessage 的調用在桌面平台上是阻塞的,在移動平台上是非阻塞的。 但是,ShowMessage 不提供任何新參數來處理其關閉。 如果您需要在 ShowMessage 顯示的對話框關閉后執行代碼,請使用 MessageDlg 而不是 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;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.