Microsoft Foundation Class Library

From Wikipedia, the free encyclopedia

In computer programming, Microsoft Foundation Class Library (also Microsoft Foundation Classes or MFC, originally Application Framework eXtensions or AFX) is a Microsoft library that wraps portions of the Windows API in C++ classes, forming an application framework. Classes are defined for many of the handle-managed Windows objects and also for predefined windows and common controls.

Contents

[edit] History

MFC was introduced in 1992 with Microsoft's C/C++ 7.0 compiler for use with 16-bit versions of Windows. It was part of an overall Microsoft effort to gain market share for development tools, and it was designed to showcase the capabilities of the C++ programming language. C++ was just beginning to replace C for development of commercial application software and C/C++ 7.0 was the first of Microsoft's compilers to add C++ support. MFC was inspired by, and owes much of its structure to, the Think Class Library (TCL) on Macintosh, later bought by Symantec.

The Object Windows Library (OWL), designed for use with Borland's Turbo C compiler, was a competing product introduced by Borland around the same time. Since it more strictly followed some OO design guidelines, 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. Borland then chose to release a new version of their OWL framework which was incompatible with earlier editions. A decision by Borland was made to discontinue OWL development and Borland began licensing MFC from Microsoft.

[edit] Features

When MFC was introduced, Microsoft extended the C++ syntax with a series of macros for management of windows messages, exceptions, run time type identification, and dynamic class instantiation (many of these features – exceptions or run time type identification, for example – were not built into Microsoft's compiler at the time, but would appear in future versions). The syntactic changes for windows' messages were intended to reduce memory required by avoiding gratuitous vtable use and 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++. Because some versions of the macros defeated the type checking done by the compiler, their use has been a fruitful source of bugs for users of MFC. The macros which implemented serialization, 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 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.

Practically, the chief advantage of MFC is that it provides an object-oriented programming model to the Windows APIs. Another advantage of MFC is C++ wrapper types for many common Windows resource-related data types that provide automatic closure of handles when the objects creating them go out of scope. Additionally, MFC provides a Document/View framework for creating Model-View-Controller-based architectures.

One main disadvantage of MFC is that it is not portable across many operating systems. Mainsoft has made MFC tools available for Unix [1], and Microsoft shipped MFC versions for the Apple Macintosh operating systems in the 1990s. Visual Studio support for the Macintosh has since been discontinued.

[edit] The future of MFC

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 some programmers. Windows Forms is the .NET RAD successor to Visual Basic and MFC. Native C++ programs can use Windows Forms by adding C++ Managed Extensions.

With the release of Visual Studio.NET 2005, the Visual C++ language was given new and simpler syntax for defining and using types in the .NET framework, such as Classes, Interfaces, Properties, Enumerations, and Delegates, making it simpler to write C++ programs that target the CLR (Common Language Runtime).

Despite promoting Visual Basic, Microsoft still officially supports MFC by developing new versions with each new version of Microsoft Visual Studio. Shops and computer programmers that have made a strategic commitment to C++ and the Windows platform continue to use MFC for new development.

[edit] Books about MFC

The most popular book about the MFC is Programming Windows with MFC by Jeff Prosise, published by Microsoft Press. Programmers often compare the book and its content with the 'WinAPI bible' by Charles Petzold, the famous Programming Windows book. Prosise's 'MFC bible' has been translated into many other languages and it's still the reference book for MFC programming.

[edit] Versions

Product version MFC version
Microsoft C/C++ 7.0 MFC 1.0
Visual C++ 1.0 MFC 2.0
Visual C++ 1.5 MFC 2.5
Visual C++ 2.0 MFC 3.0
Visual C++ 2.1 MFC 3.1
Visual C++ 2.2 MFC 3.2
Visual C++ 4.0 MFC 4.0
Visual C++ 4.1 MFC 4.1
Visual C++ 4.2 MFC 4.2
Visual C++ 5.0 MFC 4.21 (mfc42.dll)
Visual C++ 6.0 MFC 6.0 (mfc42.dll)
Visual C++ .NET 2002 MFC 7.0 (mfc70.dll)
Visual C++ .NET 2003 MFC 7.1 (mfc71.dll)
Visual C++ 2005 MFC 8.0 (mfc80.dll)

[edit] See also

[edit] External links

[edit] Official sites

[edit] Tips