CRibbonFrame

Win32++

CRibbonFrame Class

Description

CRibbonFrame provides a Frame window with a Ribbon in place of the traditional MenuBar and ToolBar. Only Windows 7 (and above) supports the ribbon framework.  By default, a ToolBar and MenuBar is displayed instead of the ribbon if the ribbon framework is not supported by the Operating System. 

CRibbonFrame Members

CRibbonFrame
CRibbonFrame();
Constructs a CRibbonFrame object.
GetViewRect
virtual CRect GetViewRect() const;
Returns a CRect containing the dimensions of the view window. OnCreate
virtual void OnCreate();
Called when the frame window is created. OnDestroy
virtual void OnDestroy();
Called when the frame window is destroyed. OnViewChanged
virtual STDMETHODIMP OnViewChanged(UINT32 viewId, UI_VIEWTYPE typeId, 
                      IUnknown* pView, UI_VIEWVERB verb, INT32 uReasonCode);
Called when the state of the view changes. PopulateRibbonRecentItems
virtual HRESULT PopulateRibbonRecentItems(__deref_out PROPVARIANT* pvarValue);
Populates the list of Most Recently Used files. UpdateMRUMenu
virtual void UpdateMRUMenu();
Updates the frame with the MRU list.
Base class Members

For base class members, refer to the members of CFrame and CRibbon.

Remarks

Microsoft's RibbonUI framework uses COM to implement the ribbon. The COM interfaces involved are IUIApplication and IUICommandHandler. The Win32++ CRibbon class inherits from both IUIApplication and IUICommandHandler. CRibbonFrame inherits from both CFrame and and CRibbon.

To add a ribbon to your frame, inherit CMainFrame from CRibbonFrame, and add the Ribbon.xml file containing the definitions for your ribbon to the project.  The Ribbon.xml is compiled to produce the RibbonUI.h and Ribbon.rc before the files C++ files are compiled. To compile Ribbon.xml, specify it's custom build properties in the IDE as follows:

  • Command Line:-  uicc.exe ..\src\Ribbon.xml ..\src\Ribbon.bml /header:..\src\RibbonUI.h /res:..\src\RibbonUI.rc
  • Outputs:-  Ribbon.bml;RibbonUI.rc;RibbonUI.h

To create and interact with the ribbon, we override the relevant functions from both IUIApplication and IUICommandHandler. The functions you may wish to override are:

  • IUIApplication::OnCreateUICommand - Called for each Command specified in the Ribbon markup to bind the Command to an IUICommandHandler.
  • IUIApplication::OnDestroyUICommand - Called for each Command specified in the Ribbon markup when the Ribbon host application window is destroyed.
  • IUIApplication::OnViewChanged - Called when the state of a View changes.
  • IUICommandHandler::Execute - Executes or previews the Commands bound to the Command handler.
  • IUICommandHandler::UpdateProperty - Sets a property value for a bound Command, for example, setting a Command to enabled or disabled depending on the state of a View.

Refer to the RibbonFrame sample for a demonstration of how to create an application with a ribbon frame.

Summary Information

Header file ribbon.h
Win32/64 support Yes
WinCE support No
Library required Comctl32.lib,  Shlwapi.lib