Skip to main content

How to Add a Dialog Launcher to the Ribbon Tab Group in Code

The following example demonstrates how to add a dialog launcher button to the Ribbon tab group programmatically.

//...
type
  TRibbonDemoMainForm = class(TdxRibbonForm)
    BarManager: TdxBarManager;
    BarManagerBar5: TdxBar;
    dxBarScreenTipRepository1: TdxBarScreenTipRepository;
    procedure FontClick(Sender: TObject);
//...
var
  STBitmap: TBitmap;
//...
// ------------------------------------------------
// Provide implementation for the dialog launcher's OnClick event
// ------------------------------------------------
procedure TRibbonDemoMainForm.FontClick(Sender: TObject);
begin
  FontDialog.Font.Assign(Editor.SelAttributes);
  if FontDialog.Execute then
    Editor.SelAttributes.Assign(FontDialog.Font);
end;
//...
// ------------------------------------------------
// Create a new ScreenTip for the dialog launcher button
// ------------------------------------------------
var
  stFontDialog: TdxBarScreenTip;
begin
  stFontDialog := dxBarScreenTipRepository1.Items.Add;
  with stFontDialog do
  begin
    Header.Text := 'Font Dialog';
    Description.Glyph := STBitmap;
    Description.Text := 'Show the Font dialog box';
  end;
end;
//...
// ------------------------------------------------
// Create a new dialog launcher button with required attributes
// ------------------------------------------------
with BarManagerBar5.CaptionButtons.Add do
begin
  KeyTip := 'FN';
  ScreenTip := stFontDialog;
  OnClick := FontClick;
end;
//...
initialization
  STBitmap := TBitmap.Create;
  STBitmap.LoadFromFile('FontDlgIcon.bmp');
end.

The following image shows the dialog launcher button’s KeyTip and ScreenTip:

The following image shows the button’s event handler execution result, after the button has been clicked:

See Also