Skip to main content

TdxMessageDialogForm.FindButton(TMsgDlgBtn) Method

Provides access to a button by its type.

Declaration

function FindButton(AButton: TMsgDlgBtn): TcxButton;

Parameters

Name Type Description
AButton TMsgDlgBtn

The target message box button type.

Returns

Type Description
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:

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;

VCL Editors Library: Custom Button Captions

See Also