Adding/removing backstage menu buttons at runtime?

Add-in Express™ Support Service
That's what is more important than anything else

Adding/removing backstage menu buttons at runtime?
Possible at all? 
Oliver Giesen




Posts: 75
Joined: 2006-08-07
I'd like to dynamically set up menu items for a backstage primary menu button (my addin has optional modules (implemented in external COM-DLLs) whose functionality I'd like to expose on the backstage view as it is needed/available). So far, I've had no luck: While clearing/deleting items at runtime appears to kind of work in that items do in fact disappear, any menu buttons I add in code from inside the TadxBackstageView.OnShow event handler never show up.

I've already found a few similar issues discussed here on the forums and the general message seemed to be that dynamically creating ribbon controls is no longer possible after the addin module's DFM has been loaded (except for ADXRibbonMenu with Dynamic=True). Then again, there was one thread about dynamically adding items to a backstage combobox where Andrei's initial reaction was again "cannot be done" but then he followed up with some code that apparently did work. Is it possible that something similar can be done for backstage menu buttons, too? I tried adapting the code quoted there for my use case but so far I haven't been able to make it work.

The only workaround I could currently think of (which I have already tested successfully) is to create a bunch of dummy buttons at designtime (or rather in an override of the addin module's Loaded method) and then only set their captions, visibility states and click handlers at runtime, hiding the unused ones. This is obviously not a very clean solution and I'd prefer it if there was a different way that would not involve either creating unneeded items or running the risk of having too few dummy items.

Any ideas?

Cheers,

Oliver
Posted 29 Jul, 2016 03:57:11 Top
Andrei Smolin


Add-in Express team


Posts: 14106
Joined: 2006-05-11
Hello Oliver,

The topic you've mentioned relates to adding *items* to a control. As to adding a *control* to the Backstage view, this is impossible.

Oliver Giesen writes:
The only workaround I could currently think of (which I have already tested successfully) is to create a bunch of dummy buttons at designtime and then only set their captions, visibility states and click handlers at runtime, hiding the unused ones


This is an only workaround available.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 29 Jul, 2016 05:10:25 Top