Recent

Author Topic: Is posssible own MessageDlg buttons?  (Read 373 times)

Borneq

  • Full Member
  • ***
  • Posts: 238
Is posssible own MessageDlg buttons?
« on: December 10, 2019, 09:39:35 pm »
For example is:
Code: Pascal  [Select][+][-]
  1. res := MessageDlg('Save file?',mtError,[mbYes,mbNo,mbCancel],0);
But is needed more info to user: No can means "close file and discard changes" or "not close"
list: "Yes", "Save All", "Close discard changes", "Discard all", "Cancel"

wp

  • Hero Member
  • *****
  • Posts: 7204
Re: Is posssible own MessageDlg buttons?
« Reply #1 on: December 10, 2019, 10:03:56 pm »
You are probably searching for the extremely flexible QuestionDlg (https://wiki.freepascal.org/Dialog_Examples#QuestionDlg):

Code: Pascal  [Select][+][-]
  1. const
  2.   mrSaveAll = -1;
  3.   mrCloseAndDiscard = -2;
  4.   mrDiscard = -3;
  5.  
  6. procedure TForm1.Button1Click(Sender: TObject);
  7. var
  8.   res: Integer;
  9. begin
  10.   res := QuestionDlg('Caption of the form', 'This text is displayed inside the form', mtWarning, [
  11.     mrYes, 'Yes',
  12.     mrSaveAll, 'Save All',
  13.     mrCloseAndDiscard, 'Close && discard changes',
  14.     mrDiscard, 'Discard',
  15.     mrCancel, 'Cancel'
  16.     ], 0);
  17.   case res of
  18.     mrYes: ShowMessage('"Yes" clicked');
  19.     mrSaveAll: ShowMessage('"Save All" clicked');
  20.     mrCloseAndDiscard: ShowMessage('"Close & discard changes" clicked');
  21.     mrDiscard: ShowMessage('"Discard" clicked');
  22.     mrCancel: ShowMessage('"Cancel" clicked.');
  23.   end;
  24. end;
« Last Edit: December 10, 2019, 10:09:57 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

 

TinyPortal © 2005-2018