vcl-dxmessagedialog-dot-dxmessagedlg-x28-af914bef-x29.md
Opens a message dialog box with a specified dialog type, message, and a set of buttons.
function dxMessageDlg(const AMessage: string; ADialogType: TMsgDlgType; AButtons: TMsgDlgButtons; AHelpContext: Longint = 0; const AHyperlinkClickProc: TdxMessageDialogHyperlinkClickDelegate = nil; const AShowHyperlinkHintProc: TdxMessageDialogShowHyperlinkHintDelegate = nil): Integer;
| Name | Type | Description |
|---|---|---|
| AMessage | string |
Message dialog box content. The AMessage parameter value initializes the created form’s Message property.
The AMessage parameter supports a set of BBCode-inspired tags that allow you to format message box content.
| | 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 |
A set of buttons on the message dialog box form.
| | 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.
| | AHyperlinkClickProc | TdxMessageDialogHyperlinkClickDelegate |
Optional. Specifies a procedure that handles a click on a hyperlink within the displayed message. The AHyperlinkClickProc parameter value initializes the HyperlinkClickProc property of the created message dialog box form.
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 AShowHyperlinkHintProc parameter value initializes the ShowHyperlinkHintProc property of the created message dialog box form.
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.
|
| Type | Description |
|---|---|
| Integer |
The ID of the button clicked to close the message box.
The function returns 0 if it failed to create a message box, and 2 if a user clicked the Close button or pressed Esc.
Refer to the list of possible return values in the Remarks section.
|
Call the dxMessageDlg function to open a generic dialog box with a specified dialog type, a message and one or more buttons.
The opened message dialog box has the mdsMessageDlg style.
The following code example displays a generic message box with a predefined Error caption, an OK button, and an error icon:
uses
dxMessageDialog, // Declares the dxMessageDlg method
Winapi.Windows; // Declares WinAPI constants
// ...
procedure TMyForm.DemonstrateGenericDxMessageDlg;
var
ADialogType: TMsgDlgType;
AButtons: TMsgDlgButtons;
begin
ADialogType := mtError; // Defines the "Error" dialog title, icon, and sound
AButtons := [mbOk]; // Selects the "OK" button
dxMessageDlg('Incorrect operation!', ADialogType, AButtons); // Displays a message box
end;
#include "dxMessageDialog.hpp" // Declares the dxMessageDlg method
#include <Winapi.Windows.hpp> // Declares WinAPI constants
// Add the following linker directive to the corresponding CPP source file:
#pragma link "dxMessageDialog" // Required to use dxMessageDialog.hpp declarations
// ...
void __fastcall TMyForm::DemonstrateGenericDxMessageDlg()
{
TMsgDlgType ADialogType;
TMsgDlgButtons AButtons;
ADialogType = mtError; // Defines the "Error" dialog title, icon, and sound
AButtons = TMsgDlgButtons() << mbOK; // Selects the "OK" button
dxMessageDlg("Incorrect operation!", ADialogType, AButtons); // Displays a message box
}
The code example in this section displays a message dialog box with a formatted message and a configured button layout. 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.DemonstrateDxMessageDlg1;
var
AMessage, AHelpURL: string;
ADialogType: TMsgDlgType;
AButtons: TMsgDlgButtons;
ACloseAction: Integer;
begin
// Define a formatted message with a hyperlink (using the BBCode-inspired markup)
AHelpURL := 'https://docs.devexpress.com/VCL/dxMessageDialog.dxMessageDlg(AF914BEF)';
AMessage := '[URL=' + AHelpURL + ']dxMessageDlg[/URL] opens a message dialog box with ' +
'a message ([B]AMessage[/B]) and a set of buttons ([B]AButtons[/B]).';
ADialogType := mtInformation; // Defines the "Information" dialog title, icon, and sound
AButtons := mbYesNoCancel; // Defines a button set (Yes, No, and Cancel)
// Display a message box
ACloseAction := dxMessageDlg(AMessage, ADialogType, AButtons);
// 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;
#include "dxMessageDialog.hpp" // Declares the dxMessageDlg method
#include <Winapi.Windows.hpp> // Declares WinAPI constants
// Add the following linker directive to the corresponding CPP source file:
#pragma link "dxMessageDialog" // Required to use dxMessageDialog.hpp declarations
// ...
void __fastcall TMyForm::DemonstrateDxMessageDlg1()
{
UnicodeString AMessage, AHelpURL;
TMsgDlgType ADialogType;
TMsgDlgButtons AButtons;
int ACloseAction;
// Define a formatted message with a hyperlink (using the BBCode-inspired markup)
AHelpURL = "https://docs.devexpress.com/VCL/dxMessageDialog.dxMessageDlg(AF914BEF)";
AMessage =
"[URL=" + AHelpURL + "]dxMessageDlg[/URL] opens a message dialog box with "
"a message ([B]AMessage[/B]) and a set of buttons ([B]AButtons[/B]).";
ADialogType = mtInformation; // Defines the "Information" dialog title, icon, and sound
AButtons = mbYesNoCancel; // Defines a button set (Yes, No, and Cancel)
// Display a message box
ACloseAction = dxMessageDlg(AMessage, ADialogType, AButtons);
// Identify the action used to close the message box
switch (ACloseAction)
{
case IDYES: Caption = "Yes is clicked"; break;
case IDNO: Caption = "No is clicked"; break;
case IDCANCEL: Caption = "Cancel is clicked"; break;
case 0: Caption = "Failed to create a message box"; break;
}
}
The return value identifies the action used to close the message box:
IDOKA user clicked the OK button to close the message box.IDCANCELA user clicked the Cancel or Close button, or pressed Esc to close the message box.IDABORTA user clicked the Abort button to close the message box.IDRETRYA user clicked the Retry button to close the message box.IDIGNOREA user clicked the Ignore button to close the message box.IDYESA user clicked the Yes button to close the message box.IDNOA user clicked the No button to close the message box. See Also
TdxMessageDialogForm.Create Constructor