123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include "stdafx2.h"
- #include "resource.h"
- #include "MainFrm.h"
- CAppModule _Module;
- int WINAPI gui_entry(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow, HWND *phWnd, IConsole *pConsole)
- {
- HRESULT hRes = ::CoInitialize(NULL);
- // If you are running on NT 4.0 or higher you can use the following call instead to
- // make the EXE free threaded. This means that calls come in on a random RPC thread.
- // HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
- ATLASSERT(SUCCEEDED(hRes));
- // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
- ::DefWindowProc(NULL, 0, 0, 0L);
- AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES); // add flags to support other controls
- hRes = _Module.Init(NULL, hInstance);
- ATLASSERT(SUCCEEDED(hRes));
- ATL::AtlAxWinInit();
- CMessageLoop theLoop;
- _Module.AddMessageLoop(&theLoop);
- CMainFrame wndMain(pConsole);
- pConsole->Initialize();
- if(wndMain.CreateEx() == NULL)
- {
- ATLTRACE(_T("Main window creation failed!\n"));
- return -1;
- }
- if (phWnd) {
- *phWnd = wndMain.m_hWnd;
- }
- pConsole->OnStartRead(TRUE);
- wndMain.ShowWindow(nCmdShow);
- int nRet = theLoop.Run();
- _Module.RemoveMessageLoop();
- _Module.Term();
- ::CoUninitialize();
- pConsole->UnInitialize();
- pConsole->OnStopReady();
- return nRet;
- }
|