dxMessageDlg(string,string,TMsgDlgType,TMsgDlgButtons,Longint,TMsgDlgBtn,TdxMessageDialogHyperlinkClickDelegate,TdxMessageDialogShowHyperlinkHintDelegate) Method
Opens a message dialog box with a specified dialog type, title, message, and a set of buttons (and allows you to specify the default button).
Declaration
function dxMessageDlg(const AMessage: string; const ATitle: string; ADialogType: TMsgDlgType = TMsgDlgType.mtInformation; AButtons: TMsgDlgButtons = [mbOK]; AHelpContext: Longint = 0; ADefaultButton: TMsgDlgBtn = TMsgDlgBtn.FirstButton; const AHyperlinkClickProc: TdxMessageDialogHyperlinkClickDelegate = nil; const AShowHyperlinkHintProc: TdxMessageDialogShowHyperlinkHintDelegate = nil): Integer;
Parameters
| Name | Type | Description |
|---|---|---|
| AMessage | string | Message dialog box content. The The |
| ATitle | string | A message dialog box caption. You can pass an empty string as the |
| ADialogType | TMsgDlgType | A message dialog box type that determines the predefined caption, system icon, and sound of the message dialog box. This parameter value initializes the created form’s DialogType property. |
| AButtons | TMsgDlgButtons | Optional. A set of buttons on the message dialog box form. If this parameter is omitted, the message box will display an OK button (mbOk). |
| AHelpContext | Longint | Optional. A context ID of the help topic associated with the created message box. Users can click the Help button or press F1 to open the associated help topic. |
| ADefaultButton | TMsgDlgBtn | Optional. A button type. Use this parameter to specify the button that has focus when the message box appears. If this parameter is omitted, the first button on the message box has focus ( |
| AHyperlinkClickProc | TdxMessageDialogHyperlinkClickDelegate | Optional. Specifies a procedure that handles a click on a hyperlink within the displayed message. The You can define a click handler procedure to identify the clicked hyperlink and prevent certain links from being activated. Tip Refer to the TdxMessageDialogHyperlinkClickDelegate procedural type description for detailed information and a code example. |
| AShowHyperlinkHintProc | TdxMessageDialogShowHyperlinkHintDelegate | Optional. Specifies a procedure that handles a hyperlink hint display event. The You can define a hyperlink hint handler procedure to change the predefined hint message (the hyperlink target URI) depending on certain conditions in your application. Tip Refer to the TdxMessageDialogShowHyperlinkHintDelegate procedural type description for detailed information and a code example. |
Returns
| Type | Description |
|---|---|
| Integer | The ID of the button clicked to close the message box. The function returns Refer to the list of possible return values in the Remarks section. |
Remarks
Call the dxMessageDlg function to open a generic dialog box with a specified dialog type, a message and one or more buttons.
The current function overload additionally allows you to specify the message box title and the default button.
The opened message dialog box has the mdsMessageDlg style.

Code Example: Display a Message Dialog and Identify the User Action
The following code example opens a message dialog box with a formatted message, title, and a configured button layout (with the initially focused Cancel button). The demonstrated procedure identifies the action used to close the message box.
uses
dxMessageDialog, // Declares the dxMessageDlg method
Winapi.Windows; // Declares WinAPI constants
// ...
procedure TMyForm.DemonstrateDxMessageDlg3;
var
ATitle, AMessage, AHelpURL: string;
ADialogType: TMsgDlgType;
AButtons: TMsgDlgButtons;
ADefaultButton: TMsgDlgBtn;
AHelpContext, ACloseAction: Integer;
begin
// Define a formatted message with a hyperlink (using the BBCode-inspired markup)
AHelpURL := 'https://docs.devexpress.com/VCL/dxMessageDialog.dxMessageDlg(80E4ACD7)';
AMessage := '[URL=' + AHelpURL + ']dxMessageDlg[/URL] opens a message dialog box with ' +
'a message ([B]AMessage[/B]) and a set of buttons ([B]AButtons[/B]).' +
sLineBreak + sLineBreak +
'This function overload allows you to set the message box title ([B]ATitle[/B]) ' +
'and select the default button ([B]ADefaultButton[/B]).';
ATitle := 'Message Box Example'; // Defines a message box title
ADialogType := mtInformation; // Defines the "Information" dialog icon and sound
AButtons := mbYesNoCancel; // Defines a button set (Yes, No, and Cancel)
ADefaultButton := mbCancel; // Moves focus to the Cancel button
AHelpContext := 0; // Retains the default help context
// Display a message box
ACloseAction :=
dxMessageDlg(AMessage, ATitle, ADialogType, AButtons, AHelpContext, ADefaultButton);
// Identify the action used to close the message box
case ACloseAction of
IDYES: Caption := 'Yes is clicked';
IDNO: Caption := 'No is clicked';
IDCANCEL: Caption := 'Cancel is clicked';
0: Caption := 'Failed to create a message box';
end;
end;

Return Values
The return value identifies the action used to close the message box:
- IDOK
- A user clicked the OK button to close the message box.
- IDCANCEL
- A user clicked the Cancel or Close button, or pressed Esc to close the message box.
- IDABORT
- A user clicked the Abort button to close the message box.
- IDRETRY
- A user clicked the Retry button to close the message box.
- IDIGNORE
- A user clicked the Ignore button to close the message box.
- IDYES
- A user clicked the Yes button to close the message box.
- IDNO
- A user clicked the No button to close the message box.