Converting An MFC Ribbon To Designer Format

Converting An MFC Ribbon To Designer Format

  • Comments 4

Pat Brenner

Hello, I’m Pat Brenner, a developer on the Visual C++ Libraries team, and I primarily work on MFC.

In Visual Studio 2010, a ribbon designer was added which allows you to visually edit the ribbon used in your MFC application. This doesn’t help you, however, if you adopted the ribbon user interface with Visual Studio 2008 SP1 and you’re creating your ribbon UI entirely with code in your application. We did consider that scenario, however, and added functionality to MFC to allow conversion of a “code” ribbon to an XML ribbon resource. I’ve been meaning to post an article on how to do this, so here it is.

I’ll use the conversion of the ribbon in the MSOffice2007Demo sample as an example:


  1. Download (if necessary) and open the MSOffice2007Demo sample solution. It can be found at this link ( ) under the “MFC Samples - Visual C++ 2008 Feature Pack” section. You may want to make a copy first if you want to keep the original sample around for reference.
  2. Build and run the solution. Check the contents of the different tabs of the ribbon. Exit the application.
  3. Open MainFrm.cpp and go to line 196 (where CreateStatusBar is called).
  4. Insert the following code at line 196 (immediately following the call to CreateRibbonBar):


  5. Right click on the file tab and select “Copy Full Path” to get the full path name for the file.

  6. Put the cursor between the double-quotes and insert the filename. Then modify the path to write the file to MSOffice2007Demo.mfcribbon-ms in the RES folder.

  7. Build and run the application again. As soon as the application starts up, you can exit the application. This will leave the XML file created on disk in the RES folder (with the mfcribbon-ms extension).
  8. Open the MSOffice2007Demo.mfcribbon-ms XML file and reformat it, using the “Format the whole document” button in the “XML Editor” group on the toolbar (or use the Ctrl+K, Ctrl+D keyboard shortcut to format the file).

  9. Edit the resource.h file using the text edit and add the ribbon resource ID:

    #define IDR_RIBBON 33000
  10. Edit the MSOffice2007Demo.rc file using the text editor and add the ribbon resource (since the ribbon is not a native resource type, 28 is used as the number for the ribbon resource type):

    IDR_RIBBON 28 DISCARDABLE "res\\MSOffice2007Demo.mfcribbon-ms"
  11. Remove the call to SaveToXMLFile from MainFrm.cpp (that you added earlier in steps 5 and 6).
  12. Remove lines 362-373 from MainFrm.cpp, the code to add ribbon tabs in code (except for the Developer tab).
  13. Add one line at line 362:


  14. Build and run the application again. Verify that all the ribbon UI looks the same as it did in step 2.
  15. You can now open the RC file using the Resource View and edit the ribbon resource using the ribbon designer.


I hope you find this information helpful.



Pat Brenner
Visual C++ Libraries Development

Leave a Comment
  • Please add 8 and 5 and type the answer here:
  • Post
  • Hello Pat,

    Thanks for  the info.   I want  to migrate  several projects

    from  Visual  C++  6.0  to  VS2010  that  link  to  the  MFC

    statically, and don't  use any of  the Feature Pack  classes

    and when are compiled in  VS2010 the size of the  executable

    increases significantly.  I also  have other  projects using

    the  BCGSoft  classes  and  they  overlap  with  the feature

    classes:  Currently, I  prefer to  use the  BCGSoft classes

    because it is  possible to enable  the Visual Themes  in the

    FormView classes  something that  is not  implemented yet in

    the Feature Pack classes.

    It would be useful then, if we have an option to exclude all

    of the Feature Classes  from the executable when  statically

    linking applications that don’t use the Feature Pack or when

    using the BCGSoft framework.

  • That is nice. Thanks for sharing.

  • @Marcello:  We are working on the static link size issue and are confident that we will have a fix for the next major version that addresses the size increase of applications that are not using Feature Pack controls.

  • OK. Thank you. I think the Feature Pack is a valuable addition but we should be able to build small executables as in the earlier releases of Visual Studio.

Page 1 of 1 (4 items)