BOOL CNewControlsApp::InitInstance() { AfxEnableControlContainer(); AfxOleInit(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. SetRegistryKey(_T("Microsoft\\MFC\\Samples")); SetRegistryBase(_T("Settings")); InitCommonControls(); InitContextMenuManager(); InitShellManager(); CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows)); CMFCButton::EnableWindowsTheming(); NewControlsPropSheet *pPropSheet = new NewControlsPropSheet; m_pMainWnd = pPropSheet; pPropSheet->DoModal(); delete pPropSheet; // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
//************************************************************************************** CBCGShellManager* CBCGWorkspace::GetShellManager() { if (g_pShellManager == NULL) { InitShellManager (); } ASSERT_VALID (g_pShellManager); return g_pShellManager; }
BOOL CwxApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) InitContextMenuManager(); InitShellManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // 注册应用程序的文档模板。文档模板 // 将用作文档、框架窗口和视图之间的连接 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CwxDoc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(CwxView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 分析标准外壳命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 调度在命令行中指定的命令。如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; // 唯一的一个窗口已初始化,因此显示它并对其进行更新 m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // 仅当具有后缀时才调用 DragAcceptFiles // 在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生 return TRUE; }
BOOL CExplorerXPApp::InitInstance() { InOut log (TEXT("CExplorerXPApp::InitInstance")); // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); AfxOleInit(); AfxEnableControlContainer(); InitContextMenuManager(); InitShellManager(); InitThemes(); COleMessageFilter *pfilter = AfxOleGetMessageFilter(); if (pfilter) { pfilter->EnableBusyDialog(FALSE); pfilter->EnableNotRespondingDialog(FALSE); } RegisterShellClipboardFormats (); /*HINSTANCE hInstance = LoadLibrary(_T("Bulgarian.dll")); if( hInstance ) { AfxSetResourceHandle( hInstance ); } */ InitSoftwareLogPath (); gOptions.Load (); gFolderStateMan.Load(); gGroupManager.Load (); dirs.Load(); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; ParseCommandLine(cmdInfo); if ( !m_SingleInstance.Create( IDR_MAINFRAME, cmdInfo) ) return FALSE; // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("ExplorerXP")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_EXPLORTYPE, RUNTIME_CLASS(CExplorerXPDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CExplorerXPView)); AddDocTemplate(pDocTemplate); CMainFrame* pMainFrame = new CMainFrame; { InOut log2 (_T("Mainframe:Load")); // create main MDI Frame window if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; } m_pMainWnd = pMainFrame; // Dispatch commands specified on the command line // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); { InOut log2(_T("MainFrame->FillTree ")); // pMainFrame->FillTree (); } LoadFilters (); dirs.Start (); LoadDefaultTabs(); gShortcutManager.Initialize (); gShortcutManager.LoadAccel(IDR_MAINFRAME); if (!cmdInfo.m_strFileName.IsEmpty ()) { // //AfxMessageBox (cmdInfo.m_strFileName); if (cmdInfo.m_strFileName[cmdInfo.m_strFileName.GetLength() -1] == _T('\"')) cmdInfo.m_strFileName.Delete (cmdInfo.m_strFileName.GetLength() -1); OpenFolder (cmdInfo.m_strFileName); } pMainFrame->RepositionMDIChildsInitial (); return TRUE; }
BOOL CExplorerApp::InitInstance() { // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } CoInitialize (NULL); AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Microsoft\\MFC\\Samples")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) SetRegistryBase (_T("Settings")); // Initialize all Managers for usage. They are automatically constructed // if not yet present InitContextMenuManager(); InitKeyboardManager(); InitShellManager(); // Enable user-defined tools. If you want allow more than 10 tools, // add tools entry to resources (ID_USER_TOOL11, ID_USER_TOOL12,...) EnableUserTools (ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CExplorerDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CExplorerView)); 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; // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; }
BOOL CCafeOrangeApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(); // AfxInitRichEdit2() is required to use RichEdit control // AfxInitRichEdit2(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("CafeOrange")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) InitContextMenuManager(); InitShellManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CMultiDocTemplate* pImageEditorDocTemplate; pImageEditorDocTemplate = new CMultiDocTemplate(IDR_CafeOrangeTYPE, RUNTIME_CLASS(CCafeOrangeDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CCafeOrangeView)); if (!pImageEditorDocTemplate) return FALSE; AddDocTemplate(pImageEditorDocTemplate); CMultiDocTemplate* pOpenCVDocTemplate; pOpenCVDocTemplate = new CMultiDocTemplate(IDR_CafeOrangeTYPE, RUNTIME_CLASS(CCafeOrangeDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(COpenCVView)); if (!pOpenCVDocTemplate) return FALSE; AddDocTemplate(pOpenCVDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } m_pMainWnd = pMainFrame; // call DragAcceptFiles only if there's a suffix // In an MDI app, this should occur immediately after setting m_pMainWnd // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; 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 FALSE; // The main window has been initialized, so show and update it pMainFrame->ShowWindow(m_nCmdShow); //pMainFrame->UpdateWindow(); CDocument* pOpenCVDoc = pOpenCVDocTemplate->OpenDocumentFile(NULL); CDocument* pImageEditorDoc = pImageEditorDocTemplate->OpenDocumentFile(NULL); pOpenCVDoc->SetTitle("Movie"); pImageEditorDoc->SetTitle("ImageEditor"); POSITION OpenCVPosition= pOpenCVDoc->GetFirstViewPosition(); CView *pOpenCVView = pOpenCVDoc->GetNextView(OpenCVPosition); //CMDIChildWndEx* pOpenCVWnd = (CMDIChildWndEx*)pOpenCVView->GetParentFrame(); POSITION ImageEditorPosition = pImageEditorDoc->GetFirstViewPosition(); CView *pImageEditorView = pImageEditorDoc->GetNextView(ImageEditorPosition); //CMDIChildWndEx* pImageEditorWnd = (CMDIChildWndEx*)pImageEditorView->GetParentFrame(); pMainFrame->InitializeMDIView(pOpenCVView, pImageEditorView); pMainFrame->UpdateWindow(); return TRUE; }
BOOL CEcoZipFMApp::InitInstance() { g_hInstance = m_hInstance; // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } CoInitialize(NULL); if (FAILED(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL))) return FALSE; AfxEnableControlContainer(); // Create the shell manager, in case the dialog contains // any shell tree view or shell list view controls. InitShellManager(); // Activate "Windows Native" visual manager for enabling themes in MFC controls CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows7)); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization m_strRegSection.Empty(); SetRegistryKey(_T(""));// _T("[email protected]")); InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); LoadState(); // DWORD dwRouting; // if (SystemParametersInfo(SPI_GETMOUSEWHEELROUTING, 0, &dwRouting, 0)) { // DWORD dwNewRouting = MOUSEWHEEL_ROUTING_HYBRID; // SystemParametersInfo(SPI_SETMOUSEWHEELROUTING, 0, &dwNewRouting, 0); // } g_RAM_Size_Defined = NWindows::NSystem::GetRamSize(g_RAM_Size); SetLargePageSize(); LoadLangOneTime(); #if defined(_WIN32) && !defined(_WIN64) && !defined(UNDER_CE) Set_Wow64(); #endif #if defined(_WIN32) && !defined(UNDER_CE) SetMemoryLock(); Set_SymLink_Supported(); #endif ReloadLang(); CEcoZipFMDlg dlg; InitWindow(&dlg); m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } else if (nResponse == -1) { TRACE(traceAppMsg, 0, "Warning: dialog creation failed, so application is terminating unexpectedly.\n"); TRACE(traceAppMsg, 0, "Warning: if you are using MFC controls on the dialog, you cannot #define _AFX_NO_MFC_CONTROLS_IN_DIALOGS.\n"); } SaveState(); CoUninitialize(); // SystemParametersInfo(SPI_SETMOUSEWHEELROUTING, 0, &dwRouting, 0); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL COngTVApp::InitInstance() { // customisation des barres d'outils non autorisée CMFCToolBar::SetCustomizeMode(FALSE); #ifdef SCINTILLA_DLL // Chargement de la DLL Scintilla : on va la chercher dans le repertoire de l'exe et nul part ailleurs // recuperation du path de l'exe char lpFilename[255]; memset(lpFilename,0,255); GetModuleFileName(NULL ,lpFilename, 255); std::string strSciLexerDllName = CPathMgr::ExtractPath(lpFilename); strSciLexerDllName = strSciLexerDllName + "\\SciLexer.dll"; m_hSciDLL = LoadLibrary(strSciLexerDllName.c_str()); if (NULL == m_hSciDLL) { // DLL scintilla non disponible => on ne pourra pas editer de scrip LUA } else { CVersion versionSciDLL(strSciLexerDllName); if (versionSciDLL.GetProductVersion() < std::string(EXPECTED_SCINTILLA_VERSION)) { // version de la DLL inferieur a la version attendue => on ne pourra pas editer de scrip LUA FreeLibrary(m_hSciDLL); m_hSciDLL = NULL; std::string strMsgError = "Dll min expected version : "EXPECTED_SCINTILLA_VERSION" obtained : "; strMsgError += versionSciDLL.GetProductVersion(); MessageBox(NULL, strMsgError.c_str(), "Unable to load SciLexer.dll", MB_ICONEXCLAMATION); } } #endif #ifdef TEST_ENGLISH // Pour forcer une langue ::SetThreadLocale(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),SORT_DEFAULT)); #endif // nettoyage des clefs de registres de la version precedente // si la version qui s'execute n'est pas identique a celle enregistree dans la base de registres // MFCFP = MFC Feature Pack => pour pouvoir faire cohabiter sur un même PC des versions antérieures à la 1.6.0 et des versions postérieures // a la 1.6.0 // avant la 1.6.0 => IHM basée sur UltimateToolbox et sauvegarde des caractéristiques des fenêtres à plat dans la base de registre // à partir de 1.6.0 => IHM basée sur MFC Feature Pack et sauvegarde des caractéristiques des fenêtres dans une arborescence de clefs // dans la base de registres // le nettoyage de la base de registres plantait si on essaiyait de revenir à une version < 1.6.0 => on différencie la clef de base std::string strReg = "\\CurrentUser\\Software\\" + m_versionInfos.GetCompanyName() + "\\" + m_versionInfos.GetProductName() + "MFCFP\\"; g_Registry.SetFullRegistryItem(strReg.c_str()); CString sVersion=g_Registry.GetStringValue(REGISTRY_KEY_VERSION); CString sProductVersion(m_versionInfos.GetProductVersion().c_str()); if (sVersion != sProductVersion) { DeleteRegTree(&g_Registry); } g_Registry.Close(); // Pour utilisation de RichEditCtrl AfxEnableControlContainer(); AfxInitRichEdit(); // InitCommonControlsEx() est requis sur Windows XP si le manifeste de l'application // spécifie l'utilisation de ComCtl32.dll version 6 ou ultérieure pour activer les // styles visuels. Dans le cas contraire, la création de fenêtres échouera. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // À définir pour inclure toutes les classes de contrôles communs à utiliser // dans votre application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); InitContextMenuManager(); InitShellManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // enregistrement Scintilla #ifndef SCINTILLA_DLL Scintilla_RegisterClasses(AfxGetInstanceHandle()); Scintilla_LinkLexers(); #endif // Supprime pour la gestion multi-lingues // CWinAppEx::InitInstance(); // Initialisation standard // Si vous n'utilisez pas ces fonctionnalités et que vous souhaitez réduire la taille // de votre exécutable final, vous devez supprimer ci-dessous // les routines d'initialisation spécifiques dont vous n'avez pas besoin. // Changez la clé de Registre sous laquelle nos paramètres sont enregistrés // TODO : modifiez cette chaîne avec des informations appropriées, // telles que le nom de votre société ou organisation SetRegistryKey(m_versionInfos.GetCompanyName().c_str()); //First free the string allocated by MFC at CWinApp startup. //The string is allocated before InitInstance is called. free((void*)m_pszProfileName); //Change the name of the .INI file. //The CWinApp destructor will free the memory. // Ce nom est utilise pour la sauvegarde des parametres strReg = m_versionInfos.GetProductName() + "MFCFP"; m_pszProfileName = _tcsdup(strReg.c_str()); LoadStdProfileSettings(4); // Charge les options de fichier INI standard (y compris les derniers fichiers utilisés) // Inscrire les modèles de document de l'application. Ces modèles // lient les documents, fenêtres frame et vues entre eux // creation du manager de doc specifique afin de gerer specifiquement les repertoires // de sauvegarde des diffents documents. // cf http://www.codeguru.com/cpp/w-d/dislog/commondialogs/article.php/c1967 m_pDocManager = new COngTVDocManager; // Creation doc template pour les scripts LUA (uniquement si DLL scintilla disponible) if (NULL != m_hSciDLL) { m_pNewLuaDocTemplate = new CMultiDocTemplate( IDR_LUATYPE , RUNTIME_CLASS(CLuaDoc) , RUNTIME_CLASS(CLuaChildFrame) , RUNTIME_CLASS(CLuaView) ); if (!m_pNewLuaDocTemplate) return FALSE; AddDocTemplate(m_pNewLuaDocTemplate); } // Installe la police DINA HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(IDR_DINA), _T("DINA")); PVOID lpFont = LockResource(LoadResource(NULL, hRes)); DWORD dwSize = SizeofResource(NULL, hRes), cFonts = 0; m_hDinaFont = AddFontMemResourceEx(lpFont, dwSize, NULL, &cFonts); ASSERT(cFonts > 0); // crée la fenêtre frame MDI principale CMainFrame* pMainFrame = new CMainFrame; // On parse la ligne de commande CCmdLine cmdLine; cmdLine.SplitLine(__argc, __argv); // On indique le fichier de configuration ("" par defaut) std::string configFileName = cmdLine.GetSafeArgument("-cnx", 0, ""); pMainFrame->SetConfigFile(configFileName); m_pMainWnd = pMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } // La fenêtre principale a été initialisée et peut donc être affichée et mise à jour pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
BOOL CConfigApp::InitInstance() { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); globalData.SetDPIAware (); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("BCGP AppWizard-Generated Applications")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) SetRegistryBase (_T("Settings")); InitContextMenuManager(); InitKeyboardManager(); InitShellManager(); InitParam(); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CConfigDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CConfigView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open 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 FALSE; LoadCustomState (); // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand return TRUE; }
BOOL CICTStudioApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。 否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); // Initialize GDI+. Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) InitContextMenuManager(); InitShellManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // 注册应用程序的文档模板。 文档模板 // 将用作文档、框架窗口和视图之间的连接 CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_ICTStudioTYPE, RUNTIME_CLASS(CICTStudioDoc), RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架 RUNTIME_CLASS(CICTStudioView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 创建主 MDI 框架窗口 CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } m_pMainWnd = pMainFrame; // 仅当具有后缀时才调用 DragAcceptFiles // 在 MDI 应用程序中,这应在设置 m_pMainWnd 之后立即发生 // 启用拖/放 m_pMainWnd->DragAcceptFiles(); // 分析标准 shell 命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 启用“DDE 执行” EnableShellOpen(); RegisterShellFileTypes(TRUE); // 默认不新建空白文件 cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; // 调度在命令行中指定的命令。 如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; // 主窗口已初始化,因此显示它并对其进行更新 pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }