在OnInitInstance()函数里打开

解决方案 »

  1.   

    先贴一段:“怎样不叫MDI的子窗口自动出现,除非我按NEW” 回复人:vcbacker(VC支持者) (2001-4-27 17:32:00)  得5分 
    在App的InitInstance函数里面找下面这一段:
    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    在它后面加入:
    if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew){
      cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
    }
    就行了,来自《vc++内幕》  
     
    //CUT,贴文到此为止,用上面方法就杜绝了程序启动自动打开空文档。下面,在CMainFrame的OnCreate之后重载OnFileNew函数
    其中做一些修改就可以了,指定文件的路径就OK。
      

  2.   

    在InitInstance中
    加上OpenDocumentFile(CString yourFileName);
      

  3.   

    在msdn中有一段,供老兄参考:
    BOOL CMyApp::InitInstance()
    {
       // ...
      
       if (m_lpCmdLine[0] == _T('\0'))
       {
          // Create a new (empty) document.
          OnFileNew();
       }
       else
       {
          // Open a file passed as the first command line parameter.
          OpenDocumentFile(m_lpCmdLine);
       }
      
       // ...
    }