Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why MessageDlg show only "OK" button under windows?

With delphi 10.2.2 firemonkey, under windows, when i do :

MessageDlg('Are you sure you want to undo the last operation ?', // const AMessage: string;
             TMsgDlgType.mtConfirmation, // const ADialogType: TMsgDlgType;
             [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbCancel], // const AButtons: TMsgDlgButtons;
             0, // const AHelpContext: THelpContext;
             TMsgDlgBtn.mbCancel, // const ADefaultButton: TMsgDlgBtn;
             procedure(const AResult: TModalResult)
             begin
               if AResult = mrYes then begin
               end;
             end); // const ACloseDialogProc: TInputCloseDialogProc);

then only a "OK" button is show in the popup dialog (no "cancel" nor "yes"). Is it normal or I miss something ?

like image 244
zeus Avatar asked Jul 12 '18 13:07

zeus


1 Answers

It happens because Delphi checks valid button combinations and for the combination of Yes and Cancel there's no corresponding dialog box type on Windows platform. That you get just dialog with the OK button is because the structure passed to the Windows API function is zeroed at the beginning and the value of the uType parameter MB_OK is just 0.

The Windows implementation of this is inside the TFMXDialogService.MessageDialog method, within the FMX.Dialogs.Win module.

like image 108
Victoria Avatar answered Oct 10 '22 03:10

Victoria