Search code examples
winapiribbon

Is it possible to use IUIFramework::LoadUI to load a compiled markup file?


The documentation for this function reads:

Loads the Windows Ribbon framework UI resource, or compiled markup, file.

I have the compiled .bml file (via uicc.exe). However, I don't know what parameters to pass for instance and resourceName when calling LoadUI.


Solution

  • As documented, the IUIFramework::LoadUI call can in fact load a compiled, binary markup file. This file must be linked as a user-defined resource into the binary image, identified through the instance argument. resourceName is the name of this resource. By default, UUIC.exe assigns the name "APPLICATION_RIBBON".

    Assuming a standard UUIC.exe invocation

    UICC.exe RibbonMarkup.xml RibbonMarkup.bml /header:RibbonIds.h /res:RibbonUI.rc

    This produces a resource script file RibbonUI.rc with the following line

    APPLICATION_RIBBON UIFILE "RibbonMarkup.bml"

    This is the resource script file that adds the compiled, binary markup file into the executable image. "APPLICATION_RIBBON" is the name of the resource, and you can change it to anything you see fit (as long as it doesn't collide with other user-defined resources of type UIFILE).

    A complete guide can be found at Creating a Ribbon Application.