Start-Up MDI app without opening empty document 
Author Message
 Start-Up MDI app without opening empty document

I apologize for this simplistic question, I know I have done this before a
long time ago, but now can't seem to find the documentation reference.

How can I suppress the opening of an empty document during start-up of an
MDI app?  I want to force the user to input some options first, before
either creating a new project or opening an exisitng one.

Thanks,



Tue, 10 Jun 2003 22:29:23 GMT  
 Start-Up MDI app without opening empty document

Quote:
>How can I suppress the opening of an empty document during start-up of an
>MDI app?  I want to force the user to input some options first, before
>either creating a new project or opening an exisitng one.

Robert,

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
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Wed, 11 Jun 2003 01:18:26 GMT  
 Start-Up MDI app without opening empty document


: I apologize for this simplistic question, I know I have done this
before a
: long time ago, but now can't seem to find the documentation reference.
:
: How can I suppress the opening of an empty document during start-up of
an
: MDI app?  I want to force the user to input some options first, before
: either creating a new project or opening an exisitng one.
:
: Thanks,
:

In the BOOL CYourOwnApp::InitInstance() function place this code or
something like it.

 // Enable DDE Execute open
 EnableShellOpen();
 RegisterShellFileTypes(TRUE);

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

 // ------------ INSERTION
POINT --------------------------------------------
 // The following code looks in the Registry's MRU list for the last
file opened
 // if it exists it loads it. If the MRU list is empty the app starts
without a
 // document view. If the MRU list has a file listed, but the file does
not exist,
 // a blank window appears. From then on the OnFileNew() will open a new
blank window.

 if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) {
  CString sLastPath(GetProfileString("Recent File List", "File1"));
  if (! sLastPath.IsEmpty()) {
   CFile f;
   // If there is a file in MRU list, open it
   if (f.Open(sLastPath, CFile::modeRead)) {
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileOpen;
    cmdInfo.m_strFileName = sLastPath;
   }
  }
  else {
   // otherwise, don't display a document on startup
   if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew)
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
  }
 }
 // -------- END INSERTION --------------------------------------

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

 // The main window has been initialized, so show and update it.
 pMainFrame->ShowWindow(m_nCmdShow);
 pMainFrame->UpdateWindow();



Thu, 12 Jun 2003 02:03:27 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help! Start MDI app without document

2. Start an MDI App without an open Child Window

3. Don't Open New Document when starting a MDI app

4. Start MDI application with no empty document

5. MS-C++6.0: Starting without empty document

6. MS-C++6.0: Starting without empty document

7. How to create an MDI App without an initial MDI Child opening by the framework

8. Open MDI App Without Opening Doc

9. start MDI without Document

10. Start an SDI App without a Document?

11. Start SDI app without new document?

12. Start an MDI App without an oprn Child Winow

 

 
Powered by phpBB® Forum Software