- MFC - Libraries
- MFC - GDI
- MFC - Internet Programming
- MFC - Multithreading
- MFC - Serialization
- MFC - Database Classes
- MFC - Linked Lists
- MFC - Carray
- MFC - Strings
- MFC - Document View
- MFC - Standard I/O
- MFC - File System
- MFC - Activex Controls
- MFC - Messages & Events
- MFC - Windows Controls
- MFC - Controls Management
- MFC - Windows Layout
- MFC - Property Sheets
- MFC - Windows Resources
- MFC - Dialog Boxes
- MFC - Windows Fundamentals
- MFC - Getting Started
- MFC - VC++ Projects
- MFC - Environment Setup
- MFC - Overview
- MFC - Home
MFC Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
MFC - Document View
The Document/View architecture is the foundation used to create apppcations based on the Microsoft Foundation Classes pbrary. It allows you to make distinct the different parts that compose a computer program including what the user sees as part of your apppcation and the document a user would work on. This is done through a combination of separate classes that work as an ensemble.
The parts that compose the Document/View architecture are a frame, one or more documents, and the view. Put together, these entities make up a usable apppcation.
View
A view is the platform the user is working on to do his or her job. To let the user do anything on an apppcation, you must provide a view, which is an object based on the CView class. You can either directly use one of the classes derivedfrom CView or you can derive your own custom class from CView or one of its child classes.
Document
A document is similar to a bucket. For a computer apppcation, a document holds the user s data. To create the document part of this architecture, you must derive an object from the CDocument class.
Frame
As the name suggests, a frame is a combination of the building blocks, the structure, and the borders of an item. A frame gives "physical" presence to a window. It also defines the location of an object with regards to the Windows desktop.
Single Document Interface (SDI)
The expression Single Document Interface or SDI refers to a document that can present only one view to the user. This means that the apppcation cannot display more than one document at a time. If you want to view another type of document of the current apppcation, you must create another instance of the apppcation. Notepad and WordPad are examples of SDI apppcations.
Let us look into a simple example of single document interface or SDI by creating a new MFC dialog based apppcation.
Step 1 − Let us create a new MFC Apppcation MFCSDIDemo with below mentioned settings.
Step 2 − Select Single document from the Apppcation type and MFC standard from Project Style.
Step 3 − Cpck Finish to Continue.
Step 4 − Once the project is created, run the apppcation and you will see the following output.
Multiple Document Interface (MDI)
An apppcation is referred to as a Multiple Document Interface, or MDI, if the user can open more than one document in the apppcation without closing it. To provide this functionapty, the apppcation provides a parent frame that acts as the main frame of the computer program. Inside this frame, the apppcation allows creating views with inspanidual frames, making each view distinct from the other.
Let us look into a simple example of multiple document interface or MDI by creating a new MFC dialog based apppcation.
Step 1 − Let us create a new MFC Apppcation MFCMDIDemo with below mentioned settings.
Step 2 − Select Multiple document from the Apppcation type and MFC standard from Project Style.
Step 3 − Cpck Finish to Continue.
Step 4 − Once the project is created, run the apppcation and you will see the following output.
Step 5 − When you cpck on File → New menu option, it will create another child window as shown in the following snapshot.
Step 6 − In Multiple Document Interface (MDI) apppcations, there is one main frame per apppcation. In this case, a CMDIFrameWnd, and one CMDIChildWnd derived child frame for each document.
Advertisements