vcl-dxmessagedialog-dot-tdxmessagedialogform-dot-findbutton-x28-vcl-dot-dialogs-dot-tmsgdlgbtn-x29.md
Provides access to a button by its type.
function FindButton(AButton: TMsgDlgBtn): TcxButton;
| Name | Type | Description |
|---|---|---|
| AButton | TMsgDlgBtn |
The target message box button type.
|
| 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).
|
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.
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;
#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