Hi I’m Pat Brenner, a developer on the Visual C++ libraries team. I’m pleased to give you a sneak peek at a major MFC update we’ve been working on. Since we’re adding a number of cool new user interface components to MFC, this blog post is going to be graphics heavy. I’d much rather show you some of these components than just describe them! I hope you enjoy this quick tour through the new portions of the library.
Modern user interface elements
This update to the MFC library will enable developers to build modern user interfaces with support for the Office 2007 Ribbon Bar, Office-style menus, Visual Studio-style docking toolbars, tabbed documents and much more. All of the components included in the update will run on Windows 2000 and above.
Let’s take a look at some of the Office 2007 Ribbon Bar support. Below is an image of an MFC application built with the Office look and feel:
The ribbon support includes support for the application button (the large round button at the top left), the quick access toolbar (the small set of tools just to the right of the application button) and the standard ribbon components. Each tab on the ribbon (e.g., the “Home” tab above) allows access to a category of tools. Each category is divided up into a set of panels (e.g., “Clipboard” and “Font” above) and each panel contains a set of ribbon elements. These ribbon elements can have a wide variety of styles—I’ll go into more detail about these later.
Perhaps many of you would like to build applications that utilize some of the functionality we’ve had in Visual Studio. For example, one of the most requested features is support for the smart docking we added in Visual Studio 2005. With this new release, all the cool user interface features you’ve seen in the past versions of Visual Studio are at your disposal.
Let’s take a look at some of the Visual Studio support. Below is an image of an MFC application built with the Visual Studio look and feel:
MFC now implements its own menu bar and toolbar, which is fully customizable like the Visual Studio toolbar and menu bar. This means that buttons can be moved between toolbars, and even from the toolbar to the menu bar and vice versa. Custom toolbars can be created, and commands can be added to them. And the images for the individual toolbar buttons can even be changed, and custom images can be created and used. Support for docking panes is also included—these panes can be grouped into one docking frame as above, they can be floating as well as docked, and they support auto-hide mode like in Visual Studio, so a docked pane will slide out from the edge of the frame when its tab is hovered over, mimicking the Visual Studio behavior. There is also support for tabbed MDI documents (which can be grouped) like in Visual Studio.
In addition to all the features supporting Office, Internet Explorer and Visual Studio “look and feel” there are a number of built-in cool elements you can use in the ribbon in your application. In the images below, we provide a quick visual introduction to what’s included in the library. The images come from the RibbonGadgets example that ships with the library.
In the image below you can see large and small buttons, as well as check boxes. The buttons can be simple (so they just respond to a click), or they can drop down a menu or be a split button which responds to the click or drops a menu depending on the click location.
In the image below you can see what we call palette buttons. These can be a set of buttons that have associated images, so the user can see what he will get when he clicks on a button in the palette. These palettes can be embedded in the ribbon, or they can be dropped down from a button in a window which can be resized dynamically by the user.
In the image below you can see a variety of color choosers. These can be embedded in the ribbon, or they can be attached to a button. The table of colors associated with the chooser can be customized in your application. There is a color picker dialog which offers even more flexibility, including the ability to choose the color of any pixel on the screen and use that color.
In the image below you can see groups of commands. A ribbon group can be built from an existing toolbar, so if your application has a large number of toolbars, you can place them on the ribbon with ease.
In the image below you can see support for edit boxes, combo boxes and spin controls, as well as the font picker control, which can display the font names in the font (as in Word) so you get an instant preview of the font appearance.
Below you can see a few more ribbon elements. Several of these, including the progress indicators and the links and sliders, actually make more sense on the ribbon status bar, which you can see in the first image at the top of this article.
Powerful application wizard
We’ve also beefed up the MFC Application Wizard (see the images below) quite a bit to enable easy use of these new features in MFC. We’ve added a couple of options to the “Project Style” category which will allow you to build a project that looks something like Visual Studio or an Office application by default. We’ve added the option to use tabbed MDI document windows rather than the old MDI style. And we’ve added the ability to choose the look and feel of your application with the “Visual Style and Colors” combo box.
An option that is hidden in this image is a checkbox that allows your application look and color to be changed at runtime. You can choose your application look and color at design time, but if the user wants to change it, he can do so easily. This is possible because the drawing of all the user interface elements is done via what is called a “visual manager”. The visual manager takes care of all the drawing of elements, so if a different look is desired, all that is required is to switch to a different visual manager, and redraw the window, and your application instantly has a completely new look. As you can see in the image below, a number of schemes are supported, including Office 2003, Visual Studio 2005, and several different Office 2007 schemes which use different colors. All of these are implemented using visual managers.
An option that is disabled in the image below (because ribbon was chosen instead of menu bar) is a checkbox that enabled “personalized menu behavior”. This means that the menus will not show all commands by default, just like in Office applications. When a menu is hovered over briefly, the menu will expand to contain its full set of commands. And as the application is used, the most-used commands are added to the menu by default, so over time, the menu will become personalized to how it is being used.
Below is a screenshot of a running application which uses a ribbon. This is actually the application created by the Application Wizard when the “Office” project style is chosen. There is an Outlook-style navigation bar docked on the left side of the frame, and a caption (or message) bar at the top of the client area. Note that the application button, quick access toolbar buttons, and the ribbon elements have keyboard hotkeys which are available when the Alt key is pressed. On the right hand side of the ribbon is a drop-down element named “Style”, and from it you can choose which color you’d like the application to be presented in.
Easy to update existing MFC code
One of the great things about the new components is that they’re easy to incorporate into existing applications. All of the new behavior is encapsulated in new classes, and none of the existing classes have been modified. If you want to update your existing MFC application to use the new menu bar and toolbar support, all that is required to update your application to the new look is to change the base classes of your application and frame windows, and add a few lines of code, and you’ve just updated your application to have a more modern interface.
Below is an image of the new DrawClient sample. This is a remodel of the DrawCli sample that ships with MFC—it’s been updated to include Ribbon support. Most of the modifications to the source code were in mainfrm.h and mainfrm.cpp. The ribbon is currently built entirely in code. The ribbon is created and then the various ribbon elements (application button, quick access toolbar, categories, etc.) are added via calls to ribbon member functions. However, the underlying command architecture did not have to change—all the ribbon controls can be associated with a command identifier, and when the command is fired, it is handled via the existing command handlers. The object drawing code did not have to change in any substantial way—it was only augmented to allow a few new capabilities. One of these capabilities is something I’ll call “command preview”. This means that, just like in the new Office applications, you can see the effect of a command before actually choosing it. For example, the purple rounded rectangle is active below. As you float the mouse over the large color buttons in the ribbon, the rectangle will temporarily change color to match the color of the button the mouse is hovered over. When you click on the button, the color of the rectangle will then be changed.
We’re pretty excited about all these new additions to MFC, and we hope you are too! Feel free to ask any questions you have about the new features and I’ll do my best to answer.
Visual C++ Libraries Development
Sven: The current plan is for all of the new functionality to be completely integrated into MFC (and, consequently, MFCxx.dll).
Chabster: Yes, we will have MSDN docs for everything we ship.
Somebody: It's great to see you're checking out BCGSoft's stuff, but please do keep in mind that there is more work we're doing here as a part of the MFC integration. We we look forward to your feedback once we actually release a beta version of the software. :)
Stevetei: Thanks for the response. I will definitely check out the beta. Still, I think the consensus that I've seen here and on other places discussing the new functionality is that regardless of the quality people would like to be able to "turn it off" much the way we don't need to ship ATL, STL, or even MFC if we don't want to. Would be nice if the BCG stuff was "integrated", but still modularized at the same time. Putting everything in the MFCxx.DLL will turn a thin 1.5MB DLL into a 20MB DLL.
"The current plan is for all of the new functionality to be completely integrated into MFC (and, consequently, MFCxx.dll)"
That sucks big time! Like me there are many others who don't want all that stuff and there is no justification why you bloat our apps.
I also don't understand why there is so much positive feedback (or is the negative just filtered?). Here is an analogy:
When a car maker releases a new model there will be all kind of aftermarket parts for it, from spoilers to seats. What Microsoft did is they took an aftermarket spoiler (the cheapest one they found), put it on the old MFC and try to sell it as a new version. So what's so cool about that? Just buy the spoiler (BCGControlBar) and put it on your old car (VS2005).
But maybe Microsoft follows a different strategy. With the integration of the BCGControlBar MFC apps will be bloated, sluggish and require a lot more memory than before, so nobody can say that for .NET apps in comparison any longer.
Somebody is right. The size of the BCG dll is round about 3.5 MiB, the Office 2007 images (blue, silver, black) need additional 5.0 MiB. I doesn't need this stuff, because I'm using Codejock's Xtreme Toolkit and I don't want to ship a 10 MiB MFCxx.dll instead of a 1.5 MiB dll.
Can I use this lib in a plain win32 app?
Hello! I work with the CodeJock Xtreme Toolkit Pro for a long time now. They implemented graphics and speed much better than BCG! Codejock matches MS graphics for 100 %. You should think once again about that!
Greetings, Moritz Leutenecker
I third Somebody's request that this be put in it's own DLL.
(The SxS stuff totally and completely sucks as it is; adding this to the mix makes it even worse. After we shoot all the lawyers, I want to line up the idiots who came up with SxS.)
To those asking why the VC++ team didn't use Office's implementation of the Office 2k7 UI, I think Herb Sutter's blog tells it best:
To summarize: Over the years, the Office team comes up with its own UI, then the Tools team and/or Windows team add it to the tools and/or OS. The Tools and Window teams never use the Office team's implementation, because the Office team's implementation is for internal use by the Office team, and not meant or designed to be used as a library by 3rd parties. The Office code isn't suitable for 3rd party use because it wasn't designed with that in mind. This isn't the first time that the tools team has used 3rd party libs in its own offerings, and it makes sense because those 3rd party libs are built explicitly for 3rd party use (unlike the Office code).
Microsoft has been it this way for years.
But see Herb Sutter's blog, he says it better than I. :)
Auf der TechEd wurde die Katze aus dem Sack gelassen. Ale Contenti stellte die neuen Features der MFC
Will the appropriate image files be made available for redistribution? For that matter, has the image library been updated for VS2008? The update for VS2005 was a huge step forward, but there seemed to be a large number missing (no I don't have a list) images, plus everything that is new for Vista.
This is excellent news! I for one am pleased to see MS' commitment to the C++ platform as we'll be using it for quite some time. GUI additions like this are needed. I can't wait to try them out!
Pat, can you tell us if we'll gain the ability to hide a window's menu bar and have it appear when the user presses Alt (ala IE and Media Center)?
What are the patent/licensing implications of using the new MFC Ribbon components in my software? My understanding is that Microsoft has imposed significant restrictions on that visual style:
"The license [For the office-style UI] is available for applications on any platform, except for applications that compete directly with the five Office applications that currently have the new UI (Microsoft Word, Excel, PowerPoint, Outlook and Access"
If I build a commercial application using the Ribbon components of MFC, does it still need to be vetted out by the Office-UI licensing group?
With regard to the licensing question, we are currently in process of finalizing such details. Most probably, the licesnse will adhere to the Office license you mentioned above.
Lead Program Manager
Visual C++ Team
Hi all! Whew! Thanks all for the feedback and questions. I'll try to answer some of them here:
Tony, re: "Are these examples in the SDK, or should I just figure them out all myself. Surely the application wizard doesn't just create me a VS look and feel app out of the box.?!"
Yes, these samples are all included in the MFC samples we are shipping with this feature pack. And yes, the application can (but does not have to) create you a VS look and feel app right out of the box.
Iain, re: "Is this the actual ribbon code from Office (MSO) refactored, or is it a separate ground-up implementation? Will full source code be available for the new MFC, just as its has been for all prior releases of MFC?"
This is not the Office ribbon refactored, it is a separate implementation. But it has been approved by the Office team with respect to their ribbon guidelines. And full source code will be shipped as aw
Pavel, re: "Is this MFC-Update only for VS2008? Are there any plans for VS2005 integration? What about PropertyGrid and ReportControl? Are they also a part of new MFC? What about deployment issue? Is it still one DLL (mfc90.dll)?
Yes, this update is only for VS2008. There are no plans for VS2005 integration. Property Grid is included. And it is still one DLL.
Somebody, re: "Putting everything in the MFCxx.DLL will turn a thin 1.5MB DLL into a 20MB DLL."
We have integrated everything into MFCxx.DLL, to simplify deployment. But the DLL did not grow to 20MB. It grew from 1.2MB to 3.8MB.
Chris, re: "Will the appropriate image files be made available for redistribution?"
There are load of image files included with the samples code. All the screen shots in the original blog post are samples or app-wizard generate code, so you'll have access to all those images.
JSchroedl, re: "can you tell us if we'll gain the ability to hide a window's menu bar and have it appear when the user presses Alt?"
I don't believe this will be supported in the feature pack, but it's an excellent suggestion for a future feature request. Thanks!
Thanks for filtering the negative comments!
But that doesn't make your decisions any better.