SDI and MDI

MFC Document View Architecture can have two types of applications. SDI and MDI. SDI stands for Single Document Interfce where as MDI stands for Multiple document interface. Making a SDI or MDI application requires multiple classes. VC++ editor provides "Application Wizard" for users which takes care of the file and class creations of the project. User needs to select verious settings when Wizard progress one by one and finally it gives a finish button to end the process. We will see how a SDI and MDI application can be made and run in step by step.

Single Document Interfaing (SDI)

This type of application can deal with a single document and single view of the document at one point of time. There is no way to open another document in the same application. Only way to open another document is to launch another instance of the application and open the anothe document. Notepad, Wordpad are such application in Windows.

SDI project creation using wizard

Select MFC Appwizard type of your project in VC++. Give the name of the project.

SDI-wizard-project-name

Step 1: Application Single document type. Support Doc /View architechure? Language selection for the resources.

SDI-wizard-step1-create-sdi

Step 2: Add database support to the project? If yes select the source.

SDI-wizard-step2-db-support

Step 3: Compound document support? Compound file and ActiveX support.

SDI-wizard-step3

Step 4: Support for toolbars, status bars, and verious controls, recent file list.

SDI-wizard-step4

Step 5: Style of the project MFC/Windows Explorer. Source comments, MFC shared library or static library.

SDI-wizard-step5

Step 6: Summary of class file names will be generated.

SDI-wizard-step6

Final step: Summary of class file names will be generated.

SDI-wizard-new-project

Files and classes:

  • CAboutDlg- About dialog
  • CChildFrame- Child frame window
  • CMainFrame- Main frame window of SDI App
  • CSDIDemoApp- MDI MFC app class

SDI-project-files

SDI-classes

Running SDI Application.

Single Document Interfaing (SDI) Application

Multiple Document Interfae (MDI)

This type of application can deal with multiple documents and views of the documents at one point of time. Thus many documents can be opened and can be edited at any point of time. There is no need to open new application instance to open a new document. Visual Studio/Visual C++ editor and many other source code editors are good example of this MDI design.

MDI project creation using wizard

Select MFC Appwizard type of your project in VC++. Give the name of the project.

MDI-wizard-project-name

Step 1: Application Single document type. Support Doc /View architechure? Language selection for the resources.

MDI-wizard-step1-create-mdi

Step 2: Add database support to the project? If yes select the source.

MDI-wizard-step2-db-support

Step 3: Compound document support? Compound file and ActiveX support.

MDI-wizard-step3

Step 4: Support for toolbars, status bars, and verious controls, recent file list.

MDI-wizard-step4

Step 5: Style of the project MFC/Windows Explorer. Source comments, MFC shared library or static library.

MDI-wizard-step5

Step 6: Summary of class file names will be generated.

MDI-wizard-step6

Final step: Summary of class file names will be generated.

MDI-wizard-new-project

Files and classes:

  • CAboutDlg- About dialog
  • CChildFrame- Child frame window of each MDI
  • CMainFrame- Main frame window of MDI App
  • CMDIDemoApp- MDI MFC app class
  • CMDIDemoDoc- MDI MFC Doc class
  • CMDIDemoView- MDI MFC View class

MDI-project-files

MDI-classes

Running MDI Application.

Multiple Document Interfaing (SDI) Application

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

#