Home > MFC > How to prevent MDI applications from showing a template dialog at startup?

How to prevent MDI applications from showing a template dialog at startup?

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.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: