而且,我也试过把单文档的InitInstance()中的代码,放入对话框的OnButton()函数内,void CMyDlg::OnButton() { CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMyDoc), RUNTIME_CLASS(CMyFrame), // main SDI frame window RUNTIME_CLASS(CMyView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; } 可是在执行OnButton()时,会提示“建立空文档失败”,事实已经证明,不能简单的照般单文档程序的代码,起码,直接复制上面的代码是不可行的!!!难道文档/视图结构的窗口,只能通过向导生成吗????
{
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CMyFrame), // main SDI frame window
RUNTIME_CLASS(CMyView));
AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
}
可是在执行OnButton()时,会提示“建立空文档失败”,事实已经证明,不能简单的照般单文档程序的代码,起码,直接复制上面的代码是不可行的!!!难道文档/视图结构的窗口,只能通过向导生成吗????