Posts 1 - 10 of 12
First | Prev. | 1 2 | Next | Last
|
|
Francesco Faleschini
Posts: 26
Joined: 2014-05-15
|
i am implementing TadxRibbonContextMenu to support Outlook 2013 and i want to do same thing which i already implemented using TadxContextMenu (that was ok for Outolook 2003-2010).
i used TadxContextMenu.OnBeforeAddControls event to add popup items at run time, is there any equivalent event /place for TadxRibbonContextMenu where i can add popup items run time?
Scenario : TadxRibbonContextmenu is Assigned to MailItem, so every rightclick of mail item i want to delete previous popup items and generate new popup Items. |
|
Posted 15 May, 2014 03:13:05
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Hello Francesco,
Ribbon controls are static from birth. The only control providing some dynamism is TadxRibbonMenu having the Dynamic property set to true. You populate this control in the OnCreate event, see http://www.add-in-express.com/forum/read.php?PAGEN_1=2&FID=1&TID=11982&1=&11982=#nav_start.
If you need to add controls directly to the context menu, not to a popup control (TadxRibbonMenu), consider pre-creating the required number of controls and modifying their properties (Caption, visible, etc.) at run time depending on the context. Please see sections "Updating Ribbon Controls at Run-Time" and "Determining a Ribbon Control's Context" in the PDF file in the folder {Add-in Express}\Docs on your development PC.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 15 May, 2014 04:16:00
|
|
Top
|
|
Francesco Faleschini
Posts: 26
Joined: 2014-05-15
|
Thanks Andrei.
I need to add items to the popupmenu as the popupmenu is diplayed. You said that "ribbon controls are static from birth".
I need an example that does not use OnCreate, but as OnPopup in Delphi, simply out: on right click on a mailitem i need to add at runtime some menuitems and submenu items.
How to do this?
Note: Oncreate it is too early for me. Up to 2010 i was using TadxContextMenu and this allowed to do this, unfortunately TadxContextMenu is not supported by outlook 2013.
I hope you can suggest me a way out soon since i am stuck since weeks on this.
Thanks. |
|
Posted 16 May, 2014 08:57:09
|
|
Top
|
|
Bart Van Bossche
Guest
|
Hi Francesco,
I know what you mean, I have a ribbon menu that needs to have different buttons at runtime.
The solution I use is the following: I've added a lot of buttons to my menu in design and at runtime I just use the needed buttons and change their captions, icons etc. and I just put the remaining buttons invisible.
So I suggest you create a popupmenu with for example 10 items and just change those items on the fly ;) |
|
Posted 16 May, 2014 09:05:53
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Thank you Bart!
Francesco,
You need to set TadxRibbonMenu.Dynamic=true. In this case the event occurs when you expand the menu.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 16 May, 2014 09:14:53
|
|
Top
|
|
Francesco Faleschini
Posts: 26
Joined: 2014-05-15
|
I tried to add runtime Ribbon context menu items the way you suggested, i had error while assigning caption "The add-in has fired an exception.The parameter is incorrect"
Please suggest/pinpoint the problem in the example
object RCM: TadxRibbonContextMenu
ContextMenuNames.Strings = (
'Outlook.Explorer.ContextMenuMailItem')
Left = 168
Top = 88
ControlTypes = {010000000F000000}
Controls_ = <
item
Dynamic = True
Id = 'adxRibbonMenu249CCB92F6C34B0B86849AB3682BF330'
OnCreate = RCMControls0Create
Caption = 'Invia a'
Ribbons = [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer]
Ribbons2010 = [msrOutlookExplorer2010]
ControlTypes = {010000000F000000}
Controls_ = <
item
Id = 'adxRibbonMenu920B4A508ADD4CC194F421F825E9E676'
Caption = 'Recenti'
Ribbons = [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer]
Ribbons2010 = [msrOutlookExplorer2010]
ControlTypes = {00000000}
Controls_ = <>
end>
end>
Ribbons = [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer]
Ribbons2010 = [msrOutlookExplorer2010]
end
procedure TAddInModule.RCMControls0Create(Sender: TObject);
var
pil1,pil2 : TadxRibbonMenu;
i : Integer;
newButton: TadxRibbonbutton;
sCaption :string;
begin
pil1 := RCM.Controls[0].AsRibbonMenu;
pil2 := pil1.Controls[0].AsRibbonMenu;
for i := 0 to pil2.Controls.Count -1 do
pil2.Controls.Delete(0);
for i := 0 to 10 do
begin
// Button
newButton := pil2.Controls.Add(rctButton).AsRibbonButton;
newButton.Caption := 'Caption'+ IntToStr(i); // This line generates exception "The parameter is incorrect"
newButton.ID := 'uniqueString'+ IntToStr(i);
newButton.OnClick := DoOnRRecentClick;
end;
end;
|
|
Posted 19 May, 2014 06:34:12
|
|
Top
|
|
Bart Van Bossche
Guest
|
Hi Francesco,
That's not what I suggested...
What I suggest is do the following:
for i := 0 to numberOfVisibleItems - 1 do
begin
pil2.Controls[i].Caption := 'Caption' + IntToStr(i);
pil2.Controls[i].ID := 'uniqueString' + IntToStr(i);
pil2.Controls[i].OnClick := DoOnRRecentClick;
pil2.Controls[i].Visible := True;
end;
for i := numberOfVisibleItems to pil2.Controls.Count - 1 do
pil2.Controls[i].Visible := False;
So just change the properties of existing buttons and hide the remaining ones, not deleting controls and adding new ones. :)
Sincerely,
Bart |
|
Posted 19 May, 2014 06:45:43
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Thank you Bart!
Francesco,
Could you please send me a sample project for testing to the support email address, see {Add-in Express installation folder}\readme.txt? Please make sure your email contains a link to this topic.
Andrei Smolin
Add-in Express Team Leader |
|
Posted 19 May, 2014 07:08:30
|
|
Top
|
|
Francesco Faleschini
Posts: 26
Joined: 2014-05-15
|
Sample sent to support address. Thanks |
|
Posted 19 May, 2014 07:56:18
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 18829
Joined: 2006-05-11
|
Francesco,
You've set Dynamic=true for a wrong Ribbon menu component. Since your task is to create controls for the menu RCM.Controls[0].Controls[0].AsRibbonMenu at run time, you need to set TadxRibbonMenu.Dynamic=false on the menu "Invia a" and TadxRibbonMenu.Dynamic=true on the menu "Recenti".
Andrei Smolin
Add-in Express Team Leader |
|
Posted 19 May, 2014 08:27:00
|
|
Top
|
|
Posts 1 - 10 of 12
First | Prev. | 1 2 | Next | Last
|