Skip to main content

Message Dialog Boxes

  • 4 minutes to read

A message box is a modal dialog designed to display important information and optionally allow a user to make a choice or confirm an operation. All DevExpress products use the TdxMessageDialogForm class to display message dialog boxes that support skins and BBCode-inspired markup tags:

VCL Editors Library: A Message Dialog Box Example

Create a Skinnable Message Box

Skinnable message dialog boxes allow you to keep the appearance of your application consistent. They import all look & feel settings from the TdxSkinController component if it is in an application project. To create such a message box, call one of the global DevExpress methods that have the same API as the corresponding standard VCL library methods:

DevExpress Method Standard VCL Method Description
dxCreateMessageDialog CreateMessageDialog Creates a message dialog box form with the specified settings.
dxMessageBox TApplication.MessageBox Invokes a modal message dialog box.
dxMessageDlg MessageDlg Invokes a modal message dialog box.
dxMessageDlgPos MessageDlgPos Invokes a modal message dialog box at the specified position on the screen.
dxMessageDlgPosHelp MessageDlgPosHelp Invokes a message dialog box whose help topic is supplied in a specified help file.
dxShowMessage ShowMessage Invokes a generic message dialog box with an OK button.
dxShowMessageFmt ShowMessageFmt Displays a message dialog box with a formatted message.
dxShowMessagePos ShowMessagePos Invokes the message dialog box at the specified position on the screen.

All DevExpress controls and components invoke these global methods to display message boxes. If you call DevExpress methods to invoke message boxes, you can use the global dxUseStandardMessageDialogs global variable to switch between standard and skinnable DevExpress message boxes.

Message Box Content Formatting

All message box creation methods allow you to pass the required message as a parameter. Once a message dialog box form is created, you can use its Message property to change the displayed message.

Supported BBCode-Inspired Markup Tags

Text Formatting Attribute Message Text with Tags Example
Bold '[B]DevExpress[/B]' VCL Editors Library: A Bold Font Attribute Example
Italic '[I]DevExpress[/I]' VCL Editors Library: An Italic Font Attribute Example
Underscore '[U]DevExpress[/U]' VCL Editors Library: An Underscore Font Attribute Example
Strikeout '[S]DevExpress[/S]' VCL Editors Library: A Strikeout Font Attribute Example
Subscript 'Dev[Sub]Express[/Sub]' VCL Editors Library: A Subscript Font Attribute Example
Superscript 'Dev[Sup]Express[/Sup]' VCL Editors Library: A Superscript Font Attribute Example
Custom Font 'Dev[U][Font=Consolas][Size=12]Express[/U][/Font][/Size]' VCL Editors Library: A Custom Font Settings Example
Color '[Color=#E67E22]Dev[/Color][Color=Gray]Express[/Color]' VCL Editors Library: A Color Font Attribute Example
Background Color '[BackColor=Orange]DevExpress[/BackColor]' VCL Editors Library: A Background Color Font Attribute Example
Hyperlink '[URL=]DevExpress[/URL]' VCL Editors Library: A Hyperlink Example
No Parse '[NOPARSE][B]DevExpress[/B][/NOPARSE]' VCL Editors Library: A "No Parse" Example

Customize Dialog Buttons

The TdxMessageDialogForm includes one or more TcxButton components to display message box buttons. You can use the TdxMessageDialogForm.Buttons property or call the TdxMessageDialogForm.FindButton function to change predefined button captions before the form is displayed. The following code example changes captions of Yes, No, and Cancel buttons:

uses dxMessageDialog;
// ...
  ADialog: TdxMessageDialogForm;
  AMessage: string;
  AMessage := 'One or more margins are set outside the printable area of the page.' + #13#10 +
    + #13#10 + 'Choose the [B]Fix[/B] button to increase the appropriate margins.';
  ADialog := dxCreateMessageDialog(AMessage, mtWarning, mbYesNoCancel);
    ADialog.FindButton(mbYes).Caption := 'Fix';
    ADialog.FindButton(mbNo).Caption := 'Restore Original';
    ADialog.FindButton(mbCancel).Caption := 'Close';

    ADialog.AlignButtons;   // Recalculates the button layout
    ADialog.ShowModal;      // Invokes the form as a modal dialog
    ADialog.Free;           // Releases the message box when a user closes it

VCL Editors Library: Custom Button Captions

Customize the Message Box Layout

The message dialog box form has multiple layout customization options:

Change the UseLatestCommonDialogs Global Variable

Set the UseLatestCommonDialogs global variable to True or False to switch between two predefined layouts also available for standard VCL message boxes:

Value Description Example
True (Default) The modern message box style available in Microsoft Windows® Vista and later operating systems. The message box has a fixed width; buttons are right-aligned. VCL Editors Library: Modern Message Box Style
False The message box style found in Microsoft Windows® XP and older operating systems. The width of the message box depends on its content size; buttons are centered. VCL Editors Library: Windows XP Message Box Style

Use the TdxMessageDialogForm.Style Property

You can set the form’s Style property to mdsMessageBox or mdsMessageDlg to switch between two layout styles that imitate message boxes that different VCL library methods can invoke:

Value Description Example
mdsMessageDlg (default) This message dialog style imitates dialogs that the standard MessageDlg function invokes. The message box layout has increased paddings between borders and the message icon. VCL Editors Library: A Message Dialog Style Example
mdsMessageBox This message box style imitates dialog boxes that the standard MessageBox function invokes. The message box layout is smaller compared to the message dialog style (mdsMessageDlg). VCL Editors Library: A Message Box Style Example


This layout customization option is available only before you manually display a skinnable message dialog box form after you call the dxCreateMessageDialog function or the form constructor.

Create a Custom Message Dialog Box Form

You can replace the built-in message dialog box form with a custom implementation:

  1. Derive a custom form from the TdxMessageDialogForm class.
  2. Assign a reference to your form class to the dxMessageDialogFormClass global variable.