Microsoft KB Archive/141725

= INFO: Stopping MFC/MDI from Creating New MDI Child Window On Startup =

Article ID: 141725

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft Foundation Class Library 4.2, when used with:
 * Microsoft Visual C++ 4.0 Standard Edition

-



This article was previously published under Q141725



SUMMARY
By design, an AppWizard-generated MDI application will display a new MDI child window on startup. To turn off this feature, an application needs to use CCommandLineInfo::FileNothing as the shell command when calling the ProcessShellCommand function.



MORE INFORMATION
The enum value CCommandLineInfo::FileNothing is missing from the online documentation of CCommandLineInfo::m_nShellCommand. However, its definition can be found in the header file \Msdev\Mfc\Include\Afxwin.h.

The ProcessShellCommand function is called by InitInstance of any CWinApp-derived class, so you can use the following sample code to disable the creation of a new MDI child window at startup:

Sample Code
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;

...   }

Additional query words: kbinf 4.00

Keywords: kbcode kbdocview kbinfo kbmdi kbuidesign KB141725

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.