How to create a MFC MDI application without initial empty doc/window.

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

Hi

When creating a MFC MDI application through the wizard,

I get an application that starts with a new/empty document/view.

How should I edit code so that to start without it ? that is with the
situation I get closing the initial empty window ?

Thank you

Frank
 
When creating a MFC MDI application through the wizard,
I get an application that starts with a new/empty document/view.

How should I edit code so that to start without it ? that is with the
situation I get closing the initial empty window ?

Frank,

In InitInstance, you need to set the m_nShellCommand variable to the
FileNothing value.

Here's the relevant snippet from Knowledge Base article Q141725
"Stopping MFC/MDI from Creating New MDI Child Window On Startup":

BOOL CMyWinApp::InitInstance()
{
...

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

// Don't display a new MDI child window during startup
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

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

...
}

Dave
 
It works!
Thank you very much!


David Lowndes said:
Frank,

In InitInstance, you need to set the m_nShellCommand variable to the
FileNothing value.

Here's the relevant snippet from Knowledge Base article Q141725
"Stopping MFC/MDI from Creating New MDI Child Window On Startup":

BOOL CMyWinApp::InitInstance()
{
...

// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);

// Don't display a new MDI child window during startup
if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

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

...
}

Dave
 
Back
Top