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.[citation needed] 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.[citation needed]

MFC v8 was released with Visual Studio 2005. MFC is not included with the free Express edition of VS-2005. Microsoft recommends use of .NET for new development.[citation needed]

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.[citation needed] However, it lost market share when OWL updates lagged the addition of new features to Windows.[citation needed] Borland then released VCL (Visual Component Library) to replace the OWL framework. VCL is incompatible with OWL.[citation needed] A decision by Borland was made to discontinue OWL development and Borland began licensing MFC from Microsoft.[citation needed]

[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 macros 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 potential source of bugs for users of MFC.[citation needed]

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.

[edit] Advantages

  • provides an object-oriented programming model to the Windows APIs
  • 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.
  • provides a Document/View framework for creating Model-View-Controller-based architectures.
  • provides utility classes such as CString and collection classes, which are usable even by console applications
  • faster executables than produced by interpreters like Visual Basic
  • generally faster executables than those produced by the .NET Framework
  • capable IDE (integrated development environment) for debugging and code development
  • relatively small gui executables
    • mfc42.dll has been included with all distributions of the Windows operating system since Win98-First Edition
    • Windows 95 included mfc40.dll
    • executables do not require the end-user to have the .NET Framework, which is over 15 mb
    • alternatives to MFC either must link with that vendor's library, or supply a .dll
  • numerous wizards are available for a variety of tasks, especially generating minimal working applications from which to build
  • integration with form designer to position controls
  • large amount of resources available, from books to websites to sample code
  • fast compilation speed
  • similar code base (but typically not completely the same) can be used for desktop and Pocket PC applications.

[edit] Disadvantages

  • Minimally portable to other operating systems
    • Mainsoft has made MFC tools available for Unix [1],
    • Microsoft shipped MFC versions for the Apple Macintosh operating systems in the 1990s. Visual Studio support for the Macintosh has since been discontinued.
    • desktop and Pocket PC versions are similar, but not completely compatible
  • depending on the specific situation, code size will generally be larger than using native Win32 (by a negligible to significant amount ... YMMV)
  • depending on the specific situation, performance can potentially be somewhat slower than using Win32 (again, by a negligible to significant amount ... YMMV)
  • large library with a significant learning curve
  • alternatives such as VCL and Visual Basic provide RAD (rapid application development)
  • compatibility with past versions results in non-conformance with modern C++ standards[citation needed]
  • Microsoft recommends that new development use .NET, so the future of MFC is cloudy[citation needed]
  • It is not clear to what extent Microsoft actually used MFC for internal development of the software they market (a.k.a. eat your own dogfood). Microsoft reportedly used vanilla C (along with a specialized framework) for most or all of the development of their Office suite.
  • Still requires varying degrees of knowledge of the underlying Windows API depending on how much non-MFC wrapped and custom Windows API code is needed.
  • Does not provide a complete abstraction layer interface to the underlying Windows API, requiring custom Windows API code for those portions not covered by MFC.
  • .NET does a much better job at providing an object oriented, complete, natural, and well organized API.

[edit] The future of MFC

Once promoted by Microsoft, emphasis on MFC has been eclipsed by a number of other technologies, especially the family of computer languages associated with the .NET Framework. C# and Visual Basic are often preferred for commercial software development because the complexity of C++ and MFC is often a concern.[citation needed]

Microsoft still officially supports MFC by developing new versions with each new version of Microsoft Visual Studio (except the free Express version does not support MFC [2]). Vendors 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.[citation needed] Programmers often compare the book and its content with the 'WinAPI bible' by Charles Petzold, the famous Programming Windows book (and which has significant criticisms of MFC).[citation needed] 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 (mfc40.dll included with Windows 95)
Visual C++ 4.1 MFC 4.1
Visual C++ 4.2 MFC 4.2 (mfc42.dll included with Windows 98-First Edition)
Pocket PC Embedded 3.0 MFC 4.2 (mfc42.dll)
Visual C++ 5.0 MFC 4.21 (mfc42.dll)
Visual C++ 6.0 MFC 6.0 (mfc42.dll)
Pocket PC Embedded 4.0
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