SDI Application components
A Single document interface application should include 1) Document class, 2) View Class, 3) Frame class 4) Application class
Document is the class to manage data part of the objects. Application often derives a class from CDocument. This deals with saving and retrieving data fields to and from the file stream. MFC often uses CArchive and serialization process to do the same. Users however have other options like direct CFile calls to synch the data to file syatem or query SQL server to do the same. Document module also deals with the logic to maintain the data and also responsible for managing different attributes of the data.
View is the class module to display data of the document. A derived class of CView is often used for this purpose. This display part can be the display of the document in graphical form or with UI elements or in the form of printable view which contains formatted text.
MFC framework uses a Frame window or class CFrame to display window in the screen and thus a CFrame class is always needed in any application which follows document view architecture.
All MFC applications should have an application class defined and derived from CWinApp base class. SDI application should define the same. This class manages the creation of main thread in the application and the starup function initinstance should create objects of doc and view. MFC application should create an global object
User can write all these class headers and implementations manually. All these header and C++ files should be included in an MFC project. Manually creating these files are tedious process and it consumes time. However these are basic SDI frameword skeleton and MFC provides wizard to do these automatically. Wizard creates a step by step dialog to take inputs from user and generates the necessary files needed for the project. Wizard creates all header, C++ source, resource and project files. Lets see the
Overview step is the introduction step. It displays all the steps those will come in this wizard.
There are options like Single Document", "Multiple Documents" and "Dialog based". Select application type as "Single Document". Select project style as "MFC Standard". This will prepare the editor look like old "MFC/VC++ editor"
Compound document type
Enter the document extension and filter.
Select "None" to set no database support.
User Interface Features
Select the frame window features. Go with default selections.
Select the advanced feature support. Go with default selections.
Change the filenames for "View", "App", "Doc", and Frame classes. Go with default names.
Generated Classes - View
Change the filenames for "View" or go with default names.
Generated Classes - App
Change the filenames for "App" or go with default names.
Generated Classes - Doc
Change the filenames for "Doc" or go with default names.
Generated Classes - Frame
Change the filenames for "Frame" or go with default names.
Press finish at the end. VC++ will open a project will all the populated sources and resouces.
About our authors: Team EQA
MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.
This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...
Define a custom Window class structure, Register the class name, CreateWindow, Show windows and write message get and dispatch loop statements. Define the Window CallBack procedure and write the handlers.
DispatchMessage() is a API which indirectly triggers the Window CallBack procedure. Message structure members from this function are passed to the CallBack procedure. CallBack procedure should implement event handlers depending on the need of the application.
LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.
We need to write WinMain and need to follow all these in a Win32 application. However we need not to write much if we are writing an application with MFC ...
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Memory leaks