BOOL CMDITestApp::InitInstance() { InitCommonControls(); // 这里删减了大量注释和错误处理 CWinApp::InitInstance(); AfxOleInit(); AfxEnableControlContainer(); SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) TRACE("Before CMultiDocTemplate
"); // 注册应用程序的文档模板。文档模板 // 将用作文档、框架窗口和视图之间的连接 CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MDITestTYPE, RUNTIME_CLASS(CMDITestDoc), RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架 RUNTIME_CLASS(CMDITestView)); if (!pDocTemplate) return FALSE; TRACE("Before AddDocTemplate
"); AddDocTemplate(pDocTemplate); // 创建主 MDI 框架窗口 TRACE("Before new CMainFrame
"); CMainFrame* pMainFrame = new CMainFrame; TRACE("Before pMainFrame->LoadFrame
"); if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; TRACE("Before ParseCommandLine
"); CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 调度在命令行中指定的命令。如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 TRACE("Before ProcessShellCommand
"); if (!ProcessShellCommand(cmdInfo)) return FALSE; TRACE("Before pMainFrame->ShowWindow
"); // 主窗口已初始化,因此显示它并对其进行更新 pMainFrame->ShowWindow(m_nCmdShow); TRACE("Before pMainFrame->UpdateWindow
"); pMainFrame->UpdateWindow(); return TRUE; } |