使用Delphi 10.2.1 Tokyo的Modal Android对话框 [英] Modal Android Dialog using Delphi 10.2.1 Tokyo

查看:186
本文介绍了使用Delphi 10.2.1 Tokyo的Modal Android对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have the following Delphi code for showing a modal message on Android which worked fine on 10.1 Berlin, but stopped working on Delphi 10.2.1 Tokyo. This procedure now hangs the Android app.

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来显示对话框,以便用户可以单击某些内容。

I suspect it possibly has something to do with the change in Tokyo as to how the app runs in the main thread. Not sure what I can replace Application.ProcessMessages with that will let the dialog show, so that the user can click on something.

我在很多地方都使用过,因此使用回调将其更改为可以正常工作,并且需要进行重组。

I have a lot of places this is used, so changing it to work using a callback is going to be a lot of work, and restructuring.

推荐答案

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

On Android we have only asynchronous dialog boxes. If we want they act as modal dialog box, we have to do ourself.

带有ProcessMessage循环的解决方案是一个主意,但我认为这不是最好的方法

The solution with a ProcessMessage loop is an idea, but I don't think it's the best approach.

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

An other one is to add a transparent (or opaque) layout (or rectangle) on your form before displaying the dialog box and when you have an answer, you can remove the blockin layout.

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

You can also use TFrameStand from Andrea Magni (downloadable directly from GetIt) who propose to use a TFrame as a dialog box. https://github.com/andrea-magni/TFrameStand

这篇关于使用Delphi 10.2.1 Tokyo的Modal Android对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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