2008-10-09 77 views
2

我使用Visual Studio的應用程序嚮導來創建一個具有多文檔界面的框架MFC程序。當我啓動這個程序時,它會自動創建一個子框架,我不希望它這樣做 - 我需要主框架的客戶區域爲空,直到用戶選擇打開文件。如何阻止MFC應用程序在啓動時調用OnFileNew()?

調試器告訴我應用程序類的InitInstance()函數調用ProcessShellCommand()時會創建一個CChildFrame對象,但對於我來說重寫此行爲有什麼好的切入點?在您的應用程序的InitInstance()函數的變化

if (!ProcessShellCommand(cmdInfo)) 

if (cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew && !ProcessShellCommand(cmdInfo)) 

-

回答

3

這爲我工作。

+0

謝謝,我會盡力的。 – 2008-10-09 16:03:40

+0

它的工作原理!但是如果跳過ProcessShellCommand()會產生不必要的後果?這個功能是做什麼的? (我沒有在我的項目中找到它的定義。) – 2008-10-09 16:12:09

1

在InitInstance()中跳過ProcessShellCommand()調用(在FileNew的情況下)的確是要走的路。

5

這個工作,它保持了從外殼印花/開放等

// 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 ; 
} 

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

做一件事..

在XXXApp.cpp文件

在這種方法中

: -

評論以下行.. /*

CCommandLineInfo cmdInfo; 
ParseCommandLine(cmdInfo); 

// Dispatch commands specified on the command line. Will return FALSE if 
// app was launched with /RegServer, /Register, /Unregserver or /Unregister. 
if (!ProcessShellCommand(cmdInfo)) 
    return; 

*/

這樣....

相關問題