首页 | 主题 | 图库 | 问答 | 文摘 | 原创 | 百科

历史 | 地理 | 人物 | 艺术 | 体育 | 科学 | 音乐 | 电影 | 信息技术 | 世界遗产

 开放、中立,源自维基百科

Personal tools

Microsoft Foundation Class Library

From Wikipedia, the free encyclopedia

Jump to: navigation, search

The Microsoft Foundation Class Library (also Microsoft Foundation Classes or 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.

Contents

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 OOP/C++ wrapper for Windows API (C). C++ was just beginning to replace C for development of commercial application software (as predominant way to interface the API). With that, they also shipped the very first replacement for (older, alphanumeric) IDE called PWB. New "App Studio" was a good set of designers available at the time, still existent today (2008).

One interesting quirk of MFC is the use of "Afx" as the prefix for many functions, macros and the standard pre-compiled 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. Afx encourages best coding practices (including among other things, several types of specialized asserts, memory supervision, etc). Despites the general "visuality" of MFC is relatively reduced, the classes are very well designed (from OOP point of view, design patterns, etc).

MFC 8.0 was released with Visual Studio 2005. MFC 9.0 was released with Visual Studio 2008. MFC is not included in the free edition of Visual C++ 2005/2008 Express.[1].

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. Eventually, Borland discontinued OWL development and licensed the distribution of the MFC headers, libraries and DLLs from Microsoft[2] for a short time, though it never offered fully integrated support for MFC. Borland later released VCL (Visual Component Library) to replace the OWL framework. VCL provides native support for PME (Properties Methods Events) model at .NET level and fully complies with polymorphism and implementation inheritance. Partial ports of VCL for C++ exist as well (BCB product line). LCL is an open source port of VCL (see Lazarus) currently ported to over 20 hardware and software platforms.

Microsoft's emphasis on MFC has been reduced in favor of their .NET Framework. They failed in this attempt. MFC 7, 8 and 9 still gained support for bridging elements of MFC with the .NET Framework to aid developers in migrating to the new API. The MSVC++ compiler backend can emit managed and native object file(s). The linker can then build them together, generating hybrid (both managed and native) applications, allowing existing native applications to use managed extensions in a seamless and unprecedented manner. This feature is unique (C#, VB, etc do not have it). Also, the MFC designers support in the IDE has been improved (with VS 2002, 2003, 2005 and 2008). Browsing experience is improved (2005 and 2008), and the property window now fully reflects properties, events and override candidates (unique feature as well, among the C++ IDEs). Free C++ refactoring tools are also available, even for the Express editions (as a separate download). Cross platform ports of MFC itself exist (not free). Despite Microsoft's efforts to dismount MFC from people's minds, MFC is an excellent framework and is widely used even today. As a matter of fact, recent Microsoft statements seem to bring back the old glory of MFC. The new C++ compilers from Microsoft have excellent ANSI/ISO standard compliance, the RTL is safe and the debugging experience is excellent (especially for STL containers). Inspired by Microsoft debugger STL debugger support has added to GDB [3].

A 'leaner, meaner' alternative to MFC is the Windows Template Library (WTL). The free Visual C++ Express version compiles WTL applications, but does not include the IDE support of the Standard, Professional and Team editions.[4]

Features

When MFC was introduced, Microsoft extended the C++ syntax with a series of macros for management of Windows messages (via Message Maps), exceptions, custom design run time type identification, serialization 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 Virtual table 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++.

The macros which implemented serialization, exception support, and dynamic runtime types 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. Macros are nothing else but standard C preprocessor constructs.

Visual C++ 2008 Feature Pack

Microsoft is developing an update to the MFC classes that will be made available as an out-of-band update to Visual Studio 2008 and MFC 9 during the first half of 2008.[5] It will feature new user interface constructs, including the Ribbon user interface of Microsoft Office 2007 and associated UI widgets, fully customizable toolbars, docking panes like Visual Studio 2005 (which can either be freely floated or docked to any side) and document tabs.[6] However, the Ribbon elements needs to be created in code; it does not support the XML-based declarative markup like the RibbonX API in Microsoft Office 2007 does. 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 Visual Studio 2005 user interface elements. The new functionality is provided in new classes so that old applications still continue to run.[6] This update is building on top of BCGSoft’s BCGControlBar Library Professional Edition.[7] A beta release of this update to MFC 9 was made in January 7, 2008.[8]

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 the Windows 98 original release)
eMbedded Visual C++ 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)
eMbedded Visual C++ 4.0
Visual C++ .NET 2002 MFC 7.0 (mfc70.dll)
Visual C++ .NET 2003 MFC 7.1 (mfc71.dll)
Visual C++ 20051 MFC 8.0 (mfc80.dll)
Visual C++ 20081 MFC 9.0 (mfc90.dll)
  • 1 The Visual Studio Express Editions do not include the MFC libraries (which can be obtained for free, as well, as a separate download, rc designers not included)

See also

References

Further reading

  • Shepherd, George (1996). MFC Internals. Addison-Wesley. ISBN 0-201-40721-3. 
  • Kruglinski, David (1996). Inside Visual C++. Microsoft Press. ISBN 0-55615-891-2. 
  • Microsoft Corporation (1995). Microsoft Visual C++ Programming with MFC. Microsoft Press. ISBN 1-55615-921-8. 

External links

Official sites

Tips

de:Microsoft Foundation Classes fr:Microsoft foundation class ko:마이크로소프트 파운데이션 클래스 라이브러리 id:Microsoft Foundation Classes it:Microsoft Foundation Classes he:Microsoft Foundation Classes nl:Microsoft Foundation Classes ja:Microsoft Foundation Class pl:MFC pt:Microsoft Foundation Classes ro:Microsoft Foundation Classes ru:Microsoft Foundation Classes

Languages
AD Links