Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxMessageDialogForm.SetDefaultButton(TMsgDlgBtn) Method

Sets the specified button as the default button in the message dialog box.

#Declaration

Delphi
procedure SetDefaultButton(AButton: TMsgDlgBtn); virtual;

#Parameters

Name Type Description
AButton TMsgDlgBtn

The target message dialog button type.

#Remarks

The default message box button has focus when the message box is invoked.

VCL Editors Library: A Message Dialog Box Example

#Code Example: Change the Default Message Box Button

The following code example sets the No button as default:

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]Yes[/B] button to increase these margins.';
  ADialog := dxCreateMessageDialog(AMessage, mtWarning, mbYesNoCancel);
  try
    ADialog.SetDefaultButton(mbNo);
    ADialog.ShowModal;
  finally
    ADialog.Free;
  end;
end;

VCL Editors Library: A Modified Default Button Example

See Also