Fixing ambiguous closed window determining situation.

"offenso" <[email protected]> Fri, 19 Jul 2013 11:16:46 -0000
Newsgroups gmane.comp.windows.wtl
Message-ID <[email protected]>
===Commit message

Make CMessageLoop::Run multithread/multiwindow compatible. If user need he could call this method with extra HWND parameter, for filtering messages.
Purpose:
It helps solve ambiguous window exit situation.
Example:
By calling obj.Run(30), we know what window closed exactly on function return. (The window has HWND 30).

===Commit diff
Index: S:/documents/WTL/wtl/include/atlapp.h
===================================================================
--- S:/documents/WTL/wtl/include/atlapp.h	(revision 467)
+++ S:/documents/WTL/wtl/include/atlapp.h	(working copy)
@@ -1136,7 +1136,7 @@
 #endif // !_ATL_NO_OLD_NAMES
 
 // message loop
-	int Run()
+	int Run(const ::HWND hwnd = NULL)
 	{
 		BOOL bDoIdle = TRUE;
 		int nIdleCount = 0;
@@ -1144,13 +1144,13 @@
 
 		for(;;)
 		{
-			while(bDoIdle && !::PeekMessage(&m_msg, NULL, 0, 0, PM_NOREMOVE))
+			while(bDoIdle && !::PeekMessage(&m_msg, hwnd, 0, 0, PM_NOREMOVE))
 			{
 				if(!OnIdle(nIdleCount++))
 					bDoIdle = FALSE;
 			}
 
-			bRet = ::GetMessage(&m_msg, NULL, 0, 0);
+			bRet = ::GetMessage(&m_msg, hwnd, 0, 0);
 
 			if(bRet == -1)
 			{