SDI Application components

A Single document interface application should include 1) Document class, 2) View Class, 3) Frame class 4) Application class

Document

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

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.

Frame

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.

Application

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

SDI wizard

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

Overview step is the introduction step. It displays all the steps those will come in this wizard.

Application type

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

Select none.

Document template

Enter the document extension and filter.

Database support

Select "None" to set no database support.

User Interface Features

Select the frame window features. Go with default selections.

Advanced Features

Select the advanced feature support. Go with default selections.

Generated Classes

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

Further readings

Where is WinMain() function in MFC application ?

MFC hides WinMain in its framework and includes source file on WinMain(). This explains how framework calls global CWinApp::Initinstance() from entry WinMain.

What is the utility of CWinApp class?

This is constructed during global C++ objects are constructed and is already available when Windows calls the WinMain function, which is supplied by the ...

Basic steps in Win32 GUI Application with source code.

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.

What is a Window CallBack procedure and what is its utility?

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.

What are LPARAM and WPARAM in window proc function?

LPARAM and WPARAM are the two parameters in Window CallBack procedure. They signifies parameters of various events. They are used in handing individual events.

What are the basic steps of a typical MFC based application?

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 ...

#