Jump to content
FranzB

FMX : TDialogService.MessageDialog wrong parameter ?

Recommended Posts

Delphin 10.4  does not compile this code ,  but to my understanding this  is a correct set of parameters calling  MessageDialog  FMX version 

 

 

TDialogService.MessageDialog('You want to  ........ ',
    TMsgDlgType.mtConfirmation, TMsgDlgBtn.mbYes,  TMsgDlgBtn.mbNo,  nil,
    procedure(const aResult: TModalResult)
    begin
      if (aResult = mrYes) then
      begin
        // Write code here for pressing button OK
        ......
        Label_Statusbar.Text := ' -> done ';
      end
      else
      begin
        // Write code here for pressing button NO

       ......
        Label_Statusbar.Text := '  -> canceled ';
      end;
    end );

end;

Share this post


Link to post
TDialogService.MessageDialog('You want to  ........ ',
    TMsgDlgType.mtConfirmation, mbYesNo,  TMsgDlgBtn.mbNo,  nil,
    procedure(const aResult: TModalResult) …

Share this post


Link to post

still no luck, compiling this code .... 

 

   TDialogService.MessageDialog('You want to  ........ ',
    TMsgDlgType.mtConfirmation, mbYesNo,  TMsgDlgBtn.mbNo,  nil,
    procedure(const aResult: TModalResult)
    begin
      if (aResult = mrYes) then
      begin
        // Write code here for pressing button OK
        // ......
        Label_Statusbar.Text := ' -> done ';
      end
      else
      begin
        // Write code here for pressing button NO
        // ......
        Label_Statusbar.Text := '  -> canceled ';
      end;
    end );

Share this post


Link to post
2 hours ago, FranzB said:

still no luck, compiling this code .... 

Look at the actual declaration more carefully:

class procedure MessageDialog(
  const AMessage: string;
  const ADialogType: TMsgDlgType;
  const AButtons: TMsgDlgButtons;
  const ADefaultButton: TMsgDlgBtn;
  const AHelpCtx: THelpContext;
  const ACloseDialogProc: TInputCloseDialogProc);

The 3rd parameter is a TMsgDlgButtons, which is a Set of TMsgDlgBtn. But you were originally trying to pass a single TMsgDlgBtn.

 

Also, the 5th parameter is a THelpContext, which is an integer, not a pointer.  So, you can't pass nil to it.

 

Try this:

TDialogService.MessageDialog(
  'You want to  ........ ',
  TMsgDlgType.mtConfirmation,
  mbYesNo, // or [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo]
  TMsgDlgBtn.mbNo,
  0,
  procedure(const aResult: TModalResult) begin ... end
);

 

Edited by Remy Lebeau

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

×