|
楼主 |
发表于 2008-9-18 23:38:39
|
显示全部楼层
一个ACE的事件循环、一个Windows的消息循环,不冲突了吗?
以WTL写GUI为例,它已经有个Run循环了,把Reactor的事件循环加在哪里呢?
代码如下:
========================================================
CAppModule _Module;
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
CMessageLoop theLoop;
_Module.AddMessageLoop(&theLoop);
CMainFrame wndMain;
RECT rc = {0, 0, 350, 135};
if(wndMain.CreateEx(NULL, &rc) == NULL)
{
ATLTRACE(_T("Main window creation failed!\n"));
return 0;
}
wndMain.CenterWindow();
wndMain.ShowWindow(nCmdShow);
int nRet = theLoop.Run();
_Module.RemoveMessageLoop();
return nRet;
}
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
LPTSTR lpstrCmdLine, int nCmdShow)
{
HRESULT hRes = ::CoInitialize(NULL);
ATLASSERT(SUCCEEDED(hRes));
::DefWindowProc(NULL, 0, 0, 0L);
AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other
controls
hRes = _Module.Init(NULL, hInstance);
ATLASSERT(SUCCEEDED(hRes));
int nRet = Run(lpstrCmdLine, nCmdShow);
_Module.Term();
::CoUninitialize();
return nRet;
} |
|