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

# MessageDlg

Message Dialog

## Declaration

Source position: line 0

`function MessageDlg(`
`const aMsg: String;`
`DlgType: TMsgDlgType;`
`Buttons: TMsgDlgButtons;`
`HelpCtx: LongInt`
`):Integer; function MessageDlg(`
`const aCaption: String;`
`const aMsg: String;`
`DlgType: TMsgDlgType;`
`Buttons: TMsgDlgButtons;`
`HelpCtx: LongInt`
`):Integer; function MessageDlg(`
`const aCaption: String;`
`const aMsg: String;`
`DlgType: TMsgDlgType;`
`Buttons: TMsgDlgButtons;`
`HelpCtx: LongInt;`
`DefaultButton: TMsgDlgBtn`
`):Integer; function MessageDlg(`
`const aCaption: String;`
`const aMsg: String;`
`DlgType: TMsgDlgType;`
`Buttons: TMsgDlgButtons;`
`const HelpKeyword: String`
`):Integer;`

## Arguments

`aMsg` |  | The message to be shown.
`DlgType` |  | The type of dialog to be shown
`Buttons` |  | Determines the buttons shown on the messagedialog
`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.
This is expresed as an integer

## Arguments

`aCaption` |  | Used to set the caption of the messagedialog.
`aMsg` |  | The message to be shown.
`DlgType` |  | The type of dialog to be shown
`Buttons` |  | Determines the buttons shown on the messagedialog
`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.
This is expresed as an integer

## Arguments

`aCaption` |  | Used to set the caption of the messagedialog.
`aMsg` |  | The message to be shown.
`DlgType` |  | The type of dialog to be shown
`Buttons` |  | Determines the buttons shown on the messagedialog
`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.
This is expresed as an integer

## Arguments

`aCaption` |  | Used to set the caption of the messagedialog.
`aMsg` |  | The message to be shown.
`DlgType` |  | The type of dialog to be shown
`Buttons` |  | Determines the buttons shown on the messagedialog

## Function result

The result of this function is the button the user pressed to close the dialog.
This is expresed as an integer

## Description

Show a message to the user and receive his response.
There are four versions of this function.
The first version displays a dialog with the standard caption,
the second, third and fourth versions enable you to set the caption.
The third version allows for a Default button;
the fourth version contains a help keyword instead of using context-based help.
If the first 'Caption' argument is missing, no caption is shown on the box.
This is the most complete and elaborate of the message dialogs,
and allows the programmer considerable control over the appearance of the dialog box.
The arguments defining the kind of box and its icon are types rather than integer constants,
and the buttons can be specified as a set in square brackets
eg [mbRetry, mbIgnore, mbAbort, mbCancel].
The HelpCtx argument allows the use of Context Help
The return value from the Function is the identity of the button pressed,
expressed as an integer (see the constant definitions in TControl , [mrNone..mrAll]).

## Example

     Uses forms, dialogs, lcltype, controls;

     procedure TryMessageDlg;
     begin
       if MessageDlg ('Question', 'Do you wish to Execute?', mtConfirmation,
                      [mbYes, mbNo, mbIgnore],0) = mrYes
       then { Execute rest of Program };
      end;

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