Back to Devexpress

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

vcl-155009-expressbars-how-to-ribbon-add-a-dialog-launcher-to-the-ribbon-tab-group-in-code.md

latest2.8 KB
Original Source

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

  • Dec 28, 2020

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

delphi
//...
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

TdxBar

TdxBarScreenTipRepository

TdxRibbonTabGroup

TdxBarScreenTip

TdxBar.CaptionButtons

How to Add a Dialog Launcher to the Ribbon Tab Group at Design Time

How to Create a Ribbon Control at Design Time

Ribbon KeyTips

Ribbon Tab Group