原创 2004年08月28日 10:58:00

第二章<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

    The Microsoft Foundation Class Library Application Framework



    This chapter introduces the Microsoft Foundation Class (MFC) library 7.0 Application Framework and explains its benefits. It includes a stripped-down but fully operational MFC library program for Microsoft Windows that should help you understand what application framework programming is all about. I’m keeping theory to a minimum here, but I’ve included sections on message mapping and on documents and views to help you understand the examples in later chapters.




Why Use The Application Framework?



    If you’re going to develop applications for Windows, you’ve got to choose a development environment. Assuming that you’ve already rejected non-C options such as Microsoft Visual Basic and Borland Delphi, here are some of your remaining options:

    Program in C with the Win32 API.

Writ your own C++ Windows class library that uses Win32.

    Use the MFC library application framework

    Use another Windows-based application framework. (Most of Them

Are defunct, however-such as Borland’s Object Windows Library [OWL].)








NOTE  We’ll cover .NET Windows Forms in Part VI of this book.


解释:在我们书的第六部分包括.NET的Windows 的窗体.



    If you’re starting from scratch, any option will involve a big learning curve. If you’re already a Win32 programmer, you’ll still have a learning curve with the MFC library. Since its release, the MFC library has become the dominant Windows class library. But even if you’re familiar with it it’s still a good idea to step through the features of this programming choice.



The MFC library is the low-level C++ interface to the Windows API

C++ has been a standard for many developers for a number of years. It’s turned into a mature, well-understood framework with great third-party support. If you need the highest-performance applications, your applications must live as closely to the Windows API as possible. C++ and MFC are as close as you can get without writing WndProc methods by hand.

MFC库是基于低级C++语言的Windows API的接口

    C++是许多开发者支持许多年的标准.它是成熟的良好的框架,得到许多第三方的支持.如果你需要高效的应用程序,你的应用程序必须接近Windows API的运行的可能.C++和MFC已不在支持你去写WNDPROC这样的方法.


Application framework applications use a standard structure

    Any programmer starting on a large project develops some kind of structure for the code. The problem is that each programmer’s structure is different, and it’s difficult for a new team member to learn the structure and conform to it. The MFC library application framework includes its own application structure—one that’s been proven in many software environments and in many projects. If you write a program for Windows that uses the MFC library, you can safely retire to a Caribbean island, knowing that your minions can easily maintain and enhance your code back home.




    Don’t think that the MFC library’s structure makes your programs inflexible. With the MFC library, your program can call Win32 functions at any time, so you can take maximum advantage of Windows.



Application framework applications are small and fast

    Back in the 16-bit days, you could build a self-contained Windows EXE file that was less than 20 KB in size. Today, Windows-based programs are larger. One reason is that 32-bit code is fatter. Even with the large memory model, a Win16 program uses 16-bit addresses for stack variables and many globals. Win32 programs use 32-bit addresses for everything and often use 32-bit integers because they’re more efficient than 16-bit integers. In addition, the C++ exception-handling code consumes a lot of memory.




    That old 20KB program didn’t have a docking toolbar, splitter windows, print preview capabilities, or control container support—features that users now expect. MFC programs are bigger because they do more and look better.    Fortunately, it’s now easy to build applications that dynamically link to the MFC code(and to C run-time code), so the size goes back down again—from 192KB to about 20KB! Of course, you’ll need some big support DLLs in the background , but those are a fact of life these days.



    As far as speed is concerned, you’re working with machine code produced by an optimizing compiler. Execution is fast, but you might notice a startup delay as the support DLLs are loaded.



The Visual C++.NET tools reduce coding drudgery

    The Visual C++.NET resource editors, the MFC Application Wizard, and the code wizards available from Class View significantly reduce the time needed to write code that’s specific to your application. For example, the resource editor creates a header file that contains assigned values for #define constants. The MFC Application Wizard generates skeleton code for your entire application, and you can use the Properties window to add message handlers and map messages to them.

Visual C++的自带工具可以减少编码的难度

    Visual C++自带的资源编辑器,应用程序向导,类代码生成器向导可以大幅度的减少我们编码的时间.例如:用资源编辑器建立头文件中用#define定义的常数.MFC的应用程序向导可以为你的程序建立完整的框架代码,并且你能用属性窗口中增加消息头跟消息映射.


The MFC library application framework is feature rich

    The MFC library 1.0 classes, introduced with C/C++7.0, included the following features:

    A C++ interface to the Windows API

    General-purpose (non-Windows-specific) classes, including:

        Collection classes for lists, arrays, and maps

       A useful and efficient string class

       Time, time span, and date classes

       File access classes for operating system independence

Support for systematic object storage and retrieval to and from disk

    A “common root object” class hierarchy

    Streamlined Multiple Document Interface(MDI) application support

    Some support for OLE1.0



        Windows API是C++语言封装的接口

       通用性(非Windows 类)¸包括:










The MFC library 2.0 classes (in Visual C++ 1.0) picked up where the version 1.0 classes left off by supporting many user interface features that are found in current Windows-based application, plus they introduced the application framework architecture. Here’s a summary of the important new features:

    Full support for File Open, Save and Save as commands and the most recently used file list

    Print preview and printer support

    Support for scrolling windows and splitter windows

    Support for toolbars and status bars

    Access to Visual Basic controls

    Support for context-sensitive help

    Support for automatic processing of data entered in a dialog box

    An improved interface to OLE 1.0

DLL support


MFC2.0类库(在Visual C++ 1.0)在原来1.0的基础上被精简了,当前程序发现在没有它支持的许多用户接口的特色上,正引入了应用程序框架体系.这里大概介绍以下几个重要的特色:








    改进了OLE 1.0的接口



The MFC library 2.5 classes (in Visual C++1.5) contributed the following:

    Open Database Connectivity (ODBC) support that allows you application to access and update data stored in many popular databases such as Microsoft Access, Microsoft FoxPro, and Microsoft SQL Server

An interface to OLE 2.01,with support for in-place editing, linking, Drag and drop, and OLE Automation

    MFC2.5版(在Visual C++1.5中)有下列贡献:


例如Microsoft Access, Microsoft FoxPro,和Microsoft SQL Server.



    Visual C++2.0 was the first 32-bit version of the product. It included support for Microsoft Windows NT version 3.5. It also contained the MFC library 3.0, which had the following new features:

    Tab dialog box (property sheet) support (which was also added to Visual C++ 1.51, included on the same CD)

    Docking control bars that were implemented within MFC

    Support for thin-frame windows

    A separate Control Development Kit (CDK) for building 16-bit and 32-bit OLE controls, although no OLE control container support was provided

    Visual C++2.0是第一个32位版本的产品.它支持Windows NT3.5版.它包含MFC3.0的库.以下是它的几个新特征:

    Tab对话框(属性页)支持(在Visual C++1.51中也增加了,在同一个CD里)





    A subscription release, Visual C++2.1 with the MFC library 3.1, added the following:

    Support for the new Windows 95 (beta) common controls

    A new ODBC Level 2 driver integrated with the Access Jet database engine

    Winsock classes for TCP/IP data communication

    使用MFC3.1版的Visual C++2.1的发布,增加了下列特性:

    支持新的Windows 95(beta)通用控件




    Microsoft decided to skip Visual C++3.0 and proceeded directly to 4.0 in order to synchronize the product version with the MFC library. The MFC library 4.0 contains these additional features:

    New OLE-based Data Access Object (DAO) classes for use with the Jet engine

    Use of the Windows 95 docking control bars instead of the MFC control bars

    Full support for the common controls in the released version of Windows 95, with new tree view and rich-edit view classes

    New classes for thread synchronization

    OLE control container support

    Microsoft决定跳过Visual C++3.0并继续开发MFC4.0的类库.MFC4.0增加了以下特征:


    使用Windows 95的停靠拦控件代替了MFC的控件

    完全支持Windows 95的公共控件,及新的树控件跟RichEdit控件.




    Visual C++4.2 was and important subscription release that included the MFC 4.2. The following new features were included:

    WinInet classes

    ActiveX Documents Server classes

    ActiveX synchronous and asynchronous moniker classes

    Enhanced MFC ActiveX Control classes, with features such as windowless activation, optimized drawing code, and so forth

    Improved MFC ODBC support, including recordset bulk fetches and data transfer without binding.

    Visual C++ 4.2是个重要的版本,它包括MFC4.2.它包括以下新的特征:

    WinInt 类



    增强的MFC ActiveX类,它包括了灵活的无窗,最优化的绘图代码等等.

    改良了MFC ODBC的支持,这包括取记录集的大小和无绑定的数据传输.


    Visual C++ 5.0 included the MFC library 4.21, which fixed some 4.2 bugs.    Visual C++5.0 introduced some worthwhile features of its own as well:

    A redesigned IDE, Microsoft Developer Studio 97, which included and HTML-based online help system and integration with other languages, including Java

    The Active Template Library (ATL) for efficient ActiveX control construction for Internet

    C++ language support for COM(Component Object Model) client programs with the new #import statement for type libraries, as described in Chapter25.

    Visual C++5.0包括MFC4.21,它修复了一些4.2的错误.Visual C++5.0包括一些很突出的特点:

    从新设计了IDE, Microsoft Developer Studio 97,它包含了基于HTML在线帮助系统并集成了其他语言,包括Java



    Visual C++ 6.0 includes the MFC library 6.0 (Notice that the versions are synchronized again.) Many of the features in the MFC library 6.0 enabled developers to support the modern platform at the time, the Microsoft Active Platform, including the following:

    MFC classes that encapsulate the new Windows common controls introduced as part of Microsoft Internet Explorer 4.0

    Support for Dynamic HTML(DHTML),which allows MFC programmers to create applications that can dynamically manipulate and generate HTML pages

    Active Document Containment, which allows MFC-based applications to contain Active Documents

    OLE DB Consumers and Providers Template support and ActiveX Data Objects (ADO) data binding, which help database developers who use the MFC library or ATL

    Visual C++6.0包括MFC6.0(又是同步发部的版本),MFC6.0有许多新的特征帮助开发人员支持当时最新的平台,Microsoft活动平台,包括下列特色:

    MFC封装了新的Windows通用控件同时引入了Microsoft IE4.0



    OLE 客户和提供者摸板支持   和ADO数据绑定,可以帮助那些数据库开发者使用MFC和ATL


    The latest edition of Visual C++, Visual C++.NET ,includes the MFC library 7.0. Many of the features in the MFC library 7.0 support Internet programming (and the new Microsoft .NET platform) and also improve the Windows development environment. The new features include the following:

    Enhanced Support for HTML help within MFC applications

    Support for windowless controls

    DHTML dialog boxes and editing components

    HTTP argument management classes

    Windows 2000 Print dialog box

    Stricter message-handler type checking

    Date support beyond the year 2038


最近的Visual C++版本,Visual C++.NET包含MFC7.0.拥有许多特色的MFC7.0支持Internet编程(在新的Microsoft .NET平台)并同样改进了Windows开发环境.新的特色如下:





    Windows 2000的打印对话框





本章主要介绍与深度学习相关的线性代数知识。2.1 标量、向量、矩阵和张量 标量 (scalar) 、向量 (vector)、矩阵 (matrix) 张量 (tensor) :一般地,一个数组中的元素分...
  • Eclipsesy
  • Eclipsesy
  • 2017年07月26日 11:00
  • 630


一个进程就是一个正在执行程序的实例,包括程序计数器,寄存器和变量的当前值.从概念上说,每个进程拥有它自己的虚拟CPU.实际上真正的CPU在个进程之间来回切换。如果一个程序运行了两遍,则算作两个进程。 ...
  • liuyongli1992
  • liuyongli1992
  • 2016年08月30日 14:58
  • 191


1、可以利用数字的算数右移,然后利用0XFF这样的数字做掩码运算,可以获取到一个数字的符号位。计算机的移位运算有一种很重要的作用就是利用掩码运算去提取一个位模式的一段信息。 2、在C语言中的条件语句,...
  • u010092734
  • u010092734
  • 2014年07月15日 22:33
  • 1675

VC++ .Net 实例学习

VC++.NET中添加由C#编译的DLL引用的方法 关于VC.NET的资料网络上...
  • bcbobo21cn
  • bcbobo21cn
  • 2017年06月18日 16:55
  • 775

java编程思想学习笔记--第二章 一切都是对象

~~如果我们说另一种不同的语言,那么我们就会发觉一个有些不同的世界。 · 每种语言都有自己的操纵内存中元素的方式。 · 你拥有一个引用,并不一定需要一个对象与它关联。 字符串可以用带引号的文本初...
  • a1216323692
  • a1216323692
  • 2017年02月05日 15:55
  • 149

APUE读书笔记-第二章 unix标准及实现

  • u012927281
  • u012927281
  • 2016年06月14日 15:51
  • 305


机器学习通过适当的学习方法,进而能够对于新数据进行分类和预测。 一.机器学习按学习方法分类 监督,非监督,半监督,强化 二.监督式统计机器学习要素 假设:要训练和预测的同类数据...
  • u012177034
  • u012177034
  • 2016年08月04日 16:57
  • 595

ML入门书籍Tom Mitchell《机器学习》笔记——第二章概念学习

概念学习:给定某一类别的若干正例和反例,从中获得该类别的一般定义。也就是说判断某个东西是不是属于这个概念。 概念学习可以看作是一个搜索的过程。Tom在书中介绍了两种搜索的算法:Find-S(...
  • u011937018
  • u011937018
  • 2017年12月18日 16:02
  • 32


为什么企业选择64位linux系统---------------1科学计算领域:需要大内存大浮点性能,64位支持更大内存;64位cpu一次可以取64位数据,比32位多一倍,性能自然提升 如何区分32...
  • csdncsdn89
  • csdncsdn89
  • 2016年11月03日 13:39
  • 681

《计算机网络 自顶向下方法》 - 学习笔记 - 第二章

第二章 应用层 一、网络应用程序体系结构 1. 客户机/服务器结构(C/S):有一个总是打开的主机称为服务器,他服务于来自许多其他称为客户机的主机请求。 2. 点对点体系结构(P2P):自扩展的...
  • u010173489
  • u010173489
  • 2014年01月24日 20:16
  • 833