« May 2006 »
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
You are not logged in. Log in

Programming Tips
Saturday, 20 May 2006
How to prevent MDI applications from showing a template dialog at startup?
Mood:  a-ok
Topic: VC++

Many times we don't want the MDI template dialog to be shown during startup of an MDI application.

Well the million dollar question is how can we prevent it from popping up. Well this is how we do it... :)

Goto your applicationname.cpp file and edit the InitInstance method at the specified place as shown here...

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); 
 
//this is the line that you should add
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; 

// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
    return FALSE;

There is a member variable in the class CCommandLineInfo which is called m_nShellCommand.

This is the variable that tells the command line parser to start a new file at startup. 
This variable is by default set to FileNew. We have to assign a new value to this variable i.e. FileNothing. 
Well this means empty file so MDI will be blank initially and the template dialog doesn't pop up. 

We have to click on New file to see the template dialog again and then choose any 
template from a set of multiple templates that we have created.

Posted by Nibu babu thomas at 3:03 PM
Updated: Saturday, 20 May 2006 3:27 PM

View Latest Entries