Jump to content
baquelo

MessageDialog in Delphi 10.3

Recommended Posts

Hi!!

I need a confirmation box (Yes and No options) in Android, but in Delphi 10.3 dont work, the app crash... In the Delphi 10.1 work fine...

 

Function TForm1.mensagemConfirmacao(pMensagem: String): TModalResult;
Var
  MR: TModalResult;
Begin
  MR := mrNone;
  TDialogService.MessageDialog(pMensagem, TMsgDlgType.mtConfirmation,
    [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0,
    Procedure(Const AResult: TModalResult)
    Begin
      MR := AResult;
    End);
  While MR = mrNone Do
  begin
    Application.ProcessMessages;
  end;
  result := MR;
End;



Help me please!!

Share this post


Link to post

This code working just fine in 10.3 Android & Windows ... dont' know with Tmodalresult

  TDialogService.MessageDialog((mymessage),
      system.UITypes.TMsgDlgType.mtConfirmation,
      [system.UITypes.TMsgDlgBtn.mbYes, system.UITypes.TMsgDlgBtn.mbNo], system.UITypes.TMsgDlgBtn.mbYes,0,
procedure (const AResult: System.UITypes.TModalResult)
  begin
          case AResult of
            mrYES: Begin .....

br,

Edited by mausmb
  • Thanks 1

Share this post


Link to post
On 1/16/2019 at 4:10 PM, mausmb said:

This code working just fine in 10.3 Android & Windows ... dont' know with Tmodalresult


  TDialogService.MessageDialog((mymessage),
      system.UITypes.TMsgDlgType.mtConfirmation,
      [system.UITypes.TMsgDlgBtn.mbYes, system.UITypes.TMsgDlgBtn.mbNo], system.UITypes.TMsgDlgBtn.mbYes,0,
procedure (const AResult: System.UITypes.TModalResult)
  begin
          case AResult of
            mrYES: Begin .....

br,

Thanks for reply! I reinstall Delphi 10.1.

Share this post


Link to post
On 1/16/2019 at 1:22 PM, baquelo said:

  While MR = mrNone Do
  begin
    Application.ProcessMessages;
  end;

I always consider the Application.ProcessMessages suspicious, do you really need this ?

Usualy I'm fine when reacting to my stuff directly in the anonymous procedure.

Edited by Rollo62
  • Like 1

Share this post


Link to post
7 hours ago, Rollo62 said:

I always consider the Application.ProcessMessages suspicious, do you really need this ?

Usualy I'm fine when reacting to my stuff directly in the anonymous procedure.

I'm a beginner in Delphi and I picked up a project in the company where the programmer used the code that way. I was just migrating the Delphi 10.1 project to Delphi 10.3. I did not really think about using the anonymous procedure. Soon I will reinstall Delphi 10.3 and I will proceed to use the anonymous procedure. Many thanks for the reply.

Share this post


Link to post

The anonymous procedure helps to keep your app responsive, instead just showing a modal dialog or form.
This is required on mobile devices, but I also highly recommend to use the same strategy for desktop too.

There are many other methods to prevent unwanted user actions while the dialog is shown, beside modal dialogs and forms.

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×