MFC 应用程序体系结构类MFC application architecture classes

此类别中 (MFC) 类的 Microsoft 基础类库有助于 MFC 应用程序的体系结构。The Microsoft Foundation Class library (MFC) classes in this category contribute to the architecture of an MFC application. 它们提供大部分应用程序常见的功能。They supply functionality common to most applications. 填充框架以添加应用程序特定功能。You fill in the framework to add application-specific functionality. 通常,您通过从体系结构类派生新的类,然后添加新成员或重写现有成员函数来实现。Typically, you do so by deriving new classes from the architecture classes, and then adding new members or overriding existing member functions.

应用程序向导 生成多种类型的应用程序,所有这些应用程序都以不同的方式使用应用程序框架。Application wizards generate several types of applications, all of which use the application framework in differing ways. SDI (单文档界面) 和 MDI (多文档界面) 应用程序可充分利用框架的文档/视图部分。SDI (single document interface) and MDI (multiple document interface) applications make full use of the document/view part of the framework. 其他类型的应用程序(如基于对话框的应用程序、基于窗体的应用程序和 DLL)仅使用部分文档/视图体系结构功能。Other types of applications, such as dialog-based applications, form-based applications, and DLLs, use only some of document/view architecture features.

文档/视图应用程序包含一个或多个文档、视图和框架窗口集。Document/view applications contain one or more sets of documents, views, and frame windows. 文档模板对象将每个文档/视图/框架集的类关联起来。A document-template object associates the classes for each document/view/frame set.

您无需在 MFC 应用程序中使用文档/视图体系结构,但这样做有很多好处。You don't have to use document/view architecture in your MFC application, but there are a number of advantages to doing so. MFC OLE 容器和服务器支持基于文档/视图体系结构,如对打印和打印预览的支持。The MFC OLE container and server support is based on document/view architecture, as is support for printing and print preview.

所有 MFC 应用程序至少有两个对象:派生自的应用程序对象 CWinApp ,以及某些类型的主窗口对象,派生 (通常间接) CWndAll MFC applications have at least two objects: an application object derived from CWinApp, and some sort of main window object, derived (often indirectly) from CWnd. (最常见的情况是,主窗口派生自 CFrameWndCMDIFrameWndCDialog ,所有这些都是从派生的 CWnd 。 ) (Most often, the main window is derived from CFrameWnd, CMDIFrameWnd, or CDialog, all of which are derived from CWnd.)

使用文档/视图体系结构的应用程序包含其他对象。Applications that use document/view architecture contain additional objects. 主要对象包括:The main objects are:

  • 如前面所述,从类派生的应用程序对象 CWinAppAn application object derived from class CWinApp, as mentioned before.
  • 从类派生的一个或多个文档类对象 CDocumentOne or more document class objects derived from class CDocument. 文档类对象负责在视图中操作的数据的内部表示形式。Document class objects are responsible for the internal representation of the data that is manipulated in the view. 它们可能与数据文件关联。They may be associated with a data file.
  • 从类派生的一个或多个视图对象 CViewOne or more view objects derived from class CView. 每个视图都是附加到文档并与框架窗口关联的一个窗口。Each view is a window that is attached to a document and associated with a frame window. 视图显示和操作文档类对象中包含的数据。Views display and manipulate the data contained in a document class object.

文档/视图应用程序还包含从 CFrameWnd) 派生的) 和文档 (模板派生的框架窗口 (CDocTemplateDocument/view applications also contain frame windows (derived from CFrameWnd) and document templates (derived from CDocTemplate).

另请参阅See also

类概述Class Overview