Main Page | See live article | Alphabetical index

Microsoft Foundation Classes

Microsoft Foundation Classes, usually referred to by its acronym MFC, is Microsoft's C++ class library that serves as a wrapper for the Windows API. A class is defined for each Windows object that is managed through a handle, and also for predefined windows and common controls.

MFC was introduced in 1992(??) for use with 16-bit versions of Windows. It was part of an overall Microsoft effort to gain market share for development tools, and was designed to be something of a showcase of the capabilities of the C++ programming language. C++ was just beginning to replace C for development of commercial application software. At the time of MFC's release, Microsoft had recently added C++ support to its commercial C compilers.

The Object Windows Library (OWL) was a competing product introduced by Borland around the same time, and was designed for Borland's Turbo C compiler. Since it had a superior OO design, OWL was more popular than MFC for a time. However, it lost market share when OWL updates lagged the addition of new features to Windows. It has since been discontinued.

When MFC was introduced, Microsoft extended the C++ syntax with a series of macros for management of windows messages, exceptions, and dynamic class instantiation. The syntactic changes for windows messages were intended to reduce memory required, and mimiced the virtual function mechanism provided by C++. Because the macros defeat the type checking done by the compiler, their use has been a fruitiful source of bugs for users of MFC. The serialization and exception support and dynamic runtime types were less problematic, and predated availability of standards-based language extensions by a number of years. 32-bit versions of MFC, for Windows 95 and later Windows operating systems, retain these pecularities.

As a practical matter, the chief advantage of MFC is the automatic closure of handles when the objects creating them go out of scope.

Once highly promoted by Microsoft, emphasis on MFC has been eclipsed by a number of other technologies. Microsoft placed more emphasis on Visual Basic as a commercial software development tool as it became clear that C++ and MFC were too complex for many programmers. After a brief flirtation with Sun Microsystems' Java, Microsoft deployed its own programming language, called C# (C sharp). Advertised as a RAD language, C# is part of Microsoft's .NET initiative.

MFC continues to be used for new development by shops that have made a strategic commitment to C++ and the Windows platform.

External Link