Marius Andresen
Guest
|
Outlook 2010, Delphi 2006
Hi
I need to add a Group (TadxRibbonGroup) with some Checkboxes at runtime. I already have another Group with other buttons and this works fine so I just need to add these new ones dynamically at startup. I tried the below but it does not work. Please point me in the right direction...
x := TadxRibbonGroup.Create(adxRibbonTab.Controls);
x.Caption := 'Group';
y := TadxRibbonCheckBox.Create(x.Controls);
y.Caption := 'Bool';
|
|
Andrei Smolin
Add-in Express team
Posts: 19096
Joined: 2006-05-11
|
Hello Marius,
You can use the Ribbon components to create Ribbon controls in the OnRibbonBeforeLoad event of the add-in module. The code below shows how you do this.
Another possibility to create Ribbon controls dynamically is to do this in the OnCreate event of an TadxRibbonMenu having the Dynamic property set to true. An example of creating controls in a dynamic menu is given at http://www.add-in-express.com/forum/read.php?PAGEN_1=2&FID=1&TID=11982&1=&11982=#nav_start.
There no other way to create an Office Ribbon control at run time. This is because the Ribbon in Office is mostly static. A workaround is: create a number of controls and show/hide/modify them at run time to imitate some dynamism.
procedure TAddInModule.adxCOMAddInModuleRibbonBeforeLoad(Sender: TObject;
const RibbonID: WideString; var Xml: WideString);
var
ribbonGroup : TadxRibbonGroup;
ribbonCheckBox : TadxRibbonCheckBox;
begin
ribbonGroup := TadxRibbonGroup.Create(adxRibbonTab1.Controls);
ribbonGroup.Id := 'ribbongroup_F19ACFB9E574FBF855E1EE0B2118083';
ribbonGroup.Caption := 'My Group';
ribbonGroup.Ribbons := [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer];
ribbonGroup.Ribbons2010 := [msrOutlookExplorer2010];
ribbonCheckBox := TadxRibbonCheckBox.Create(ribbonGroup.Controls);
ribbonCheckBox.Id := 'ribbonCheckBox61E0A24F88BC4823AD8FD56FC0781844';
ribbonCheckBox.Caption := 'CheckBox';
ribbonCheckBox.Ribbons := [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer];
ribbonCheckBox.Ribbons2010 := [msrOutlookExplorer2010];
end;
Andrei Smolin
Add-in Express Team Leader |
|
Andrei Smolin
Add-in Express team
Posts: 19096
Joined: 2006-05-11
|
You are welcome.
Andrei Smolin
Add-in Express Team Leader |
|