Puneet Varma (Editor)

Microsoft Foundation Class Library

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Developer(s)
  
Microsoft

Written in
  
C++

License
  
Proprietary

Initial release
  
1992

Operating system
  
Microsoft Windows

Stable release
  
14.0.24212.0 / 2 August 2016

Microsoft Foundation Class Library (MFC) is a C++ object-oriented library for developing desktop applications for Windows.

Contents

MFC was introduced by Microsoft in 1992 and quickly gained widespread use. While Microsoft has introduced alternative application frameworks since then, MFC remains widely used.

History

MFC was introduced in 1992 with Microsoft's C/C++ 7.0 compiler for use with 16-bit versions of Windows as an extremely thin object-oriented C++ wrapper for the Windows API. C++ was just beginning to replace C for development of commercial application software at the time. In an MFC program, direct Windows API calls are rarely needed. Instead, programs create objects from Microsoft Foundation Class classes and call member functions belonging to those objects. Many of those functions share their names with corresponding API functions.

One quirk of MFC is the use of "Afx" as the prefix for many functions, macros and the standard precompiled header name "stdafx.h". During early development, what became MFC was called "Application Framework Extensions" and abbreviated "Afx". The name Microsoft Foundation Classes (MFC) was adopted too late in the release cycle to change these references.

MFC 8.0 was released with Visual Studio 2005. MFC 9.0 was released with Visual Studio 2008. MFC is not included in the freeware Visual C++ Express but is included in the commercial versions of Visual C++ 2010 and later, and in Visual Studio Community.

Object Windows Library (OWL), designed for use with Borland's Turbo C++ compiler, was a competing product introduced by Borland around the same time. Eventually, Borland discontinued OWL development and licensed the distribution of the MFC headers, libraries and DLLs from Microsoft for a short time, though it never offered fully integrated support for MFC. Borland later released Visual Component Library to replace the OWL framework.

Microsoft's emphasis on MFC has been reduced in favor of its .NET Framework. MFC 7, 8 and 9 bridge elements of MFC with .NET Framework to aid developers in migrating to the new framework. The MSVC++ compiler backend can emit managed and native object files. The linker can then build them together, generating mixed (both managed and native) applications, allowing existing native applications to use managed extensions in a seamless manner. Though Microsoft has de-emphasized MFC, it remains a widely used framework.

A lightweight alternative to MFC is the Windows Template Library (WTL). C++ Express version compiles WTL applications (if Active Template Library is installed), but does not include the IDE support of the Standard, Professional and Team editions.

Features

MFC is a library that wraps portions of the Windows API in C++ classes, including functionality that enables them to use a default application framework. Classes are defined for many of the handle-managed Windows objects and also for predefined windows and common controls.

At the time of its introduction, MFC provided C++ macros for Windows message-handling (via Message Maps ), exceptions, run-time type identification (RTTI), serialization and dynamic class instantiation. The macros for message-handling aimed to reduce memory consumption by avoiding gratuitous virtual table use and also to provide a more concrete structure for various Visual C++-supplied tools to edit and manipulate code without parsing the full language. The message-handling macros replaced the virtual function mechanism provided by C++.

The macros for serialization, exceptions, and RTTI predated availability of these features in Microsoft C++ by a number of years. 32-bit versions of MFC, for Windows NT 3.1 and later Windows operating systems, used compilers that implemented the language features and updated the macros to simply wrap the language features instead of providing customized implementations, realizing upward compatibility.

Visual C++ 2008 Feature Pack

On 7 April 2008, Microsoft released an update to the MFC classes as an out-of-band update to Visual Studio 2008 and MFC 9. The update features new user interface constructs, including the ribbons and associated UI widgets, fully customizable toolbars, docking panes which can either be freely floated or docked to any side and document tabs. The MFC ribbon resource editor allows the developer to design the ribbon graphically instead of having to use the XML-based declarative markup like the RibbonX API. Optionally, ribbon components may be programmed directly by calling a new set of ribbon class methods. The developer may mix graphical and programmatic ribbon development as is convenient. The MFC application wizard has also been upgraded to support the new features, including a check-box to select whether the application will use the ribbon or the docking panes. The new functionality is provided in new classes so that old applications still continue to run. This update is building on top of BCGSoft’s BCGControlBar Library Professional Edition.

MFC can be used by linking a static library or by adding the MFC DLL.

Microsoft has imposed additional licensing requirements on users of the ribbons. These include a requirement to adhere to Microsoft UI Design Guidelines, and a anti-competition clause prohibiting the use of the UI in applications which compete with Microsoft Office.

References

Microsoft Foundation Class Library Wikipedia