TCustomDialogButton functionality

Hi,

If I have the following code:

procedure TMain.Form1Show(Sender: TObject);
var
  dlg:TMessageDlg;
  button:TCustomDialogButton;
begin
  dlg:=TMessageDlg.Create(Self);
  button:=dlg.CustomButtons.Add;
  button.Caption:='A Button';
  button.ElementClassName:='btn btn-primary';
  dlg.Show;
end;

A button is produced with the text as specified. I have a few questions about the functionality of the TCustomDialogButton:

  1. What does the ElementClassName property do? My thought was it would allow fine grain styling of the custom button but this does not happen.
  2. How does one set the modal result of the button? I can't see anyway of doing this.
  3. Not so much a question but I noticed that the HTML ID of the button is set as whatever the caption is. Is it possible/would it be possible to set the ID of the button as a property instead?

Thanks!

Test code with a WebMessageDlg dropped on a form where CSSLibrary is set to cssBootstrap

image

with code:

var
  btn: TCustomDialogButton;
begin
  webmessagedlg1.Title := 'Hello world';
  webmessagedlg1.Message := 'This is a test message';
  btn := webmessagedlg1.CustomButtons.Add;
  btn.Caption := 'Test';
  btn.ElementClassName := 'btn btn-primary';

  btn := webmessagedlg1.CustomButtons.Add;
  btn.Caption := 'Warning';
  btn.ElementClassName := 'btn btn-warning';

  webmessagedlg1.Show;

The result of the dialog is retrieved with WebMessageDlg.DialogResult: integer;

This is a value starting at 100 for the custom buttons and values like mrOK, mrCancel, etc.... for the normal buttons

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.