int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int show) { MainDialog dlg; WTL::CMessageLoop loop; int ret = 1; CoInitialize(NULL); _Module.Init(NULL, hinst); _Module.AddMessageLoop(&loop); if(dlg.Create(NULL)) { dlg.ShowWindow(show); ret = loop.Run(); } _Module.RemoveMessageLoop(); _Module.Term(); CoUninitialize(); return ret; }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); ImmDisableIME(-1); // 检查单例,并通知旧程序 HANDLE mutex = ::CreateMutex(NULL, TRUE, repeat_run); if (::GetLastError() == ERROR_ALREADY_EXISTS) { UINT WM_REPEAT_RUN = ::RegisterWindowMessage(repeat_run); ::PostMessage(HWND_BROADCAST, WM_REPEAT_RUN, 0, 0); ::CloseHandle(mutex); return 0; } InitializeVirtualDesktopManagerInternal(); // 加载lua引擎 lua_engine = new LuaEngine(); // 加载配置 Config::Init(); // 启动程序 Window wnd; if (!wnd.Create(NULL, CRect(0, 0, 400, 400), app_name, WS_CAPTION)) { return 0; } // wnd.ShowWindow(nCmdShow); // 消息循环 WTL::CMessageLoop msgLoop; int ret = msgLoop.Run(); delete lua_engine; return ret; }
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) { WTL::CMessageLoop theLoop; _Module.AddMessageLoop(&theLoop); CMainFrame wndMain; if(wndMain.CreateEx() == NULL) { ATLTRACE(_T("Main window creation failed!\n")); return 0; } wndMain.ShowWindow(nCmdShow); int nRet = theLoop.Run(); _Module.RemoveMessageLoop(); return nRet; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { CoInitialize(NULL); ULONG_PTR token; { Gdiplus::GdiplusStartupInput gdisi; Gdiplus::Status s = Gdiplus::GdiplusStartup(&token, &gdisi, NULL); ATLTRACE("GDI+ init returned %d\n", s); } CAnimatedAlphaWindow wnd; wnd.Initialize(); wnd.Create(NULL); wnd.ShowWindow(SW_SHOW); WTL::CMessageLoop loop; return loop.Run(); }