The Transformed XML Explorer in MFC
(Page 1 of 4 )
A visual upgrade is often welcome. Aside from the aesthetics, it also helps to introduce new features and new ways to complete tasks. Microsoft made such a move with the launch of its Office Suite 12. In this, they launched the ribbon. If you're interested in making your application compatible with the ribbon, keep reading.
The ribbon is the result of a massive amount of customer research that Microsoft conducted. Over the past few years, the ribbon has managed to redefine how we interpret Office applications -- and to be honest, most of us have become addicted to its context-sensitive toolbar system.
This article is the second part of a two-part series in which I am looking into how to upgrade/extend your old-school application. The title of the first part is New Features for the Statusbar in MFC and you can find it here on the ASP Free section of the Developer Shed network. In the first part, I showed how to apply the Office style to your application. In this second part, I will show how to add the new tab-based multi-window system and how to add a ribbon to your application.
I will stick with the XML Explorer source code and continue its improvement and extension. Adding the tab support is one of the simplest tasks. First, you need to make sure that in the Application class on the initialization of the instance, the InitContextMenuManager () method is called. This will create the object that will handle future tasks; I have already done this in the first task.
Now we just need to tell the application to use the style. The CMDTabInfo is a class through which you can customize how to perform these tasks. Pass it after you build it as an argument as shown below:
CMDITabInfo tabInfo; // Declare the object
//customize it
tabInfo.m_bAutoColor = true;
tabInfo.m_bDocumentMenu = true;
//pass it for the Manager
EnableMDITabbedGroups (true, tabInfo);
Now, once you run the application, you can observe it in action:

The table below will explain the other configuration options of the tab system:
CMDITabInfo Member | Value options and effects |
m_style | STYLE_3D -3D style. STYLE_3D_ONENOTE - Microsoft OneNote style. STYLE_3D_VS2005 - Microsoft Visual Studio 2005 style. STYLE_3D_SCROLLED - 3D style with rectangle tab labels. STYLE_FLAT_SHARED_HORZ_SCROLL - Flat style with shared horizontal scroll bar. STYLE_3D_ROUNDED_SCROLL - 3D style with round tab labels. |
m_bActiveTabCloseButton | FALSE => Place close button at right of the tab area. |
m_bTabIcons | TRUE => enable document icons on MDI tabs. |
m_bAutoColor | Enable or disable the auto color. |
m_bDocumentMenu | TRUE => Enable document menu at the right edge of the tab area. |
m_bEnableTabSwap | User can change (or not change) the positions of the tabs by dragging them. |
m_bFlatFrame | TRUE => give each tab window a flat frame. |
m_bTabCloseButton | TRUE => each tab displays a close button on the right edge of the tab. |
m_bTabCustomTooltips | TRUE => tabs display tooltips. |
m_tabLocation | LOCATION_BOTTOM: the tabs; labels are located at the bottom of the page. LOCATION_TOP: the tabs' labels are located at the top of the page. |
m_nTabBorderSize | Specifies the border size, in pixels, of each tab window. |
Next: The Ribbon >>
More .NET Articles
More By Gabor Bernat