BOOL CRadiantApp::InitInstance() { //g_hOpenGL32 = ::LoadLibrary("opengl32.dll"); // 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. //AfxEnableMemoryTracking(FALSE); #ifdef _AFXDLL //Enable3dControls(); // Call this when using MFC in a shared DLL #else //Enable3dControlsStatic(); // Call this when linking to MFC statically #endif // If there's a .INI file in the directory use it instead of registry char RadiantPath[_MAX_PATH]; GetModuleFileName( NULL, RadiantPath, _MAX_PATH ); // search for exe CFileFind Finder; Finder.FindFile( RadiantPath ); Finder.FindNextFile(); // extract root CString Root = Finder.GetRoot(); // build root\*.ini CString IniPath = Root + "\\REGISTRY.INI"; // search for ini file Finder.FindNextFile(); if( Finder.FindFile( IniPath ) ) { Finder.FindNextFile(); // use the .ini file instead of the registry free( ( void * )m_pszProfileName ); m_pszProfileName = _tcsdup( _T( Finder.GetFilePath() ) ); // look for the registry key for void* buffers storage ( these can't go into .INI files ) int i = 0; CString key; HKEY hkResult; DWORD dwDisp; DWORD type; char iBuf[3]; do { sprintf( iBuf, "%d", i ); key = "Software\\Q3Radiant\\IniPrefs" + CString( iBuf ); // does this key exists ? if( RegOpenKeyEx( HKEY_CURRENT_USER, key, 0, KEY_ALL_ACCESS, &hkResult ) != ERROR_SUCCESS ) { // this key doesn't exist, so it's the one we'll use strcpy( g_qeglobals.use_ini_registry, key.GetBuffer( 0 ) ); RegCreateKeyEx( HKEY_CURRENT_USER, key, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkResult, &dwDisp ); RegSetValueEx( hkResult, "RadiantName", 0, REG_SZ, reinterpret_cast<CONST BYTE *>( RadiantPath ), strlen( RadiantPath ) + 1 ); RegCloseKey( hkResult ); break; } else { char RadiantAux[ _MAX_PATH ]; unsigned long size = _MAX_PATH; // the key exists, is it the one we are looking for ? RegQueryValueEx( hkResult, "RadiantName", 0, &type, reinterpret_cast<BYTE *>( RadiantAux ), &size ); RegCloseKey( hkResult ); if( !strcmp( RadiantAux, RadiantPath ) ) { // got it ! strcpy( g_qeglobals.use_ini_registry, key.GetBuffer( 0 ) ); break; } } i++; } while( 1 ); g_qeglobals.use_ini = true; } else { // Change the registry key under which our settings are stored. SetRegistryKey( EDITOR_REGISTRY_KEY ); g_qeglobals.use_ini = false; } 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_RADIANTYPE, // RUNTIME_CLASS(CRadiantDoc), // RUNTIME_CLASS(CMainFrame), // custom MDI child frame // RUNTIME_CLASS(CRadiantView)); // AddDocTemplate(pDocTemplate); // create main MDI Frame window g_PrefsDlg.LoadPrefs(); glEnableClientState( GL_VERTEX_ARRAY ); CString strTemp = m_lpCmdLine; strTemp.MakeLower(); if( strTemp.Find( "builddefs" ) >= 0 ) { g_bBuildList = true; } CMainFrame *pMainFrame = new CMainFrame; if( !pMainFrame->LoadFrame( IDR_MENU_QUAKE3 ) ) { return FALSE; } if( pMainFrame->m_hAccelTable ) { ::DestroyAcceleratorTable( pMainFrame->m_hAccelTable ); } pMainFrame->LoadAccelTable( MAKEINTRESOURCE( IDR_MINIACCEL ) ); m_pMainWnd = pMainFrame; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow( m_nCmdShow ); pMainFrame->UpdateWindow(); return TRUE; }
BOOL Ctask1App::InitInstance() { CWinAppEx::InitInstance(); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) InitContextMenuManager(); 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(Ctask1Doc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(Ctask1View)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 分析标准 shell 命令、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 CApp::InitInstance() { if(!CDCGFApp::InitInstance()) return FALSE; 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. /* #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif */ // 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("DEAD:CODE")); LoadStdProfileSettings(8); // Load standard INI file options (including MRU) CDCGFStringTable::Init(); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate( IDR_PROJECTYPE, RUNTIME_CLASS(CProjectDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CProjectView)); AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; // Enable drag/drop open //m_pMainWnd->DragAcceptFiles(); // This code replaces the MFC created menus with // the Ownerdrawn versions static UINT toolbars[]={ IDR_MAINFRAME, IDR_TOOLBAR_2 }; pDocTemplate->m_hMenuShared=pMainFrame->NewMenu(IDR_PROJECTYPE, toolbars, 2); pMainFrame->m_hMenuDefault=pMainFrame->NewDefaultMenu(IDR_MAINFRAME, toolbars, 2); /* CDCGFStringTable::LocMenu(CMenu::FromHandle(pMainFrame->m_hMenuDefault)); CDCGFStringTable::LocMenu(CMenu::FromHandle(pDocTemplate->m_hMenuShared)); */ // This simulates a window being opened if you don't have // a default window displayed at startup pMainFrame->OnUpdateFrameMenu(pMainFrame->m_hMenuDefault); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(FALSE); // 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; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); pMainFrame->UpdateWindow(); if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileNothing) { DoSomeNagging(); if(GetRegInt(HKEY_CURRENT_USER, DCGF_TOOLS_REG_PATH, "AutoCheckUpdates", 1)) { pMainFrame->CheckForUpdates(true); } } pMainFrame->UpdateMenuURL(pMainFrame->GetMenu()); return TRUE; }
BOOL CDmTraceViewerApp::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("Local AppWizard-Generated Applications")); LoadStdProfileSettings(8); // Load standard INI file options (including MRU) InitContextMenuManager(); 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* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_DmTraceViewerTYPE, RUNTIME_CLASS(CDmTraceViewerDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CDmTraceViewerView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 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 // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // 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(); return TRUE; }
BOOL CLogicSimulator_1App::InitInstance() { // 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을 // 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다. // InitCommonControlsEx()를 사용하지 않으면 창을 만들 수 없습니다. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 응용 프로그램에서 사용할 모든 공용 컨트롤 클래스를 포함하도록 // 이 항목을 설정하십시오. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); EnableTaskbarInteraction(FALSE); // RichEdit 컨트롤을 사용하려면 AfxInitRichEdit2()가 있어야 합니다. // AfxInitRichEdit2(); // 표준 초기화 // 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면 // 아래에서 필요 없는 특정 초기화 // 루틴을 제거해야 합니다. // 해당 설정이 저장된 레지스트리 키를 변경하십시오. // TODO: 이 문자열을 회사 또는 조직의 이름과 같은 // 적절한 내용으로 수정해야 합니다. SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램")); LoadStdProfileSettings(4); // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다. // 응용 프로그램의 문서 템플릿을 등록합니다. 문서 템플릿은 // 문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CLogicSimulator_1Doc), RUNTIME_CLASS(CMainFrame), // 주 SDI 프레임 창입니다. RUNTIME_CLASS(CLogicSimulator_1View)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다. CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // DDE Execute 열기를 활성화합니다. EnableShellOpen(); RegisterShellFileTypes(TRUE); // 명령줄에 지정된 명령을 디스패치합니다. // 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다. if (!ProcessShellCommand(cmdInfo)) return FALSE; // 창 하나만 초기화되었으므로 이를 표시하고 업데이트합니다. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // 접미사가 있을 경우에만 DragAcceptFiles를 호출합니다. // SDI 응용 프로그램에서는 ProcessShellCommand 후에 이러한 호출이 발생해야 합니다. // 끌어서 놓기에 대한 열기를 활성화합니다. m_pMainWnd->DragAcceptFiles(); return TRUE; }
// CMatchAgentApp 초기화 BOOL CMatchAgentApp::InitInstance() { if (g_SingleRunController.Create(true) == false) return FALSE; /* char szLogFileName[_MAX_DIR]; if (GetRecommandLogFileName(szLogFileName) == false) return FALSE; InitLog(MLOGSTYLE_DEBUGSTRING|MLOGSTYLE_FILE, szLogFileName); */ MRegistry::szApplicationName=APPLICATION_NAME; if(m_ZFS.Create(".")==false){ AfxMessageBox("MAIET Zip File System Initialize Error"); return FALSE; } // 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을 // 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControls()가 필요합니다. // InitCommonControls()를 사용하지 않으면 창을 만들 수 없습니다. InitCommonControls(); CWinApp::InitInstance(); // OLE 라이브러리를 초기화합니다. if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 표준 초기화 // 이들 기능을 사용하지 않고 최종 실행 파일의 크기를 줄이려면 // 아래에서 필요 없는 특정 초기화 루틴을 제거해야 합니다. // 해당 설정이 저장된 레지스트리 키를 변경하십시오. // TODO: 이 문자열을 회사 또는 조직의 이름과 같은 // 적절한 내용으로 수정해야 합니다. SetRegistryKey(_T("로컬 응용 프로그램 마법사에서 생성된 응용 프로그램")); LoadStdProfileSettings(4); // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다. // 응용 프로그램의 문서 템플릿을 등록합니다. 문서 템플릿은 // 문서, 프레임 창 및 뷰 사이의 연결 역할을 합니다. CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MatchAgentTYPE, RUNTIME_CLASS(CMatchAgentDoc), RUNTIME_CLASS(CChildFrame), // 사용자 지정 MDI 자식 프레임입니다. RUNTIME_CLASS(COutputView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); m_pDocTemplateOutput = pDocTemplate; // Template m_pDocTemplateCmdLogView = new CMultiDocTemplate(IDR_MatchAgentTYPE, RUNTIME_CLASS(CMatchAgentDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CCommandLogView)); // AddDocTemplate(m_pDocTemplateCmdLogView); // 주 MDI 프레임 창을 만듭니다. CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; // 접미사가 있을 경우에만 DragAcceptFiles를 호출합니다. // MDI 응용 프로그램에서는 m_pMainWnd를 설정한 후 바로 이러한 호출이 발생해야 합니다. // 표준 셸 명령, DDE, 파일 열기에 대한 명령줄을 구문 분석합니다. CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 명령줄에 지정된 명령을 디스패치합니다. 응용 프로그램이 /RegServer, /Register, /Unregserver 또는 /Unregister로 시작된 경우 FALSE를 반환합니다. if (!ProcessShellCommand(cmdInfo)) return FALSE; // 주 창이 초기화되었으므로 이를 표시하고 업데이트합니다. pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
BOOL CAliasApp::InitInstance() { // 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. BOOL bError = FALSE; if (!m_Quantize.Init()) return(FALSE); Enable3dControls(); LoadStdProfileSettings(); // Load standard INI file options (including MRU) static char BASED_CODE szFilter[] = "Targa Files|*.tga||"; while (!bError) { char szSceneDir[MAX_PATH]; char szGrayDir[MAX_PATH]; char szColorDir[MAX_PATH]; char szCompDir[MAX_PATH]; char szWildCard[MAX_PATH]; char szMsg[MAX_PATH]; WIN32_FIND_DATA FindData; CFileDialog bgdlg(TRUE, "tga", "*.tga", OFN_HIDEREADONLY, szFilter, NULL); //fgdlg.m_ofn.Flags &= ~OFN_EXPLORER; bgdlg.m_ofn.lpstrTitle = "Select Scene Background File"; int nResponse = bgdlg.DoModal(); if (nResponse != IDOK) { DWORD dwErr = CommDlgExtendedError(); break; } m_statusDlg.Create(IDD_STATUS); CString szBackFile = bgdlg.GetPathName(); lstrcpy(szSceneDir, szBackFile); StripFile(szSceneDir); lstrcpy(szGrayDir, szSceneDir); lstrcat(szGrayDir, "GRAY\\"); lstrcpy(szColorDir, szSceneDir); lstrcat(szColorDir, "COLOR\\"); lstrcpy(szCompDir, szSceneDir); lstrcat(szCompDir, "COMP"); #ifndef CPO CreateDirectory(szCompDir, NULL); #endif lstrcat(szCompDir, "\\"); lstrcpy(szWildCard, szColorDir); lstrcat(szWildCard, "*.*"); m_Quantize.Reset(); // first count the number of files to be processed m_nTotal = m_nFiles = 0; HANDLE hFind = FindFirstFile(szWildCard, &FindData); if (!hFind) { wsprintf(szMsg, "No subdirectories found in %s", szGrayDir); MessageBox(NULL, szMsg, "Error", MB_ICONSTOP|MB_OK); continue; } while (hFind != INVALID_HANDLE_VALUE) { if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && FindData.cFileName[0] != '.') { char szGrayAnimDir[MAX_PATH]; char szColorAnimDir[MAX_PATH]; char szCompAnimDir[MAX_PATH]; lstrcpy(szGrayAnimDir, szGrayDir); lstrcat(szGrayAnimDir, FindData.cFileName); FixPath(szGrayAnimDir); lstrcpy(szColorAnimDir, szColorDir); lstrcat(szColorAnimDir, FindData.cFileName); FixPath(szColorAnimDir); lstrcpy(szCompAnimDir, szCompDir); lstrcat(szCompAnimDir, FindData.cFileName); #ifndef CPO CreateDirectory(szCompAnimDir, NULL); #endif FixPath(szCompAnimDir); if (!ProcessFiles(szGrayAnimDir, szColorAnimDir, szCompAnimDir, TRUE)) { FindClose(hFind); bError = TRUE; break; } } if (!FindNextFile(hFind, &FindData)) { FindClose(hFind); break; } } // now actually process all the files hFind = FindFirstFile(szWildCard, &FindData); if (!hFind) { wsprintf(szMsg, "No subdirectories found in %s", szGrayDir); MessageBox(NULL, szMsg, "Error", MB_ICONSTOP|MB_OK); continue; } while (hFind != INVALID_HANDLE_VALUE) { if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY && FindData.cFileName[0] != '.') { char szGrayAnimDir[MAX_PATH]; char szColorAnimDir[MAX_PATH]; char szCompAnimDir[MAX_PATH]; lstrcpy(szGrayAnimDir, szGrayDir); lstrcat(szGrayAnimDir, FindData.cFileName); FixPath(szGrayAnimDir); lstrcpy(szColorAnimDir, szColorDir); lstrcat(szColorAnimDir, FindData.cFileName); FixPath(szColorAnimDir); lstrcpy(szCompAnimDir, szCompDir); lstrcat(szCompAnimDir, FindData.cFileName); #ifndef CPO CreateDirectory(szCompAnimDir, NULL); #endif FixPath(szCompAnimDir); if (!ProcessFiles(szGrayAnimDir, szColorAnimDir, szCompAnimDir)) { FindClose(hFind); bError = TRUE; break; } } if (!FindNextFile(hFind, &FindData)) { FindClose(hFind); break; } } FNAME szPath, szFileName; RGBQUAD StaticMap[256]; RGBQUAD InitialMap[256]; RGBQUAD PaletteMap[256]; ZeroMemory(StaticMap, sizeof(StaticMap)); ZeroMemory(PaletteMap, sizeof(PaletteMap)); GetModuleFileName(m_hInstance, szPath, sizeof(szPath)); StripFile(szPath); lstrcpy(szFileName, szPath); lstrcat(szFileName, "static.pal"); int nStaticEntries = LoadPalette(szFileName, &StaticMap[10]); lstrcpy(szFileName, szPath); lstrcat(szFileName, "initial.pal"); int nInitialEntries = LoadPalette(szFileName, InitialMap); int nEntries = m_Quantize.CreatePalette(PaletteMap, 236-nStaticEntries, InitialMap, nInitialEntries); if (nEntries) { char szPalFile[MAX_PATH]; #ifdef GARBAGE lstrcpy(szPalFile, szSceneDir); lstrcat(szPalFile, "backgrnd.pal"); SavePalette(szPalFile, PaletteMap, 256); PaletteMap[nEntries].rgbRed = m_rgbTrans.red; PaletteMap[nEntries].rgbGreen = m_rgbTrans.green; PaletteMap[nEntries].rgbBlue = m_rgbTrans.blue; lstrcpy(szPalFile, szSceneDir); lstrcat(szPalFile, "foregrnd.pal"); SavePalette(szPalFile, PaletteMap, 256); #endif for (int i = 0; i < nEntries; ++i) StaticMap[i+nStaticEntries+10] = PaletteMap[i]; CreateIdentityMap(StaticMap, 256); lstrcpy(szPalFile, szSceneDir); lstrcat(szPalFile, "final.pal"); SavePalette(szPalFile, StaticMap, 256); nStaticEntries += 10; for (i = 0; i < nStaticEntries; ++i) { #ifndef CPO if (StaticMap[i].rgbRed != m_rgbTrans.red || StaticMap[i].rgbGreen != m_rgbTrans.green || StaticMap[i].rgbBlue != m_rgbTrans.blue) #endif { StaticMap[i].rgbRed = StaticMap[i].rgbGreen = StaticMap[i].rgbBlue = 0; } } for (i = 246; i < 256; ++i) { #ifndef CPO if (StaticMap[i].rgbRed != m_rgbTrans.red || StaticMap[i].rgbGreen != m_rgbTrans.green || StaticMap[i].rgbBlue != m_rgbTrans.blue) #endif { StaticMap[i].rgbRed = StaticMap[i].rgbGreen = StaticMap[i].rgbBlue = 0; } } lstrcpy(szPalFile, szSceneDir); lstrcat(szPalFile, "premiere.pal"); SavePalette(szPalFile, StaticMap, 256); } m_statusDlg.DestroyWindow(); } // 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 CSysCtrlApp::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); CBCGPWinApp::InitInstance(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } 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("BCGP AppWizard-Generated Applications")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) SetRegistryBase(_T("Settings")); // Initialize all Managers for usage. They are automatically constructed // if not yet present // 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(CSysCtrlDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CSysCtrlView)); 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 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(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand //LOGFONT logfont = { 0 }; //::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(LOGFONT), &logfont, 0); //logfont.lfHeight = logfont.lfHeight * 10; ////strcpy(logfont.lfFaceName ,"΢ÈíÑźÚ"); //::afxGlobalData.SetMenuFont(&logfont, true); return TRUE; }
BOOL CDynamoRIOApp::InitInstance() { #ifndef DRSTATS_DEMO TCHAR msg[MAX_PATH*2]; #endif BOOL windows_NT; // 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. if (!CheckWindowsVersion(windows_NT)) { // abort return FALSE; } #if 0 // warning C4996: 'CWinApp::Enable3dControlsStatic': CWinApp::Enable3dControlsStatic is no longer needed. You should remove this call. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif #ifndef DRSTATS_DEMO // Change the registry key under which our settings are stored, // including MRU SetRegistryKey(L_DYNAMORIO_REGISTRY_KEY); LoadStdProfileSettings(12); // Load standard INI file options (including MRU) #endif // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( #ifdef DRSTATS_DEMO IDR_MAINFRAME_DEMO, #else IDR_MAINFRAME, #endif RUNTIME_CLASS(CDynamoRIODoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CDynamoRIOView)); 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; // enable file manager drag/drop and DDE Execute open m_pMainWnd->DragAcceptFiles(); // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // I can't find any other way to access the main frame m_pMainFrame = (CMainFrame *) m_pMainWnd; // I can't figure out how to disable a menu item that has a command // handler when this var is set, so I disable it: m_pMainFrame->m_bAutoMenuEnable = FALSE; #ifndef DRSTATS_DEMO m_bSystemwideAllowed = TRUE; // set the string we'll put into the registry key to inject system-wide TCHAR data[1024]; int len = GetEnvironmentVariable(_T("DYNAMORIO_HOME"), m_dynamorio_home, _MAX_DIR); #if 1 //NOCHECKIN if (len == 0) m_dynamorio_home[0] = _T('\0'); #else if (len == 0) { int res = MessageBox(NULL, _T("DYNAMORIO_HOME environment variable not found.\n") _T("Set all the DynamoRIO environment variables to their default values?\n") _T("(Otherwise this GUI cannot operate and must exit.)"), _T("DynamoRIO Not Configured for Current User"), MB_YESNO | MYMBFLAGS); if (res == IDYES) { if (!ConfigureForNewUser()) return FALSE; } else { // abort return FALSE; } } #endif if (windows_NT) { // we don't support systemwide on NT // hack: use "confirm systemwide" setting to decide whether to notify user if (GetProfileInt(_T("Settings"), _T("Confirm Systemwide"), 1) == 1) { MessageBox(NULL, _T("Run All is not supported on Windows NT, it will be disabled"), _T("Notice"), MB_OK | MYMBFLAGS); // but then how does user turn off, if can't do Run All? // just turn it off now: SetSystemwideSetting(0); } m_bSystemwideAllowed = FALSE; // so key won't be cleared DisableSystemwideInject(); } else { //NOCHECKIN assert(len > 0 && len < _MAX_DIR && len + _tcslen(L_INJECT_ALL_DLL_SUBPATH) < MAX_PATH); _stprintf(data, _T("%s%s"), m_dynamorio_home, L_INJECT_ALL_DLL_SUBPATH); // make sure it exists CFile check; if (!check.Open(data, CFile::modeRead|CFile::shareDenyNone)) { #if 0 // I'm disabling this dialog until we decide to support running apps _stprintf(msg, _T("Library %s does not exist"), data); MessageBox(NULL, msg, _T("Error"), MB_OK | MYMBFLAGS); #endif m_bSystemwideAllowed = FALSE; // so key won't be cleared DisableSystemwideInject(); } else { if (_tcschr(data, _T(' ')) != NULL) { // registry key cannot handle spaces in names! // must get 8.3 alias -- and some volumes do not support such an alias! len = GetShortPathName(data, m_inject_all_value, MAX_PATH); if (len == 0) { _stprintf(msg, _T("Cannot find 8.3 alias for space-containing path \"%s\"!\nDisabling Run All"), data); MessageBox(NULL, msg, _T("Error"), MB_OK | MYMBFLAGS); m_bSystemwideAllowed = FALSE; // so key won't be cleared DisableSystemwideInject(); } } else { _tcscpy(m_inject_all_value, data); } check.Close(); } } // find current status of system-wide injection if (m_bSystemwideAllowed) { HKEY hk; unsigned long size = 1024; int res = RegOpenKeyEx(INJECT_ALL_HIVE, INJECT_ALL_KEY_L, 0, KEY_READ, &hk); assert(res == ERROR_SUCCESS); res = RegQueryValueEx(hk, INJECT_ALL_SUBKEY_L, 0, NULL, (LPBYTE) data, &size); assert(res == ERROR_SUCCESS); RegCloseKey(hk); // WARNING: do not use Unicode build! // if ever get size==2, it's b/c of Unicode build! // Plus, stats viewing doesn't work w/ Unicode build if (size > sizeof(TCHAR)) { // make sure we're the ones who set this value if (_tcscmp(m_inject_all_value, data) != 0) { // FIXME: have user notify us of conflict? int res = MessageBox(NULL, _T("DynamoRIO's RunAll system-wide injection method is ") _T("being used by some other program.\n") _T("DynamoRIO can attempt to override the other program.\n") _T("Otherwise, system-wide injection will be disabled.\n") _T("Override?"), _T("DynamoRIO Conflict"), MB_YESNO | MYMBFLAGS); if (res == IDYES) { // now clear the registry key SetSystemwideInject(_T("")); // if the call fails, callee calls Disable for us } else { m_bSystemwideAllowed = FALSE; // so key won't be cleared DisableSystemwideInject(); } } else { m_bInjectAll = TRUE; } } else { // empty value: no injection m_bInjectAll = FALSE; } } if (m_bSystemwideAllowed) { m_pMainWnd->GetMenu()->CheckMenuItem(ID_FILE_SYSTEMWIDE, MF_BYCOMMAND | ((m_bInjectAll) ? MF_CHECKED : MF_UNCHECKED)); } // make sure preinject dll exists if (m_bSystemwideAllowed) { CFile check; if (!check.Open(m_inject_all_value, CFile::modeRead|CFile::shareDenyNone)) { #if 0 // I'm disabling this dialog until we decide to support running apps _stprintf(msg, _T("Library %s does not exist!\nDisabling Run All"), m_inject_all_value); MessageBox(NULL, msg, _T("DynamoRIO Configuration Error"), MB_OK | MYMBFLAGS); #endif DisableSystemwideInject(); } else check.Close(); } m_dll_path[0] = _T('\0'); DisableMissingLibraries(TRUE); // now select the previously checked library int lib = GetProfileInt(_T("Settings"), _T("Library"), 1); int tried = 0; while (tried < 3) { if (lib == 0 && SwitchLibraries(L_DLLPATH_RELEASE, FALSE)) { OnLibraryRelease(); break; } else if (lib == 1 && SwitchLibraries(L_DLLPATH_DEBUG, FALSE)) { OnLibraryDebug(); break; } else if (lib == 2 && SwitchLibraries(L_DLLPATH_PROFILE, FALSE)) { OnLibraryProfile(); break; } lib = (lib + 1) % 3; tried++; } if (tried == 3) { #if 0 // Disabling MessageBox(NULL, _T("Cannot find any DynamoRIO libraries!\n") _T("Running of applications will be disabled."), _T("Error"), MB_OK | MYMBFLAGS); #endif // disable Run and libraries m_pMainWnd->GetMenu()->EnableMenuItem(ID_FILE_RUN, MF_BYCOMMAND|MF_GRAYED); DisableSystemwideInject(); m_pMainWnd->GetMenu()->EnableMenuItem(ID_LIBRARY_RELEASE, MF_BYCOMMAND|MF_GRAYED); m_pMainWnd->GetMenu()->EnableMenuItem(ID_LIBRARY_DEBUG, MF_BYCOMMAND|MF_GRAYED); m_pMainWnd->GetMenu()->EnableMenuItem(ID_LIBRARY_PROFILE, MF_BYCOMMAND|MF_GRAYED); m_pMainWnd->GetMenu()->CheckMenuItem(ID_LIBRARY_RELEASE, MF_BYCOMMAND|MF_UNCHECKED); m_pMainWnd->GetMenu()->CheckMenuItem(ID_LIBRARY_DEBUG, MF_BYCOMMAND|MF_UNCHECKED); m_pMainWnd->GetMenu()->CheckMenuItem(ID_LIBRARY_PROFILE, MF_BYCOMMAND|MF_UNCHECKED); } if (m_bInjectAll) { MessageBox(NULL, _T("Run All is already set!"), _T("Warning"), MB_OK | MYMBFLAGS); // FIXME: share this code with OnFileSystemwide SetEnvVarPermanently(_T("DYNAMORIO_SYSTEMWIDE"), m_dll_path); // disable changing the library m_pMainWnd->GetMenu()->EnableMenuItem(ID_LIBRARY_RELEASE, MF_BYCOMMAND|MF_GRAYED); m_pMainWnd->GetMenu()->EnableMenuItem(ID_LIBRARY_DEBUG, MF_BYCOMMAND|MF_GRAYED); m_pMainWnd->GetMenu()->EnableMenuItem(ID_LIBRARY_PROFILE, MF_BYCOMMAND|MF_GRAYED); } #endif /*! DRSTATS_DEMO */ return TRUE; }
BOOL CCircleApp::InitInstance() { // InitCommonControlsEx() требуются для Windows XP, если манифест // приложения использует ComCtl32.dll версии 6 или более поздней версии для включения // стилей отображения. В противном случае будет возникать сбой при создании любого окна. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Выберите этот параметр для включения всех общих классов управления, которые необходимо использовать // в вашем приложении. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); // Инициализация библиотек OLE if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // Для использования элемента управления RichEdit требуется метод AfxInitRichEdit2() // AfxInitRichEdit2(); // Стандартная инициализация // Если эти возможности не используются и необходимо уменьшить размер // конечного исполняемого файла, необходимо удалить из следующего // конкретные процедуры инициализации, которые не требуются // Измените раздел реестра, в котором хранятся параметры // TODO: следует изменить эту строку на что-нибудь подходящее, // например на название организации SetRegistryKey(_T("Локальные приложения, созданные с помощью мастера приложений")); LoadStdProfileSettings(4); // Загрузите стандартные параметры INI-файла (включая MRU) // Зарегистрируйте шаблоны документов приложения. Шаблоны документов // выступают в роли посредника между документами, окнами рамок и представлениями CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CCircleDoc), RUNTIME_CLASS(CMainFrame), // основное окно рамки SDI RUNTIME_CLASS(CCircleView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Разрешить использование расширенных символов в горячих клавишах меню CMFCToolBar::m_bExtCharTranslation = TRUE; // Синтаксический разбор командной строки на стандартные команды оболочки, DDE, открытие файлов CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Включить открытие выполнения DDE EnableShellOpen(); RegisterShellFileTypes(TRUE); // Команды диспетчеризации, указанные в командной строке. Значение FALSE будет возвращено, если // приложение было запущено с параметром /RegServer, /Register, /Unregserver или /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; // Одно и только одно окно было инициализировано, поэтому отобразите и обновите его m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); // вызов DragAcceptFiles только при наличии суффикса // В приложении SDI это должно произойти после ProcessShellCommand // Включить открытие перетаскивания m_pMainWnd->DragAcceptFiles(); return TRUE; }
BOOL CCloneDetectorGUIApp::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. AfxInitRichEdit(); 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(FALSE); // 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("Local AppWizard-Generated Applications")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) InitContextMenuManager(); 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* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME, //IDR_CloneDetectorGUTYPE, RUNTIME_CLASS(ClonePairsAsmDoc), RUNTIME_CLASS(ClonePairsAsmFrame), // custom MDI child frame RUNTIME_CLASS(ClonePairsAsmView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); m_pDocTemplateTokenRef = new CMultiDocTemplate(IDR_MAINFRAME, //IDR_TOKEN_REF_MENU, RUNTIME_CLASS(CTokenRefDoc), RUNTIME_CLASS(CTokenRefFrm), // custom MDI child frame RUNTIME_CLASS(ClonePairsAsmView)); // 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 pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); //m_initFragStr = "This is line one\r\nThis is line two\r\n"; CCmdLineInfo cmdInfo; ParseCommandLine(cmdInfo); if( cmdInfo.m_fragmentTmpFile && !cmdInfo.m_strFileName.IsEmpty()) //if(cmdInfo.m_fragmentTmpFile == true) { //TODO IDA PRO PLUGIN HERE readFragFromFile(cmdInfo.m_strFileName,m_initFragStr); //m_initFragStr = cmdInfo.m_strFileName; //"This is line one\r\nThis is line two\r\n"; OnFileNewSearchCodeFrag(); } return TRUE; }
BOOL CUIDesignerApp::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(); // 加载标准 INI 文件选项(包括 MRU) SetRegistryBase(_T("Settings")); CPaintManagerUI::LoadPlugin(_T("mgyUI_Plugin.dll")); InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); // 注册应用程序的文档模板。文档模板 // 将用作文档、框架窗口和视图之间的连接 m_pUIDocTemplate = new CMultiDocTemplate(IDR_UIDESIGNER, RUNTIME_CLASS(CUIDesignerDoc), RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架 RUNTIME_CLASS(CUIDesignerView)); if (!m_pUIDocTemplate) return FALSE; AddDocTemplate(m_pUIDocTemplate); // 创建主 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(); // 启用“DDE 执行” EnableShellOpen(); RegisterShellFileTypes(TRUE); // 主窗口已初始化,因此显示它并对其进行更新 pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); pMainFrame->UpdateWindow(); return TRUE; }
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 CT3000App::InitInstance() { try { // 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(); HRESULT hr;// if(!AfxInitRichEdit()) { AfxMessageBox(IDS_INIT_RICHEDIT_ERROR);// return FALSE;// } if (!AfxSocketInit())// { AfxMessageBox(IDP_SOCKETS_INIT_FAILED);// return FALSE;// } // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); #if 1 try { TCHAR exeFullPath[MAX_PATH+1]; // GetModuleFileName(NULL, exeFullPath, MAX_PATH); // (_tcsrchr(exeFullPath, _T('\\')))[1] = 0;// g_strDatabasefilepath=exeFullPath;// g_strExePth=g_strDatabasefilepath;// CreateDirectory(g_strExePth+_T("Database"),NULL);//creat database folder;// g_strOrigDatabaseFilePath=g_strExePth+_T("T3000.mdb");// g_strDatabasefilepath+=_T("Database\\T3000.mdb");// CString FilePath; HANDLE hFind;// WIN32_FIND_DATA wfd;// hFind = FindFirstFile(g_strDatabasefilepath, &wfd);// if (hFind==INVALID_HANDLE_VALUE)//说明当前目录下无t3000.mdb { //CopyFile(g_strOrigDatabaseFilePath,g_strDatabasefilepath,FALSE);// //没有找到就创建一个默认的数据库 FilePath=g_strExePth+_T("Database\\T3000.mdb"); HRSRC hrSrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_T3000_DATABASE), _T("DB")); HGLOBAL hGlobal = LoadResource(AfxGetResourceHandle(), hrSrc); LPVOID lpExe = LockResource(hGlobal); CFile file; if(file.Open(FilePath, CFile::modeCreate | CFile::modeWrite)) file.Write(lpExe, (UINT)SizeofResource(AfxGetResourceHandle(), hrSrc)); file.Close(); ::UnlockResource(hGlobal); ::FreeResource(hGlobal); }// FindClose(hFind);// g_strDatabasefilepath=(CString)FOR_DATABASE_CONNECT+g_strDatabasefilepath;// g_strImgeFolder=g_strExePth+_T("Database\\image\\");// CreateDirectory(g_strImgeFolder,NULL);// JudgeDB(); //CString strocx=g_strExePth+_T("MSFLXGRD.OCX"); /*CStdioFile file; CString versionno; file. file.SetFilePath(_T("http://www.temcocontrols.com/ftp/software/T3000_Version.txt")); file.ReadString(versionno); file.Close();*/ //CFile file; // file.Open(_T("http://www.temcocontrols.com/ftp/software/T3000_Version.txt"),modeRead); InitModeName();// #if 0 CInternetSession session; CInternetFile *file=NULL; try { INTERNET_PROXY_INFO proxyinfo; proxyinfo.dwAccessType=INTERNET_OPEN_TYPE_PROXY; proxyinfo.lpszProxy=_T("192.168.0.4:8080 "); proxyinfo.lpszProxyBypass=NULL; if (!session.SetOption(INTERNET_OPTION_PROXY,(LPVOID)&proxyinfo,sizeof(INTERNET_PROXY_INFO))) { AfxMessageBox(_T("UserName")); } CString username=_T("alex"); if(!session.SetOption(INTERNET_OPTION_PROXY_USERNAME,username.GetBuffer(),username.GetLength()+ 1)){ AfxMessageBox(_T("UserName")); } CString password=_T("travel"); if(!session.SetOption(INTERNET_OPTION_PROXY_PASSWORD,password.GetBuffer(),password.GetLength()+ 1)){ AfxMessageBox(_T("Password")); } file=(CInternetFile*)session.OpenURL(_T("www.temcocontrols.com/ftp/software/T3000_Version.txt")); } catch (CInternetException* e) { file=NULL; e->Delete(); } CString version; if (file) { while(file->ReadString(version)!=NULL){ } AfxMessageBox(version); } #endif #endif // 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("Temco T3000 Application"));// LoadStdProfileSettings(); // Load standard INI file options (including MRU)// InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); #if 1 hr=CoInitialize(NULL);// if(FAILED(hr)) // { AfxMessageBox(_T("Error Initialize the COM Interface"));// return FALSE;// } #endif } catch (...) { AfxMessageBox(_T("Database operation to stop!")); } CString registerfilename; registerfilename=g_strExePth+_T("REG_msado15.bat"); // ::ShellExecute(NULL, _T("open"), registerfilename.GetBuffer(), _T(""), _T(""), SW_HIDE); registerfilename=g_strExePth+_T("REG_MSFLXGRD.bat"); //::ShellExecute(NULL, _T("open"), registerfilename.GetBuffer(), _T(""), _T(""), SW_HIDE); CString languagepath=g_strExePth+_T("\\Language"); m_locale.AddCatalogLookupPath(languagepath); m_locale.SetLanguage(CLanguageLocale::LANGUAGE_ENGLISH); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views #ifndef Fance_Enable_Test CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CT3000Doc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CT3000View)); #endif #ifdef Fance_Enable_Test CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CT3000Doc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CDialogCM5_BacNet)); #endif if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); //cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; //lsc // 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; GdiplusStartupInput gdiplusStartupInput;// GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL);// #if 1 //////////////////////////////////////////////////////// _ConnectionPtr m_pCon; _RecordsetPtr m_pRs; m_pCon.CreateInstance(_T("ADODB.Connection")); hr=m_pRs.CreateInstance(_T("ADODB.Recordset")); if(FAILED(hr)) { AfxMessageBox(_T("Load msado12.dll erro")); return FALSE; } m_pCon->Open(g_strDatabasefilepath.GetString(),"","",adModeUnknown); m_pRs->Open(_T("select * from Userlogin"),_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText); int nRecord=m_pRs->GetRecordCount(); if (nRecord<=0) { g_bPrivilegeMannage=FALSE; } else { int nUse; _variant_t temp_variant; temp_variant=m_pRs->GetCollect("USE_PASSWORD");// if(temp_variant.vt!=VT_NULL) nUse=temp_variant; else nUse=0; if(nUse==-1) { g_bPrivilegeMannage=TRUE; } else { g_bPrivilegeMannage=FALSE; } } m_pRs->Close(); m_pCon->Close(); if (g_bPrivilegeMannage) {//for just quick debug,only on this computer if(!user_login()) { AfxMessageBox(_T("Error password!")); return false; } } #endif ((CMainFrame*)m_pMainWnd)->InitViews();// m_pMainWnd->SetWindowText(_T("T3000 Building Automation System"));// m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); } catch (...) { // AfxMessageBox(_T("Double click 'REG_msado15.dll',Please!\nAt C:\\Program Files\\Temcocontrols\\T3000")); // CString strFilter = _T("hex File;bin File|*.hex;*.bin|all File|*.*||"); // CFileDialog dlg(true,_T("hex"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,strFilter); // dlg.DoModal(); // CFileDialog dlg(true,NULL,_T("C:\Program Files\Common Files\System\ado")); //dlg.lpstrInitialDir = "..\\hisdata"; //dlg.op //// // OPENFILENAME // if (dlg.DoModal()==IDOK) // { // path = dlg.GetPathName(); // pLogFile = fopen("Log.txt", "wt+"); // fprintf(pLogFile, "%s", (LPCSTR)path); // fclose(pLogFile); // pLogFile = NULL; // } // CFileDialog fileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, // NULL,NULL);//_T("工作表(*.xls)|*.xls|文本文件(*.txt)|*.txt||") // fileDlg.m_ofn.lpstrInitialDir = _T("C:\\Program Files\\Temcocontrols\\T3000\\REG_msado15.dll.bat"); // fileDlg.DoModal(); //::ShellExecute(NULL, _T("open"), _T("C:\\Program Files\\Temcocontrols\\T3000\\REG_msado15.dll.bat"), _T(""), _T(""), SW_SHOW); //vcredist_x86.zip // ::ShellExecute(NULL, _T("open"), _T("C:\\Program Files\\Temcocontrols\\T3000\\vcredist_x86.zip"), _T(""), _T(""), SW_SHOW); //这个要先试试,当电脑没有安装这个文件时,如何捕获这个信息,然后再执行这个。 AfxMessageBox(_T("Open'T3000'Again,Please!")); return TRUE; } return TRUE; }
BOOL CMiniDebuggerApp::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(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } 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("Local AppWizard-Generated Applications")); LoadStdProfileSettings(4); // 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 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMiniDebuggerDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CMiniDebuggerView)); 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; // 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 CRWDSClientApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); CLogin login; if(login.DoModal() == IDCANCEL) return FALSE; m_LoginAccount = login.GetLoginAccount(); m_LoginPassword = login.GetLoginPassword(); m_LoginOrgID = login.GetLoginOrgID(); m_LoginPermission = login.GetLoginPermission(); //if(VerifyLogin(m_LoginAccount, m_LoginPassword, &m_LoginOrgID, &m_LoginPermission) != KErrNone) // return FALSE; //获取权限 //m_LoginPermission = 0x01010101; // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) InitContextMenuManager(); 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(CRWDSClientDoc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(CRWDSClientView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 分析标准 shell 命令、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 CMyCC3DApp::InitInstance() { AfxEnableControlContainer(); // CC3D ATl stuff // Initialize the ATL Module _Module.Init(ObjectMap,m_hInstance); VERIFY(SUCCEEDED(_Module.RegisterServer(TRUE)));// ATL Classes // 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. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif // Change the registry key under which our settings are stored. // You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings(8); // 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. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMyCC3DDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CMyCC3DView)); AddDocTemplate(pDocTemplate); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // 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(); // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); return TRUE; }
BOOL CCugWorkSpaceApp::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(); // 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")); // Initialize all Managers for usage. They are automatically constructed // if not yet present InitContextMenuManager(); InitKeyboardManager(); // TODO: Remove this if you don't want extended tooltips: InitTooltipManager(); GdiplusStartupInput gdiplusStartupInput; GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL); CBCGPToolTipParams params; params.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager ()->SetTooltipParams ( BCGP_TOOLTIP_TYPE_ALL, RUNTIME_CLASS (CBCGPToolTipCtrl), ¶ms); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MAIN, RUNTIME_CLASS(CCugWorkSpaceDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CCugWorkSpaceView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAIN)) return FALSE; m_pMainWnd = pMainFrame; pMainFrame->m_wndMenuBar.LoadData(); // 加载菜单图标资源 pMainFrame->OpenJianMoHuanJing(); // 打开建模环境 pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
BOOL CUDSonCANApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, // 则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); m_pDiagnosticService = DiagnosticService::CServiceManager::GetInstance(); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("Ray Chow")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) InitContextMenuManager(); 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(CUDSonCANDoc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(CUDSonCANView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 分析标准 shell 命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 调度在命令行中指定的命令。如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; // 唯一的一个窗口已初始化,因此显示它并对其进行更新 m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; }
BOOL CCyberToolBoxApp::InitInstance() { // 標準的な初期化処理 // もしこれらの機能を使用せず、実行ファイルのサイズを小さく // したければ以下の特定の初期化ルーチンの中から不必要なもの // を削除してください。 #ifndef _DEBUG #ifndef INSTALL_BIN_DIR char moduleFileName[_MAX_PATH]; HMODULE module = GetModuleHandle(AfxGetAppName()); GetModuleFileName(module, moduleFileName, sizeof(moduleFileName)-1); SetCurrentDirectory(GetDirectoryName(moduleFileName)); // MessageBox(NULL, GetDirectoryName(moduleFileName), "Current Directory", IDOK); #endif #endif WorldInit(); #ifdef _AFXDLL Enable3dControls(); // 共有 DLL の中で MFC を使用する場合にはここを呼び出してください。 #else Enable3dControlsStatic(); // MFC と静的にリンクしている場合にはここを呼び出してください。 #endif LoadStdProfileSettings(); // 標準の INI ファイルのオプションをロードします (MRU を含む) // アプリケーション用のドキュメント テンプレートを登録します。ドキュメント テンプレート // はドキュメント、フレーム ウィンドウとビューを結合するために機能します。 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CCyberToolBoxDoc), RUNTIME_CLASS(CMainFrame), // メイン SDI フレーム ウィンドウ RUNTIME_CLASS(CCyberToolBoxView)); AddDocTemplate(pDocTemplate); // DDE、file open など標準のシェル コマンドのコマンドラインを解析します。 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // コマンドラインでディスパッチ コマンドを指定します。 if (!ProcessShellCommand(cmdInfo)) return FALSE; mDgmDocTemplate = new CMultiDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CDiagramDoc), RUNTIME_CLASS(CDiagramFrame), // メイン SDI フレーム ウィンドウ RUNTIME_CLASS(CDiagramView)); AddDocTemplate(mDgmDocTemplate); mpPerspectiveDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(PerspectiveDoc), RUNTIME_CLASS(PerspectiveFrame), // メイン SDI フレーム ウィンドウ RUNTIME_CLASS(PerspectiveView)); AddDocTemplate(mpPerspectiveDocTemplate); mpPerspectiveDocument = mpPerspectiveDocTemplate->OpenDocumentFile(NULL); mpOrthoDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(OrthoDoc), RUNTIME_CLASS(OrthoFrame), // メイン SDI フレーム ウィンドウ RUNTIME_CLASS(OrthoView)); AddDocTemplate(mpOrthoDocTemplate); mpOrthoDocument = mpOrthoDocTemplate->OpenDocumentFile(NULL); /* setSceneGraphView(view); */ // GetWorld()->createJavaConsole(); m_pMainWnd->SetWindowText(_T("CyberToolbox")); assert(SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS) == TRUE); return TRUE; }
BOOL CVecDemoApp::InitInstance() { 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. if (!AfxOleInit()) { AfxMessageBox("Ole Initialization Failed"); return FALSE; } HDC hdc=GetDC(NULL); ASSERT(hdc!=NULL); int bpp = GetDeviceCaps(hdc, BITSPIXEL); ReleaseDC(NULL, hdc); if(bpp <= 8) { AfxMessageBox("This application requires more then 256 colors."); return FALSE; } #if _MSC_VER<8 #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif // 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("Monfort Software")); 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. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CVecDemoDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CVecDemoView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // main frame will not show itself on creation m_nCmdShow = SW_HIDE; // Dispatch commands specified on the command line BOOL bFileOpen = FALSE; if(cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen) { cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew; bFileOpen = TRUE; } if (!ProcessShellCommand(cmdInfo)) return FALSE; ((CMainFrame*)m_pMainWnd)->LoadWorkspace(); // show the main frame with the size that we loded from the registery m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); if(bFileOpen) { POSITION pos = pDocTemplate->GetFirstDocPosition(); pDocTemplate->GetNextDoc(pos)->OnOpenDocument(cmdInfo.m_strFileName); } else { POSITION pos = pDocTemplate->GetFirstDocPosition(); CVecDemoDoc* pAlbDoc = (CVecDemoDoc*)pDocTemplate->GetNextDoc(pos); pos = pAlbDoc->GetFirstViewPosition(); CVecDemoView* pVecDemoView = (CVecDemoView*) pAlbDoc->GetNextView(pos); pVecDemoView->ClearDocument(); } return TRUE; }
BOOL CFaceEncryptApp::InitInstance() { //AfxMessageBox("InitInstance()"); { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_CHOOSEOPERATION_TMPL, RUNTIME_CLASS(CFaceEncryptDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(CChooseOperation)); // view class AddDocTemplate(pNewDocTemplate); } 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. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif // 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("Local AppWizard-Generated Applications")); 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. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CFaceEncryptDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CFaceEncryptView)); AddDocTemplate(pDocTemplate); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // 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(); // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); return TRUE; }
BOOL CServerApp::InitInstance() { #ifdef _DEBUG // turn on extra memory tracking afxMemDF |= checkAlwaysMemDF; #endif // OLE 2.0 initialization if (!AfxOleInit()) { AfxMessageBox(IDP_AFXOLEINIT_FAILED); return FALSE; } // Standard initialization LoadStdProfileSettings(); // Register document templates CDocTemplate* pDocTemplate; pDocTemplate = new CHierSvrDocTemplate; pDocTemplate->SetServerInfo( IDR_HIERSVRTYPE_SRVR_EMB, IDR_HIERSVRTYPE_SRVR_IP, RUNTIME_CLASS(CInPlaceFrame), RUNTIME_CLASS(CServerView)); AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } m_pMainWnd = pMainFrame; // enable file manager drag/drop and DDE Execute open m_pMainWnd->DragAcceptFiles(); EnableShellOpen(); // connect the COleTemplate server to the document template m_server.ConnectTemplate(clsid, pDocTemplate, FALSE); COleTemplateServer::RegisterAll(); // Note: MDI applications register all class objects regardless of // the /Embedding on the command line. // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // try to launch as an OLE server if (cmdInfo.m_bRunEmbedded) { // application was run with /Embedding flag. Instead of showing // the window, the application waits to receive OLE requests. return TRUE; } m_server.UpdateRegistry(); RegisterShellFileTypes(TRUE); COleObjectFactory::UpdateRegistryAll(); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
BOOL C图片管理器App::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); ::CoInitialize(NULL);//初始化数据库连接 CWinApp::InitInstance(); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskbarInteraction(FALSE); // 使用 RichEdit 控件需要 AfxInitRichEdit2() // AfxInitRichEdit2(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(5); // 加载标准 INI 文件选项(包括 MRU) // 注册应用程序的文档模板。文档模板 // 将用作文档、框架窗口和视图之间的连接 CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MyTYPE, RUNTIME_CLASS(C图片管理器Doc), RUNTIME_CLASS(CChildFrame), // 自定义 MDI 子框架 RUNTIME_CLASS(C图片管理器View)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // 创建主 MDI 框架窗口 CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } m_pMainWnd = pMainFrame; // 分析标准 shell 命令、DDE、打开文件操作的命令行 CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // 调度在命令行中指定的命令。如果 // 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。 if (!ProcessShellCommand(cmdInfo)) return FALSE; // 主窗口已初始化,因此显示它并对其进行更新 pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }
BOOL CWedApp::InitInstance() { CString str; char *ptr; //SetDialogBkColor(0x00ff0000, 0xffffff); WaitCursor = AfxGetApp()->LoadStandardCursor(IDC_WAIT); NormalCursor = AfxGetApp()->LoadStandardCursor(IDC_ARROW); GetModuleFileName(AfxGetInstanceHandle(), approot, MAX_PATH); CTime ct = CTime::GetCurrentTime(); CString datestr = ct.Format("%A, %B %d, %Y - %I:%M %p"); C2N(); P2N("\r\nStarted WED application at %s\r\n", datestr); //P2N("AppRoot=%s\r\n", approot); //CString desktop; //GetSpecialFolder(CSIDL_DESKTOPDIRECTORY, desktop); //desktop += "wed"; //P2N("Desktop special: %s\r\n", desktop); // Create initial desktop xcpt folder //if(access(desktop, 0) == -1) // { // P2N("Making %s\r\n", desktop); // //message("Created desktop folder."); // _mkdir(desktop); // } ptr = strrchr(approot, '\\'); if(ptr) *(ptr+1) = '\0'; //dataroot = (CString)approot + "wed\\"; GetSpecialFolder(CSIDL_PERSONAL, dataroot); dataroot += "WedData\\"; P2N("Wed user data directory: %s\r\n", dataroot); if(access(dataroot, 0)) { if(mkdir(dataroot)) { //P2N("Cannot create data root dir\r\n"); } } ////////////////////////////////////////////////////////////////////// // Create data dirs str = dataroot; str += "data"; // Check if data dir is in order if(access(str, 0)) { if(mkdir(str)) { //P2N("Cannot create data dir\r\n"); } } str = dataroot; str += "macros"; // Check if data dir is in order if(access(str, 0)) { if(mkdir(str)) { //P2N("Cannot create macro dir\r\n"); } } str = dataroot; str += "holdings"; // Check if data dir is in order if(access(str, 0)) { if(mkdir(str)) { //P2N("Cannot create holders dir\r\n"); } } str = dataroot; str += "coco"; // Check if coco dir is in order if(access(str, 0)) { if(mkdir(str)) { //P2N("Cannot create coco dir\r\n"); } } str = dataroot; str += "backup"; // Check if state dir is in order if(access(str, 0)) { if(mkdir(str)) { //P2N("Cannot create state dir\r\n"); } } str = dataroot; str += "template"; // Check if state dir is in order if(access(str, 0)) { if(mkdir(str)) { //P2N("Cannot create template dir\r\n"); } } //P2N("Started Application: %s %s\r\n", // m_pszAppName, approot); getcwd(str.GetBuffer(MAX_PATH), MAX_PATH); str.ReleaseBuffer(); //P2N("Initial dir: %s\r\n", str); if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } // Initialize OLE 2.0 libraries if (!AfxOleInit()) { AfxMessageBox("Failed OLE library init, OLE functions will not be available"); } AfxEnableControlContainer(); #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif // Change the registry key under which our settings are stored. // You should modify this string to be something appropriate // such as the name of your company or organization. SetRegistryKey(_T("RobotMonkeySoftware")); LoadStdProfileSettings(6); // 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. pDocTemplate = new CMultiDocTemplate( IDR_WEDTYPE, RUNTIME_CLASS(CWedDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CWedView)); AddDocTemplate(pDocTemplate); // create main MDI Frame window pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; // Global m_pMainWnd = pMainFrame; // Get resources we need: // 1. Fonts CString fontname = GetProfileString(strConfig, strFontName, "Courier"); int size = GetProfileInt(strConfig, strFontSize, 10); int weight = GetProfileInt(strConfig, strFontWeight, 0); int italic = GetProfileInt(strConfig, strFontItalic, 0); if(!ff.CreateFont(size, 0, 0, 0, weight, italic, 0, 0, 0, 0, 0, 0, FIXED_PITCH, fontname)) { AfxMessageBox("Cannot set font"); } if(!ff.GetLogFont(&fflf)) { AfxMessageBox("Cannot get font parameters"); } // 2. Printer fonts if(!pp.CreateFont(80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FF_MODERN, "system")) { MessageBox(NULL, "Cannot set font", "Wed", 0); } if(!pp.GetLogFont(&pplf)) { MessageBox(NULL, "Cannot get font parameters", "Wed", 0); } // Get colors bgcol = GetProfileInt(strConfig, strColorBg, bgcol); fgcol = GetProfileInt(strConfig, strColorFg, fgcol); selcol = GetProfileInt(strConfig, strColorSel , selcol ); cselcol = GetProfileInt(strConfig, strColorCSel, cselcol); cadd = GetProfileInt(strConfig, strColorAdd , cadd ); cdel = GetProfileInt(strConfig, strColorDel , cdel ); cchg = GetProfileInt(strConfig, strColorChg , cchg ); comm = GetProfileInt(strConfig, strColorComm, comm ); srcc = GetProfileInt(strConfig, strColorSrc , srcc ); clng = GetProfileInt(strConfig, strColorLong, clng ); // Bimaps caret.LoadBitmap(IDB_BITMAP1); backwrap = GetProfileInt(strConfig, strBackWrap , 0); Tab2Space = GetProfileInt(strConfig, strTab2Space, 0); tabstop = GetProfileInt(strConfig, strTabStop, 4); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if(cmdInfo.m_strFileName != "") { comline = TRUE; OpenDocumentFile(cmdInfo.m_strFileName); } else { // DON'T display a new MDI child window during startup!!! cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; } // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // Key settings // Figure out last usage time ... int last = GetProfileInt(strConfig, "strLastUsage", 0); use = GetProfileInt(strConfig, "strUsage", 0); //P2N("Usage count %d \r\n", use); // First time ever, display initial file if(!use) { OpenDocumentFile("Welcome.txt"); comline = TRUE; if(currentedit) { } } use++; CTime tt = CTime::GetCurrentTime(); CTimeSpan t(tt.GetTime() - (time_t)last); //P2N("Time diff of last fire %d -- %d \r\n", // t.GetTotalSeconds(), (int)tt.GetTime()); YieldToWin() ; // Show sign banner only if more then 60 seconds passed //if(t.GetTotalSeconds() > 60) { spp.Create(IDD_DIALOG5, NULL); spp.Show(); } YieldToWin() ; //if(GetKeyState(VK_SHIFT)) // { // AfxMessageBox("SHIFT HELD on startup\r\n"); // return(TRUE); // } // The main window has been initialized ... // Show and update it. m_nCmdShow = GetProfileInt(strConfig, "WindowState", 1); pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); int num = GetProfileInt(strSection, strIntItem, 0); // De-serialize hash map CMap < int, int&, CString, CString& > HashMap; CFile cf; CString fname; fname.Format("%s%s", dataroot, "macros\\hashes.000"); if( cf.Open( fname, CFile::modeRead)) { CArchive ar( &cf, CArchive::load); HashMap.Serialize(ar); } else { //P2N("Cannot open hash map file: %s\r\n", fname); } POSITION rpos; rpos = HashMap.GetStartPosition(); while(rpos) { int key; CString val; HashMap.GetNextAssoc(rpos, key, val); //P2N("In Hashlist: %x %s\r\n", key, val); } if(!comline) { // Reopen old documents: CString buf2, file; for(int count1 = 1; count1 <= num; count1++) { CWedDoc *doc = NULL; buf2.Format("%d", count1); file = GetProfileString(strSection, strStringItem + buf2); //P2N("Reloading file: '%s' at %s\r\n", file, buf2); // Empty file, no action if(file == "") continue; doc = (CWedDoc*)OpenDocumentFile(file); if(YieldToWinEx()) break; //P2N("After Reloading file: %s at %s\r\n", file, buf2); if(doc) { ASSERT_VALID(doc); // Document had an error if(doc->ssel.m_err) break; int lrow, lcol; lrow = GetProfileInt(strSection, strStringItem + buf2 + "row", 0); lcol = GetProfileInt(strSection, strStringItem + buf2 + "col", 0); // Update cursor positions ... POSITION pos = doc->GetFirstViewPosition(); for(;;) { if(!pos) break; CWedView *cv = (CWedView*)doc->GetNextView(pos); if(cv) { ASSERT_VALID(cv); cv->row = lrow; cv->col = lcol; cv->SyncCaret(); YieldToWin() ; } } // This happens after load, set it again doc->UpdateAllViews(NULL); } } // Try figure out last current directory int idx; if( (idx = file.ReverseFind('\\')) != -1) { file = file.Left(idx + 1); } P2N("CWedApp::InitInstance Chdir: '%s'\r\n", file); _chdir(file); targdir = srcdir = file; } message ("Loading macros ..."); LoadMacros(); message ("Loading holdings ..."); LoadHoldings(); message(""); return TRUE; }
BOOL CbaltoshopApp::InitInstance() { // 응용 프로그램 매니페스트가 ComCtl32.dll 버전 6 이상을 사용하여 비주얼 스타일을 // 사용하도록 지정하는 경우, Windows XP 상에서 반드시 InitCommonControlsEx()가 필요합니다. // 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); // MRU를 포함하여 표준 INI 파일 옵션을 로드합니다. InitContextMenuManager(); 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(CbaltoshopDoc), RUNTIME_CLASS(CMainFrame), // 주 SDI 프레임 창입니다. RUNTIME_CLASS(CbaltoshopView)); 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 CLibraryApp::InitInstance() { 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. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif // 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("Local AppWizard-Generated Applications")); LoadStdProfileSettings(); // Load standard INI file options (including MRU) //Login Dialog CLoginDlg cLoginDlg; /* if(cLoginDlg.DoModal() != IDOK) return false; */ // 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(CLibraryDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CLibraryView)); 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; if(!cLoginDlg.IsUserType()) { CMenu *menu = m_pMainWnd->GetMenu(); menu->DeleteMenu(0,MF_BYPOSITION); m_pMainWnd->DrawMenuBar(); //ÖØ»æ²Ëµ¥À¸ } // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; }
BOOL KSceneEditorApp::InitInstance() { BOOL bResult = false; BOOL bRetCode = false; HRESULT hr = E_FAIL; char* pszRetCWD = NULL; IRecorderFactory* piRecorderFactory = NULL; CMultiDocTemplate* pDocTemplate = NULL; MFCFramework::CMainFrame* pMainFrame = NULL; KGLOG_PARAM LogParam; char szCWD[MAX_PATH]; CCommandLineInfo cmdInfo; //使用Dummper m_hDummperModule = LoadLibrary(_T("dumper.dll")); pszRetCWD = getcwd(szCWD, sizeof(szCWD)); KGLOG_PROCESS_ERROR(pszRetCWD); g_SetRootPath(); g_SetFindFileMode(TRUE); g_SetFilePath(""); g_LoadPackageFiles("config.ini", "PackFile"); memset(&LogParam, 0, sizeof(LogParam)); snprintf(LogParam.szPath,sizeof(LogParam.szPath),"%s\\logs",szCWD); LogParam.szPath[sizeof(LogParam.szPath) - 1] = '\0'; strcpy(LogParam.szIdent, "SceneEditor"); LogParam.nMaxLineEachFile = 65536; LogParam.Options = (KGLOG_OPTIONS)KGLOG_OPTION_FILE; bRetCode = KGLogInit(LogParam, NULL); KGLOG_PROCESS_ERROR(bRetCode); m_bLogInitFlag = true; bRetCode = KMemory::Initialize("SceneEditor.memory"); KGLOG_PROCESS_ERROR(bRetCode); m_bMemoryInitFlag = true; g_cEditorDirectory.Load(); { TCHAR AppDir[256] = {0}; GetCurrentDirectory(256, AppDir); wsprintf(g_szDefWorkDirectory,"%s\\",AppDir); wsprintf(g_szDefExeDirectory,"%s\\",AppDir); } 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("Local AppWizard-Generated Applications")); LoadStdProfileSettings(10); // 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. pDocTemplate = new CMultiDocTemplate( IDR_SCENEETYPE, RUNTIME_CLASS(KSceneEditorDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(KSceneEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MESHETYPE, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDS_OBJECTTYPE, RUNTIME_CLASS(KSceneObjectEditorDoc), RUNTIME_CLASS(KSceneObjectEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneObjectEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_SFXEDITOR, RUNTIME_CLASS(KSceneSFXEditorDoc), RUNTIME_CLASS(KSceneSFXEditorFrame), // custom MDI child frame RUNTIME_CLASS(KSceneSFXEditorView)); pDocTemplate->SetContainerInfo(IDR_SFXEDITOR); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MODELTYPE, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDS_DATAFLOWFILE, RUNTIME_CLASS(KSceneDataFlowEditorDoc), RUNTIME_CLASS(KScneDataFlowEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneDataFlowEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_PVSTYPE, RUNTIME_CLASS(KPvsEditorDoc), RUNTIME_CLASS(KPvsEditorFrame), // custom MDI child frame RUNTIME_CLASS(KPvsEditorView)); pDocTemplate->SetContainerInfo(IDR_PVSTYPE); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MODELTYPE2, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_SPEEDTREETYPE, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); pDocTemplate = new CMultiDocTemplate( IDR_MODELTYPE3, RUNTIME_CLASS(KSceneModelEditorDoc), RUNTIME_CLASS(KSceneModelEditorFrameWnd), // custom MDI child frame RUNTIME_CLASS(KSceneModelEditorView)); pDocTemplate->SetContainerInfo(IDR_SCENEETYPE_CNTR_IP); AddDocTemplate(pDocTemplate); // create main MDI Frame window pMainFrame = new MFCFramework::CMainFrame; bRetCode = pMainFrame->LoadFrame(IDR_SCENEETYPE); KGLOG_PROCESS_ERROR(bRetCode); m_pMainWnd = pMainFrame; //(by dengzhihui 2006年12月7日 15:48:16 extern BYTE* g_SceneEditorKeyState;//键盘状态 ZeroMemory(g_SceneEditorKeyState,sizeof(BYTE)*256); //) // Parse command line for standard shell commands, DDE, file open ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line //if (!ProcessShellCommand(cmdInfo)) // return FALSE; // The main window has been initialized, so show and update it. pMainFrame->ShowWindow(SW_MAXIMIZE); pMainFrame->UpdateWindow(); g_pEngineManager->GetUseSO3Logical(&g_bUseSO3Logical); if (g_bUseSO3Logical) { piRecorderFactory = CreateRecorderFactoryInterface(ermNormal); KGLOG_PROCESS_ERROR(piRecorderFactory); g_pSO3World = new KSO3World; KGLOG_PROCESS_ERROR(g_pSO3World); bRetCode = g_pSO3World->Init(piRecorderFactory); KGLOG_PROCESS_ERROR(bRetCode); m_bGameWorldOpenFlag = true; if (InitRepresent() && InitUI()) { HWND hWnd = NULL; g_SetGameWorldUIHandler(&g_pUI->GetGameWorldUIHandler()); g_SetGameWorldRepresentHandler(g_pRepresent->GetGameWorldRepresentHandler()); g_pRepresentHandler = g_pRepresent->GetRepresentHandelr(); g_pRepresent->GetRepresentHandelr()->AttachGameWorld(g_pSO3World, QuerySO3WorldClientInterface()); g_pRepresent->GetRepresentHandelr()->Attach3DEngine(g_GetEngineIEInterface(), g_pEngineManager->Get3DModelTable(), g_pEngineManager->Get3DUI()); g_pRepresent->GetRepresentHandelr()->AttachUI(g_pUI, &g_pUI->GetGameWorldUIHandler()); g_pEngineManager->GetBaseWnd(&hWnd); g_pRepresent->GetRepresentHandelr()->InitHWND(hWnd); if (!g_pRepresent->Init()) { ::MessageBox(NULL, "表现逻辑初始化失败!", NULL, 0); } } } //创建声音 g_pSoundShell = Create3DSoundShell(); if (!g_pSoundShell) { KGLogPrintf(KGLOG_WARNING, "声音创建失败."); } else { g_pSoundShell->Init(m_pMainWnd->GetSafeHwnd()); } //在这里把需要使用sound的地方都统一设置上soundshell g_pEngineManager->SetSoundShell(g_pSoundShell); if (g_pRepresent) { g_pRepresent->SetSoundShell(g_pSoundShell); } bResult = true; Exit0: if (!bResult) { if (m_bGameWorldOpenFlag) { g_pSO3World->UnInit(); m_bGameWorldOpenFlag = false; } KG_DELETE(g_pSO3World); if (m_bMemoryInitFlag) { KMemory::Finalize(); m_bMemoryInitFlag = false; } if (m_bLogInitFlag) { KGLogUnInit(NULL); m_bLogInitFlag = false; } } KG_COM_RELEASE(piRecorderFactory); return bResult; }
BOOL CMonoSLAMApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); // 初始化 OLE 库 if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); LoadStdProfileSettings(4); // 加载标准 INI 文件选项(包括 MRU) // 注册应用程序的文档模板。文档模板 // 将用作文档、框架窗口和视图之间的连接 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMonoSLAMDoc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(CMonoSLAMView)); 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_SHOWMAXIMIZED); m_pMainWnd->UpdateWindow(); // 仅当具有后缀时才调用 DragAcceptFiles // 在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生 return TRUE; }
BOOL CSpeechApp::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(FALSE); // 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("Packt Publishing\\Ogre3D Cookbook\\Speech Ogre Application")); LoadStdProfileSettings(4); // Load standard INI file options (including MRU) InitContextMenuManager(); 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 CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSpeechDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CSpeechView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Connect the COleTemplateServer to the document template // The COleTemplateServer creates new documents on behalf // of requesting OLE containers by using information // specified in the document template m_server.ConnectTemplate(clsid, pDocTemplate, TRUE); // Note: SDI applications register server objects only if /Embedding // or /Automation is present on the command line // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Enable DDE Execute open EnableShellOpen(); RegisterShellFileTypes(TRUE); // App was launched with /Embedding or /Automation switch. // Run app as automation server. if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) { // Register all OLE server factories as running. This enables the // OLE libraries to create objects from other applications COleTemplateServer::RegisterAll(); // Don't show the main window return TRUE; } // App was launched with /Unregserver or /Unregister switch. Unregister // typelibrary. Other unregistration occurs in ProcessShellCommand(). else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) { UnregisterShellFileTypes(); m_server.UpdateRegistry(OAT_DISPATCH_OBJECT, NULL, NULL, FALSE); AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor); } // App was launched standalone or with other switches (e.g. /Register // or /Regserver). Update registry entries, including typelibrary. else { m_server.UpdateRegistry(OAT_DISPATCH_OBJECT); COleObjectFactory::UpdateRegistryAll(); AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid); } // 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 one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); m_cpVoice.CoCreateInstance(CLSID_SpVoice); InitEngine(); return TRUE; }