Back to Devexpress

TdxMessageDialogForm.FindButton(TMsgDlgBtn) Method

vcl-dxmessagedialog-dot-tdxmessagedialogform-dot-findbutton-x28-vcl-dot-dialogs-dot-tmsgdlgbtn-x29.md

latest3.3 KB
Original Source

TdxMessageDialogForm.FindButton(TMsgDlgBtn) Method

Provides access to a button by its type.

Declaration

delphi
function FindButton(AButton: TMsgDlgBtn): TcxButton;

Parameters

NameTypeDescription
AButtonTMsgDlgBtn

The target message box button type.

|

Returns

TypeDescription
TcxButton

A DevExpress counterpart of the standard TButton component.

If the message box form has no specified button, the FindButton function returns nil (in Delphi) or nullptr (in C++Builder).

|

Remarks

Call the FindButton function to access and customize individual buttons on the message box form. Then call the AlignButtons procedure to recalculate the layout to fit custom button content.

Code Example: Define Custom Button Captions in a Message Box

The following code example changes captions of Yes , No , and Cancel buttons:

delphi
uses dxMessageDialog;
// ...
var
  ADialog: TdxMessageDialogForm;
  AMessage: string;
begin
  AMessage := 'One or more margins are set outside the printable area of the page.' + #13#10 +
    #13#10 + '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
    ADialog.ShowModal; // Invokes the form as a modal dialog
  finally
    ADialog.Free; // Releases the message box form when a user closes it
  end;
end;
cpp
#include "dxMessageDialog.hpp"
// ...
  TdxMessageDialogForm *ADialog;
  UnicodeString AMessage = "One or more margins are set outside the printable area of the page.\n" +
    "\n" + "Click the [B]Fix[/B] button to increase these margins.";
  ADialog = dxCreateMessageDialog(AMessage, wtWarning, mbYesNoCancel);
  try
  {
    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
  }
  __finally
  {
    delete ADialog; // Releases the message box form when a user closes it
  }

See Also

Message Dialog Boxes

BBCode-Inspired Text Formatting Markup

TdxMessageDialogForm Class

TdxMessageDialogForm Members

dxMessageDialog Unit