次の方法で共有


Document/View: Overview

How Do IDetails

By default, MFC applications use a programming model that separates a program’s data from the display of that data and from most user interaction with the data. In this model, an MFC document object reads and writes data to persistent storage. The document may also provide an interface to the data wherever it resides (such as in a database). A separate view object manages data display, from rendering the data in a window to user selection and editing of data. The view obtains display data from the document and communicates back to the document any data changes.

While you can easily override or ignore the document/view separation, there are compelling reasons to follow this model in most cases. One of the best is when you need multiple views of the same document, such as both a spreadsheet and a chart view. The document/view model lets a separate view object represent each view of the data, while code common to all views (such as a calculation engine) can reside in the document. The document also takes on the task of updating all views whenever the data changes.

MFC’s document/view architecture makes it easy to support multiple views, multiple document types, splitter windows, and other valuable user-interface features. At the heart of document/view are four key classes:

  • ****(or ), an object used to store or control your program’s data.

  • ****(or one of its many derived classes), an object used to display a document’s data and manage user interaction with the data.

  • ****(or one of its variations), an object that provides the frame around one or more views of a document.

  • ****(or ****or ), an object that coordinates one or more existing documents of a given type and manages creating the correct document, view, and frame window objects for that type.

What do you want to do?