Modifying a ribbon control at runtime

1.8k views Asked by At

I'm using the Windows Ribbon Framework in an unmanaged C++ application in Visual Studio. Is it possible to add a button or other control at runtime? I can set up my ribbon using IUIFramework::LoadUI, but I can't modify it afterwards.

2

There are 2 answers

0
Alain Rist On

It is not possible to add or remove a button at runtime, but you may hide or show a Tab or Group at run time using Application Modes and you can set any button texts and images at runtime.

So you can declare and use multi-purpose buttons that will show only when a specific Application Mode is set and contain runtime defined texts and images.

2
Steve Townsend On

You can switch modes at runtime depending on what is defined in the markup - see here for details:

After modes are defined in markup, they can be easily enabled or disabled in response to contextual events. As mentioned previously, Ribbon applications always start in the default mode 0. After the application has initialized and mode 0 is active, the set of active modes can be changed by calling the IUIFramework::SetModes function.

There is a comment here to the effect that changes at runtime are quite limited - this is in regard to a third-party wrapper, note.

You can dynamically add items at runtime only to the galleries controls:

ComboBox, SplitButtonGallerty, DropDownGallery and InRibbonGallery

If you know what you want to add from advance you can use ContextualTabs and ApplicationModes to change the visibility of (predefined) tabs and groups.

Unfortunately, you can add dynamically groups at runtime.

Note this is a limitation in the Windows Ribbon Framework and not in the wrapper library.