BOOL Cab_mfcApp::InitInstance() { CSplashWnd* pSplash = new CSplashWnd; // 创建启动画面窗口 pSplash->ShowWindow(m_nCmdShow); // 显示启动画面窗口 Sleep(2500); // 主窗口延时 2.5 秒 // 如果一个运行在 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(Cab_mfcDoc), RUNTIME_CLASS(CMainFrame), // 主 SDI 框架窗口 RUNTIME_CLASS(Cab_mfcView)); 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 CWordPadApp::InitInstance() { ParseCommandLine(cmdInfo); if (::FindWindow(szWordPadClass, NULL) && IsDocOpen(cmdInfo.m_strFileName)) return FALSE; SetRegistryKey(szRegKey); LoadOptions(); Enable3dControls(); CSplashWnd splash; BOOL bSplash = cmdInfo.m_bShowSplash; if (!cmdInfo.m_bRunEmbedded) { switch (m_nCmdShow) { case SW_HIDE: case SW_SHOWMINIMIZED: case SW_MINIMIZE: case SW_SHOWMINNOACTIVE: bSplash = FALSE; break; case SW_RESTORE: case SW_SHOW: case SW_SHOWDEFAULT: case SW_SHOWNA: case SW_SHOWNOACTIVATE: case SW_SHOWNORMAL: case SW_SHOWMAXIMIZED: if (m_bMaximized) m_nCmdShow = SW_SHOWMAXIMIZED; break; } } else { //Excel 4 will start OLE servers minimized m_nCmdShow = SW_SHOWNORMAL; } int nCmdShow = m_nCmdShow; if (bSplash) { // only show splash if not embedded splash.Create(NULL); splash.ShowWindow(SW_SHOW); splash.UpdateWindow(); } LoadAbbrevStrings(); #ifdef CREATE_DEV_NAMES m_hDevNames = CreateDevNames(); #else m_hDevNames = NULL; #endif NotifyPrinterChanged((m_hDevNames == NULL)); free((void*)m_pszHelpFilePath); m_pszHelpFilePath = _T("WORDPAD.HLP"); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } RegisterFormats(); // Initialize RichEdit control if (LoadLibrary(_T("RICHED32.DLL")) == NULL) { AfxMessageBox(IDS_RICHED_LOAD_FAIL, MB_OK|MB_ICONEXCLAMATION); return FALSE; } // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Initialize all Managers for usage. They are automatically constructed // if not yet present SetRegistryBase (_T("SettingsPro")); InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo params; params.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager ()->SetTooltipParams ( 0xFFFF, RUNTIME_CLASS (CMFCToolTipCtrl), ¶ms); EnableTearOffMenus (NULL, ID_FREE_TEAROFF1, ID_FREE_TEAROFF2); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. DocTemplate.SetContainerInfo(IDR_CNTR_INPLACE); DocTemplate.SetServerInfo( IDR_SRVR_EMBEDDED, IDR_SRVR_INPLACE, RUNTIME_CLASS(CInPlaceFrame)); // 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, &DocTemplate, TRUE); // Note: SDI applications register server objects only if /Embedding // or /Automation is present on the command line. // Check to see if launched as OLE 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(); AfxOleSetUserCtrl(FALSE); // Application was run with /Embedding or /Automation. Don't show the // main window in this case. return TRUE; } // make sure the main window is showing m_bPromptForType = FALSE; OnFileNew(); m_bPromptForType = TRUE; // destroy splash window if (cmdInfo.m_bShowSplash) splash.DestroyWindow(); m_nCmdShow = -1; if (m_pMainWnd == NULL) // i.e. OnFileNew failed return FALSE; if (!cmdInfo.m_strFileName.IsEmpty()) // open an existing document m_nCmdShow = nCmdShow; // Dispatch commands specified on the command line if (cmdInfo.m_nShellCommand != CCommandLineInfo::FileNew && !ProcessShellCommand(cmdInfo)) { return FALSE; } LoadCustomState (); // Enable File Manager drag/drop open m_pMainWnd->DragAcceptFiles(); // When a server application is launched stand-alone, it is a good idea // to update the system registry in case it has been damaged. // do registry stuff in separate thread #ifndef _UNICODE if (m_bWin31) // no threads on Win32s UpdateRegistry(); else #endif AfxBeginThread(DoRegistry, this, THREAD_PRIORITY_IDLE); if (afxGlobalData.m_nBitsPerPixel < 16) { AfxMessageBox(IDS_WRONG_DISPLAY_SETTINGS); } // Set application general look: CAppLookDlg dlg (TRUE); dlg.DoModal (); return TRUE; }
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) //int _tmain(int argc, TCHAR *argv[]) { try{ MyRegisterClass(hThisInstance); Gdiplus::GdiplusStartupInput gdiSI; Gdiplus::GdiplusStartupOutput gdiSO; ULONG_PTR gdiToken; ULONG_PTR gdiHookToken; gdiSI.SuppressBackgroundThread = TRUE; Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO); gdiSO.NotificationHook(&gdiHookToken); CSplashWnd splash; Gdiplus::Bitmap* pImage; if (_access("splash.png", 0)==-1) { CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource; if (pBitmap->Load(SPLASH_GIF)) { pImage = pBitmap->m_pBitmap; } }else{ pImage = Gdiplus::Bitmap::FromFile(L"splash.png"); } splash.SetImage(pImage); splash.SetWindowName(L"Marktfuehrer wird geladen..."); delete pImage; // you are free to delete now if (checkIfProcessIsAlreadyRunning()) { ::MessageBox(NULL, L"Die Anwendung wurde bereits geladen...", L"Info", MB_ICONINFORMATION); exit(0); }else { splash.Show(); CreateChildProcess(); BOOL loaded = FALSE; UINT progressTotal = 0; UINT oldProgress = -1; // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } gdiSO.NotificationUnhook(gdiHookToken); Gdiplus::GdiplusShutdown(gdiToken); exit(0); return (int) msg.wParam; } } catch(exception& e){ ::MessageBox(NULL, L"Die Anwendung konnte die Ladeanzeige nicht finden. Der Marktführer wurde dennoch gestartet. Das kann einen Momemt dauern. Dabei wir Ihnen kein Ladebildschirm gezeigt.", L"Failed", MB_ICONSTOP); exit(0); return (int) msg.wParam; } }
void COptionsDlg::OnSplash() { CSplashWnd * pSplash = new CSplashWnd(IDB_Splash); pSplash->Create(); }
bool Projekt::Init() { CSplashWnd splash; splash.SetImage(Gdiplus::Image::FromFile(L"Data\\Textures\\test.jpg")); splash.Show(); splash.SetProgressBarColor(0x00000000); splash.SetAutoProgress(0, 100, 50); if (!D3D11App::Init()) return false; // Read game settings if (!Settings::GetInstance()->ReadFile("Data\\Settings.txt")) return false; // Initialize effects, input layouts and texture manager Effects::InitAll(mDirect3D->GetDevice()); InputLayouts::InitAll(mDirect3D->GetDevice()); mTextureMgr.Init(mDirect3D->GetDevice()); RenderStates::InitAll(mDirect3D->GetDevice()); // Initialize models GenericHandler::GetInstance()->Initialize(mDirect3D->GetDevice(), &mTextureMgr); Python->Initialize(); //Create and initialize the GUI Gui->Init(mDirect3D->GetDevice()); Network::GetInstance()->Initialize(); Network::GetInstance()->Start(); //init soundmodule this->soundModule = new SoundModule(); this->soundModule->initialize(this->mhMainWnd, this->mDirectInput); // Create game mGame = new Game(mDirect3D->GetDevice(), mDirect3D->GetImmediateContext(), &mTextureMgr, soundModule); // Set if window is fullscreen or not D3D11App::SetFullscreen(Settings::GetInstance()->GetData().IsFullscreen); // Resize window after we've created our Game object D3D11App::SetResolution(Settings::GetInstance()->GetData().Width, Settings::GetInstance()->GetData().Height); // Create sky mSky = new Sky(mDirect3D->GetDevice(), L"Data\\Textures\\SkyBox_Space.dds", 5000.0f); // Create shadow map mShadowMap = new ShadowMap(mDirect3D->GetDevice(), 2048, 2048); // Create frustum culling mFrustumCulling = new FrustumCulling(); //-------------------------------------------------------- // Compute scene bounding box //-------------------------------------------------------- // XMFLOAT3 minPt(+MathHelper::infinity, +MathHelper::infinity, +MathHelper::infinity); // XMFLOAT3 maxPt(-MathHelper::infinity, -MathHelper::infinity, -MathHelper::infinity); // // // Get vertex positions from all models // for (UINT i = 0; i < mGenericInstances.size(); ++i) // { // for (UINT j = 0; j < mGenericInstances[i].model->vertices.size(); ++j) // { // XMFLOAT3 vPos = mGenericInstances[i].model->vertices[j]->position; // // minPt.x = MathHelper::getMin(minPt.x, vPos.x); // minPt.y = MathHelper::getMin(minPt.x, vPos.x); // minPt.z = MathHelper::getMin(minPt.x, vPos.x); // // maxPt.x = MathHelper::getMax(maxPt.x, vPos.x); // maxPt.y = MathHelper::getMax(maxPt.x, vPos.x); // maxPt.z = MathHelper::getMax(maxPt.x, vPos.x); // } // } // // // Sphere center is at half of these new dimensions // mSceneBounds.Center = XMFLOAT3( 0.5f*(minPt.x + maxPt.x), // 0.5f*(minPt.y + maxPt.y), // 0.5f*(minPt.z + maxPt.z)); // // // Calculate the sphere radius // XMFLOAT3 extent(0.5f*(maxPt.x - minPt.x), // 0.5f*(maxPt.y - minPt.y), // 0.5f*(maxPt.z - minPt.z)); // // mSceneBounds.Radius = sqrtf(extent.x*extent.x + extent.y*extent.y + extent.z*extent.z); splash.Hide(); D3D11App::ShowWindow(); OnResize(); return true; }