New MFC Library

Many C++ developers have expressed a desire to incorporate the look and feel of current Windows applications -- such as Microsoft Office 2007 -- into their user interface. In addition to making native Windows applications look more "modern," the benefits of updating native Windows apps may lead to reduced training costs and enhanced usability.

Unfortunately, for Visual C++ developers there's been little tool support for building this type of user interface. Until recently, intrepid C++ coders were required to craft all the required visual components -- and their associated behavior -- by hand. However, with the recent update to the Microsoft Foundation Class (MFC) library, modern UI components and controls are now part of the framework.

Native LibrariesFor those not familiar with MFC, a brief introduction is in order. MFC is an application framework that lets developers easily build upon the work of expert Windows programmers. Written in C++, MFC provides much of the code necessary for windows and resource management. MFC also includes built-in support for a wide variety of UI controls and gadgets. All the developer needs to do is add app-specific code into this framework.

The MFC library is part of Visual C++, Microsoft's integrated dev environment for C, C++ and .NET programming languages. The latest version, Visual C++ 2008 supports .NET 3.5 and was released last November with Visual Studio 2008. Visual C++ is also available for free as a standalone Express Edition.

Given the nature of C++ class programming, it's easy to extend or override the basic functionality that the MFC framework supplies. The flexibility of the framework, superior runtime performance and the ability to shorten dev time are among the key reasons why many of the world's largest software vendors use MFC to build their apps.

Microsoft Foundation Class Active container support integrates the Office 2007 drawing features for the Ribbon Bar.

Updated C++ Toolset With the launch of the .NET Framework in 2002, Microsoft's dev efforts were largely focused on the new Windows platform. The past several releases of the Visual C++ IDE haven't offered major updates to the MFC library. That changed with the updated native libraries made available in the Visual C++ 2008 Feature Pack.

A plug-in to Visual C++ 2008, the Feature Pack was made available for download in April. It offers a large set of new UI components for MFC such as the Office Fluent UI (also known as the Ribbon Bar).

The new "Fluent UI" functionality enables developers to build rich client apps that look just like Office 2007. These apps can display custom Ribbon panels, key tips, mini-toolbars, the Quick Access Toolbar and the Status Bar, among other features. Existing MFC apps can easily be updated to use these new components. If running on Windows Vista, the app will automatically integrate with Aero.

The updated library also contains a visualization manager that draws controls to appear in the style of different versions of Microsoft Office. Support is provided for Office 2000, XP, 2003 and 2007. The visualization can be changed at runtime.

Similarly, the visualization manager can draw controls to appear in the style of several releases of Visual Studio. Support is provided for Visual Studio 6.0, Visual Studio.NET and Visual Studio 2005. And like the Office visualizations, these can also be changed at runtime.

New Office-style menu bars enable developers to dock and customize with images. Support is provided for menu shadows and tool tips, scrollable menus, tear-off menus and menu animations in which an image fades in, unfolds or slides into view.

Windowing features include MDI tabbed groups, detachable tabs and auto-hide windows. There's also support for Visual Studio-style window docking. For example, as a window is being dragged, arrow markers automatically indicate positions where the window can dock.

A new Desktop Alert control displays a pop-up window containing a custom notification message. An example of a desktop alert is the small window that signifies that a mail message has arrived in the Outlook inbox.

Customization Features The updated MFC lets developers customize controls with color, images and text. Customization supports the ability to drag buttons between toolbars and menus, create user-defined toolbars at runtime, customize context menus and customize the look of a toolbar at runtime.

While the updated MFC library is a big step forward for native C++ developers, it's just the beginning. Many customers still require native code, so the Visual C++ team is focusing squarely on the needs of those developers. Future versions of Visual

C++ will significantly improve the productivity of native development when working on massive code bases. Further, Microsoft is looking to improve interop support so that customers can easily "mix and match" technologies from both the native and managed worlds.

About the Author

Bill Dunlap is the program manager of the Visual C++ team at Microsoft.