From 3afada92ed266e0b0d1f96b4b9e838782c959c17 Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 10 Sep 2010 19:39:54 +0000 Subject: [PATCH] Fixed the message loop to valid code. (http://msdn.microsoft.com/en-us/library/ms644936.aspx) --- Application/Application.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Application/Application.cpp b/Application/Application.cpp index f6b775ca..2a5a6e65 100644 --- a/Application/Application.cpp +++ b/Application/Application.cpp @@ -66,6 +66,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd { HANDLE hMutex = NULL; MSG msg; + BOOL bRet; HWND hWnd; _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); @@ -120,10 +121,18 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd initModuleEx(hWnd, module, NULL); // Run the standard window message loop - while(GetMessage(&msg, NULL, 0, 0)) + while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0) { - TranslateMessage(&msg); - DispatchMessage(&msg); + if (bRet == -1) // error + { + quitModule(NULL); + break; + } + else + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } } if (hMutex) ReleaseMutex(hMutex);