使用 Delphi 10.2.1 Tokyo 的模态 Android 对话框

2024-05-22

我有以下用于在 Android 上显示模式消息的 Delphi 代码,该代码在 10.1 Berlin 上运行良好,但在 Delphi 10.2.1 Tokyo 上停止运行。此过程现在会挂起 Android 应用程序。

procedure customShowMessage(AMessage: string);
//good idea to have our own procedure that we can tweak, as even for VCL and windows, we have done show message differently over the years due to all sorts of funny problems
var
  LModalWindowOpen: boolean;
begin
  LModalWindowOpen := true;

  TDialogService.MessageDialog(AMessage, TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbOK], TMsgDlgBtn.mbOK, 0,
         procedure(const AResult: TModalResult)
         begin
           LModalWindowOpen := false;
         end);

  while LModalWindowOpen do
    begin
      Application.ProcessMessages; //since 10.2 Tokyo, popup never shows and this loops forever
    end;
end;

我怀疑这可能与东京关于应用程序在主线程中运行方式的变化有关。不确定我可以用什么替换 Application.ProcessMessages 来让对话框显示,以便用户可以单击某些内容。

我有很多地方使用它,因此将其更改为使用回调工作将需要大量工作和重组。


在 Android 上我们只有异步对话框。如果我们希望它们充当模式对话框,我们必须自己做。

使用 ProcessMessage 循环的解决方案是一个想法,但我认为这不是最好的方法。

另一种方法是在显示对话框之前在表单上添加透明(或不透明)布局(或矩形),当您有答案时,可以删除阻塞布局。

您还可以使用 Andrea Magni 的 TFrameStand(可直接从 GetIt 下载),他建议使用 TFrame 作为对话框。https://github.com/andrea-magni/TFrameStand https://github.com/andrea-magni/TFrameStand

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Delphi 10.2.1 Tokyo 的模态 Android 对话框 的相关文章

随机推荐