Microsoft Foundation Class Library
Encyclopedia
The Microsoft Foundation Class Library (also Microsoft Foundation Classes or MFC) is a library
Library (computer science)
In computer science, a library is a collection of resources used to develop software. These may include pre-written code and subroutines, classes, values or type specifications....

 that wraps
Wrapper library
In computer programming, a library is a collection of subroutines or classes used to develop software. Libraries expose interfaces which clients of the library use to execute library routines. Wrapper libraries consist of a thin layer of code which translates a library's existing interface into a...

 portions of the Windows API
Windows API
The Windows API, informally WinAPI, is Microsoft's core set of application programming interfaces available in the Microsoft Windows operating systems. It was formerly called the Win32 API; however, the name "Windows API" more accurately reflects its roots in 16-bit Windows and its support on...

 in C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...

 classes
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...

, including functionality that enables them to use a default application framework
Application framework
In computer programming, an application framework consists of a software framework used by software developers to implement the standard structure of an application for a specific development environment ....

. Classes are defined for many of the handle
Handle (computing)
In computer programming, a handle is a particular kind of smart pointer. Handles are used when application software references blocks of memory or objects managed by another system, such as a database or an operating system....

-managed Windows objects and also for predefined windows and common controls.

History

MFC was introduced in 1992 with Microsoft's C/C++ 7.0 compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 for use with 16-bit
16-bit
-16-bit architecture:The HP BPC, introduced in 1975, was the world's first 16-bit microprocessor. Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816. The Intel 8088 was program-compatible with the Intel 8086, and was 16-bit in that its registers were 16...

 versions of Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

 as an extremely thin object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 C++ wrapper for the Windows API. C++ was just beginning to replace C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 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 MFC classes and call member functions belonging to those objects. Many of those functions share their names with corresponding API functions.

One interesting quirk of MFC is the use of "Afx" as the prefix for many functions, macros and the standard precompiled header
Precompiled header
In computer programming, a precompiled header is a technique used by some C or C++ compilers to reduce compilation time.-Overview:In the C and C++ programming languages, a header file is a file whose text may be automatically included in another source file by the C preprocessor by the use of a...

 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 free edition of Visual C++ 2005/2008/2010 Express.

The Object Windows Library
Object Windows Library
The Object Windows Library is a Borland C++ object-oriented framework originally designed for WinAPI. It was used in Turbo Pascal for Windows, Borland Pascal and their Borland C++ package. It was a competitor to the Microsoft Foundation Class Library .OWL had incomplete support by the Borland C++...

 (OWL), designed for use with Borland's Turbo C++
Turbo C++
Turbo C++ was a C++ compiler and integrated development environment and computer language originally from Borland. Most recently it was distributed by Embarcadero Technologies, which acquired all of Borland's compiler tools with the purchase of its CodeGear division in 2008...

 compiler, was a competing product introduced by Borland
Borland
Borland Software Corporation is a software company first headquartered in Scotts Valley, California, Cupertino, California and finally Austin, Texas. It is now a Micro Focus subsidiary. It was founded in 1983 by Niels Jensen, Ole Henriksen, Mogens Glad and Philippe Kahn.-The 1980s:...

 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 VCL (Visual Component Library
Visual Component Library
VCL is a visual component-based object-oriented framework for developing Microsoft Windows applications. It was developed by Borland for use in, and tightly integrated with, its Delphi and C++Builder RAD tools...

) to replace the OWL framework.

Microsoft's emphasis on MFC has been reduced in favor of its .NET Framework
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...

. MFC 7, 8 and 9 bridge elements of MFC with the .NET Framework to aid developers in migrating to the new framework. The MSVC++ compiler backend can emit managed and native object file(s). 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 popular and widely used framework.

A lightweight alternative to MFC is the Windows Template Library
Windows Template Library
The Windows Template Library is a free software, object-oriented C++ template library for Win32 development. WTL was created by Microsoft employee Nenad Stefanovic for internal use and later released as an unsupported add-on to Visual Studio and the Win32 Framework SDK...

 (WTL). C++ Express version compiles WTL applications (if you have ATL installed), but does not include the IDE support of the Standard, Professional and Team editions.

Features

At the time of its introduction, MFC provided C++ macros for Windows message-handling (via Message Maps
Message Maps
Message Maps - the Microsoft Foundation Class Library message map facility.Microsoft Windows implements what are essentially virtual functions in window classes using its messaging facility...

), exceptions
Exception handling
Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....

, run-time type identification
Run-time type information
In programming, RTTI refers to a C++ system that makes information about an object's data type available at runtime. Run-time type information can apply to simple data types, such as integers and characters, or to generic objects...

 (RTTI), serialization
Serialization
In computer science, in the context of data storage and transmission, serialization is the process of converting a data structure or object state into a format that can be stored and "resurrected" later in the same or another computer environment...

 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
Virtual function
In object-oriented programming, a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting class by a function with the same signature...

 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
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....

 versions of MFC, for Windows NT 3.1
Windows NT
Windows NT is a family of operating systems produced by Microsoft, the first version of which was released in July 1993. It was a powerful high-level-language-based, processor-independent, multiprocessing, multiuser operating system with features comparable to Unix. It was intended to complement...

 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 April 7, 2008, Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

 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 Ribbon
Ribbon (computing)
In GUI-based application software, a ribbon is an interface where a set of toolbars are placed on tabs in a tab bar. Recent releases of some Microsoft applications have embraced this form with a modular ribbon as their main interface. The Ribbon is a contextual interface that offers functionality...

 user interface of Microsoft Office 2007
Microsoft Office 2007
Microsoft Office 2007 is a Windows version of the Microsoft Office System, Microsoft's productivity suite. Formerly known as Office 12 in the initial stages of its beta cycle, it was released to volume license customers on November 30, 2006 and made available to retail customers on January 30, 2007...

 and associated UI widgets
Web widget
In computing a web widget is a software widget for the web. It's a small application that can be installed and executed within a web page by an end user. They are derived from the idea of code reuse. Other terms used to describe web widgets include: portlet, gadget, badge, module, webjit, capsule,...

, fully customizable toolbar
Toolbar
In a graphical user interface, on a computer monitor, a toolbar is a GUI widget on which on-screen buttons, icons, menus, or other input or output elements are placed. Toolbars are seen in office suites, graphics editors, and web browsers...

s, docking panes like Visual Studio 2005 (which can either be freely floated or docked to any side) and document tab
Tab (GUI)
In the area of graphical user interfaces , a tabbed document interface is one that allows multiple documents to be contained within a single window, using tabs as a navigational widget for switching between sets of documents...

s. The MFC Ribbon resource editor allows the developer to design the ribbon graphically instead of having to use the XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

-based declarative markup like the RibbonX API in Microsoft Office 2007
Microsoft Office 2007
Microsoft Office 2007 is a Windows version of the Microsoft Office System, Microsoft's productivity suite. Formerly known as Office 12 in the initial stages of its beta cycle, it was released to volume license customers on November 30, 2006 and made available to retail customers on January 30, 2007...

. 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
Ribbon (computing)
In GUI-based application software, a ribbon is an interface where a set of toolbars are placed on tabs in a tab bar. Recent releases of some Microsoft applications have embraced this form with a modular ribbon as their main interface. The Ribbon is a contextual interface that offers functionality...

 or the Visual Studio 2005 user interface elements. 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.

Microsoft has also imposed additional licensing requirements on users of the Ribbon UI. These include a requirement to adhere to Microsoft UI Design Guidelines, and a prohibition against using such a UI in applications which compete with Microsoft Office applications.

Versions

Product version MFC version Year introduced
Microsoft C/C++ 7.0 MFC 1.0 1993
Visual C++ 1.0 MFC 2.0
Visual C++ 1.5 MFC 2.5
Visual C++ 1.51 MFC 2.51
Visual C++ 1.52c MFC 2.5 (Last development platform for Windows 3.x
Windows 3.x
Windows 3.x can refer to either an individual or all of the following versions of Microsoft Windows:*Windows 3.0*Windows 3.1x*Windows 3.2...

)
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) Aug 1995
Visual C++ 4.1 MFC 4.1
Visual C++ 4.2 MFC 4.2 (mfc42.dll included with the Windows 98 original release) Mar 1998
eMbedded Visual C++ 3.0 MFC 4.2 (mfc42.dll)
Visual C++ 5.0 MFC 4.21 (mfc42.dll), a major upgrade from MFC 4.2.
Visual C++ 6.0 MFC 6.0 (mfc42.dll) 1998
eMbedded Visual C++ 4.0 MFC 6.0 (mfcce400.dll)
Visual C++ .NET 2002 (Visual C++ 7.0), .NET 1.0 MFC 7.0 (mfc70.dll) Feb 2002
Visual C++ .NET 2003 (Visual C++ 7.1), .NET 1.1 MFC 7.1 (mfc71.dll) Apr 2003
Visual C++ .NET 2003 + MS11-025 MFC 7.10.6119.0 (mfc71.dll) Apr 2011
Visual C++ 20051 (Visual C++ 8.0), .NET 2.0 MFC 8.0.50608.0 (mfc80.dll) Oct 2005
Visual C++ 2005 SP1 MFC 8.0.50727.762 (mfc80.dll)
Visual C++ 2005 SP1 + MS09-035 MFC 8.0.50727.4053 (mfc80.dll) Jul 2009
Visual C++ 2005 SP1 + MS11-025 MFC 8.0.50727.5592(mfc80.dll) Apr 2011
Visual C++ 20081 (Visual C++ 9.0), .NET 3.5 MFC 9.0.21022.8 (mfc90.dll) Nov 2007
Visual C++ 2008 with Feature Pack MFC 9.0.30411 (mfc90.dll) Apr 2008
Visual C++ 2008 SP1 MFC 9.0.30729.1 (mfc90.dll) Aug 2008
Visual C++ 2008 SP1 + MS09-035 MFC 9.0.30729.4148 (mfc90.dll) Jul 2009
Visual C++ 2008 SP1 + MS11-025 MFC 9.0.30729.5570 (mfc90.dll) Apr 2011
Visual C++ 2010, .NET 4.0 MFC 10.0.30319.1 (mfc100.dll) Apr 2010
Visual C++ 2010 + MS11-025 MFC 10.00.30319.415 (mfc100.dll) Apr 2011
Visual C++ 2010 SP1 MFC 10.0.40219.1 (mfc100.dll) March 2011

1 The Visual Studio Express Editions do not include the MFC libraries.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK