Applications on most of the OS require the user to know which applications must be used to create documents of a specific type.
Earlier it was not feasible to create a document with data from different applications like a word document with an excel graph and PowerPoint presentation.
But now the user instead of concentrating on the type of application , has to worry only about the work to be done.
The OS maintains a database of information where all applications installed on the system are listed.
The various types of files that each application can deal with are also listed which makes it easier for the OS to locate the application that should be started when the user needs to work on a particular type of a document.
MFC’s Document-View architecture provides the skeleton framework for developing applications , like editors, file viewers and database query front ends, that manage disk-based data.
The document and the view together form the basis of the application framework.
The document stores the data and manages printing the data and coordinates updating multiple views of the data.
The view displays the data and manages user interaction with it, including selection and editing.
As the name suggests the Doc-View architecture adds two new objects to the MFC programs- document and view.
A document class derived from CDocument.
A view class derived from CView.
A frame class derived from CFrameWnd.
A application class derived from CWinApp.
The document is a data object.
All user interaction (like in a word processor) is with the document.
The document is a non-visual object, it cannot receive messages but can respond to the messages.
The document is responsible for the application’s data. It is a data source and is widely used in word processors , spreadsheets and server to networks providing information to programs.
Irrespective of the source, data management is encapsulated within the document object.
The view provides a visual display of the data to the user in a window or on a printed page.
It handles the interaction between the document and the user.
All user interaction with the data in the document is through the interface presented by the view. It can receive messages. For eg-word processing.
It can be a simple window, an SDI, an MDI or a class derived from CFormView having the capabilities of a dialog box.
The frame class contains the view and other user-interface elements like tool bars and menus.
The frame and the view are visual components.
It is a non-visual component like the document.
It is responsible for starting the application and interacting with the windows.
Document-View Architecture CView View Windows File Edit View Help CFrameView CDocument CWinApp
Document and View
Features of Doc-View Architecture
Data is handled and displayed separately .
Multiple views of the same document can be obtained, 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.
The MFC document/view architecture makes it easy to support multiple views, multiple document types, splitter windows, and other valuable user-interface features.
There are two basic types of Document-View applications-
Single Document Interface.
SDI applications support a single type of document and a single view.
Only one document can be opened at any point of time.
It focuses on a particular task. The frame window is also the main frame window for the application.