vcl-dxmessagedialog-dot-dxcreatemessagedialog-x28-15cf10d9-x29.md
Creates a message dialog box with a specified dialog type, message, and a set of buttons.
function dxCreateMessageDialog(const AMessage: string; ADialogType: TMsgDlgType; AButtons: TMsgDlgButtons; const AHyperlinkClickProc: TdxMessageDialogHyperlinkClickDelegate = nil; const AShowHyperlinkHintProc: TdxMessageDialogShowHyperlinkHintDelegate = nil): TdxMessageDialogForm;
| 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.
| | 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 |
|---|---|
| TdxMessageDialogForm |
The created message dialog box form.
|
You can call the dxCreateMessageDialog function instead of the TdxMessageDialogForm constructor. The created message dialog box has the mdsMessageDlg style.
Note
The dxUseStandardMessageDialogs global variable has no effect on dxCreateMessageDialog function calls.
The code example in this section calls the dxCreateMessageDialog function to create a message box with Yes , No , and Cancel buttons. This example displays the message box using ShowModal and identifies the action used to close the message box.
uses
dxMessageDialog, // Declares the dxCreateMessageDialog method
Winapi.Windows; // Declares WinAPI constants
// ...
procedure TMyForm.DemonstrateDxCreateMessageDialog1;
var
AMessage, AHelpURL, AShowModalURL: string;
ADialogType: TMsgDlgType;
AButtons: TMsgDlgButtons;
ADialog: TdxMessageDialogForm;
ACloseAction: Integer;
begin
// Define a formatted message with hyperlinks (using the BBCode-inspired markup)
AHelpURL := 'https://docs.devexpress.com/VCL/dxMessageDialog.dxCreateMessageDialog(15CF10D9)';
AShowModalURL := 'https://docwiki.embarcadero.com/Libraries/en/Vcl.Forms.TCustomForm.ShowModal';
AMessage :=
'[URL=' + AHelpURL + ']dxCreateMessageDialog[/URL] creates a message dialog box ' +
'with a message ([B]AMessage[/B]) and a set of buttons ([B]AButtons[/B]).' +
sLineBreak + sLineBreak +
'Use [URL=' + AShowModalURL + ']ShowModal[/URL] to display the message box.';
ADialogType := mtInformation; // Defines the "Information" dialog title, icon, and sound
AButtons := mbYesNoCancel; // Defines a button set (Yes, No, and Cancel)
// Creates a message dialog form
ADialog := dxCreateMessageDialog(AMessage, ADialogType, AButtons);
try
ACloseAction := ADialog.ShowModal; // Displays the form as a modal dialog
finally
ADialog.Free; // Releases the message dialog form once a user closes it
end;
// 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 dxCreateMessageDialog 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::DemonstrateDxCreateMessageDialog1()
{
UnicodeString AMessage, AHelpURL, AShowModalURL;
TMsgDlgType ADialogType;
TMsgDlgButtons AButtons;
TdxMessageDialogForm *ADialog;
int ACloseAction;
// Define a formatted message with hyperlinks (using the BBCode-inspired markup)
AHelpURL = "https://docs.devexpress.com/VCL/dxMessageDialog.dxCreateMessageDialog(15CF10D9)";
AShowModalURL = "https://docwiki.embarcadero.com/Libraries/en/Vcl.Forms.TCustomForm.ShowModal";
AMessage =
"[URL=" + AHelpURL + "]dxCreateMessageDialog[/URL] creates a message dialog box "
"with a message ([B]AMessage[/B]) and a set of buttons ([B]AButtons[/B])." +
sLineBreak + sLineBreak +
"Use [URL=" + AShowModalURL + "]ShowModal[/URL] to display the message box.";
ADialogType = mtInformation; // Defines the "Information" dialog title, icon, and sound
AButtons = mbYesNoCancel; // Defines a button set (Yes, No, and Cancel)
// Creates a message dialog form
ADialog = dxCreateMessageDialog(AMessage, ADialogType, AButtons);
try
{
ACloseAction = ADialog->ShowModal(); // Displays the form as a modal dialog
}
__finally
{
delete ADialog; // Releases the message dialog form once a user closes it
}
// 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 code example in this section calls the dxCreateMessageDialog function to create a message box with three buttons, and changes their captions to Fix , Restore Original , and Close. This example displays the message box using ShowModal and identifies the action used to close the message box.
uses
dxMessageDialog, // Declares the dxCreateMessageDialog method
Winapi.Windows; // Declares WinAPI constants
// ...
procedure TMyForm.DemonstrateDxCreateMessageDialog3;
var
ADialog: TdxMessageDialogForm;
AMessage: string;
ACloseAction: Integer;
begin
AMessage := 'One or more margins are set outside the printable area of the page.' +
sLineBreak + sLineBreak + 'Click the [B]Fix[/B] button to increase these margins.';
ADialog := dxCreateMessageDialog(AMessage, mtWarning, mbYesNoCancel);
try
ADialog.FindButton(mbYes).Caption := 'Fix';
ADialog.FindButton(mbNo).Caption := 'Restore Original';
ADialog.FindButton(mbCancel).Caption := 'Close';
ADialog.AlignButtons; // Recalculates the button layout
ACloseAction := ADialog.ShowModal; // Displays the form as a modal dialog
finally
ADialog.Free; // Releases the message dialog form once a user closes it
end;
// Identify the action used to close the message box
case ACloseAction of
IDYES: Caption := 'Fix is clicked';
IDNO: Caption := 'Restore Original is clicked';
IDCANCEL: Caption := 'Close is clicked';
0: Caption := 'Failed to create a message box';
end;
end;
#include "dxMessageDialog.hpp" // Declares the dxCreateMessageDialog 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::DemonstrateDxCreateMessageDialog3()
{
TdxMessageDialogForm *ADialog;
UnicodeString AMessage;
int ACloseAction;
AMessage = UnicodeString("One or more margins are set outside the printable area of the page.") +
sLineBreak + sLineBreak + "Click the [B]Fix[/B] button to increase these margins.";
ADialog = dxCreateMessageDialog(AMessage, mtWarning, mbYesNoCancel);
try
{
ADialog->FindButton(mbYes)->Caption = "Fix";
ADialog->FindButton(mbNo)->Caption = "Restore Original";
ADialog->FindButton(mbCancel)->Caption = "Close";
ADialog->AlignButtons(); // Recalculates the button layout
ACloseAction = ADialog->ShowModal(); // Displays the form as a modal dialog
}
__finally
{
delete ADialog; // Releases the message dialog form once a user closes it
}
// Identify the action used to close the message box
switch (ACloseAction)
{
case IDYES: Caption = "Fix is clicked"; break;
case IDNO: Caption = "Restore Original is clicked"; break;
case IDCANCEL: Caption = "Close is clicked"; break;
case 0: Caption = "Failed to create a message box"; break;
}
}
ShowModal returns one of the following values that identify actions 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