[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'Dialogs' (#lcl)

QuestionDlg

Show a question to the user and get a response

Declaration

Source position: dialogs.pp line 689

function QuestionDlg(

  const aCaption: string;

  const aMsg: string;

  DlgType: TMsgDlgType;

  Buttons: array of Const;

  HelpCtx: LongInt

):TModalResult; overload;

function QuestionDlg(

  const aCaption: string;

  const aMsg: string;

  DlgType: TMsgDlgType;

  Buttons: array of Const;

  const HelpKeyword: string

):TModalResult; overload;

Arguments

aCaption

  

Used to set the caption of the question dialog.

aMsg

  

The question to be shown.

DlgType

  

The type of dialog to be shown in fact which icon will be shown.

Buttons

  

An array of return values and caption for the buttons on the question dialog.

HelpCtx

  

HelpCtx is used to specify which topic from the help should be shown.

Function result

The result of this function is the button the user pressed to close the dialog.

Arguments

aCaption

  

Used to set the caption of the question dialog.

aMsg

  

The question to be shown.

DlgType

  

The type of dialog to be shown in fact which icon will be shown.

Buttons

  

An array of return values and caption for the buttons on the question dialog.

Description

QuestionDlg has the same functionality as MessageDlg except for the parameter Buttons which is of a different type.
You can define your own captions and return values of this function.

Buttons is a list of TModalResult (defined as constants [mrNone..MrYesToAll] in Controls) and strings.
For each TModalResult a button is created.
To set a custom caption, add a string after a button. You can use the special string parameters 'isdefault' and 'iscancel' to setup the default and cancel buttons.

The default TModalResults defined in controls.pp (mrNone..mrLast) don't need a caption. The default captions will be used.

You can mark one default button using the 'IsDefault' option. When the user presses 'Return' this button is triggered.

Some widgetsets provide an Escape key and/or a close button. This results in mrCancel even if it is not in the given button list. Use the 'IsCancel' option to redirect it to a button of your choice. You can combine 'IsDefault' and 'IsCancel'.

case QuestionDlg('COPYING',
                   'Abort?',
                   mtConfirmation,
                   [mrNo, '&No','IsDefault',
                   mrYes,'&Yes'],0) 
of
   mrYes : ShowMessage('You clicked Yes');
   mrNo : ShowMessage('You clicked No');
else
  // mrCancel
  ShowMessage('You cancelled the dialog.');
end;

See also

MessageDlg

  

Message Dialog

InputQuery

  

Use InputQuery to show a dialog box to get some input from the user

The latest version of this document can be found at lazarus-ccr.sourceforge.net.