Преглед изворни кода

mouse wheel over window crash for i saw on martins computer

sabrogden пре 8 година
родитељ
комит
b5dbe1283b
1 измењених фајлова са 13 додато и 2 уклоњено
  1. 13 2
      MainFrm.cpp

+ 13 - 2
MainFrm.cpp

@@ -825,11 +825,22 @@ BOOL CMainFrame::PreTranslateMessage(MSG *pMsg)
 {
 	//forward the mouse wheel onto the window under the cursor
 	//normally windows only sends it to the window with focus, bypass this
-	if (pMsg->message == WM_MOUSEWHEEL)
+	if (pMsg->message == WM_MOUSEWHEEL &&
+		::GetCapture() == nullptr)
 	{
 		POINT mouse;
 		GetCursorPos(&mouse);
-		pMsg->hwnd = ::WindowFromPoint(mouse);
+		HWND hwndFromPoint = ::WindowFromPoint(mouse);
+
+		if (pMsg->hwnd != hwndFromPoint)
+		{
+			DWORD winProcessId = 0;
+			::GetWindowThreadProcessId(hwndFromPoint, &winProcessId);
+			if (winProcessId == ::GetCurrentProcessId()) //no-fail!
+			{
+				pMsg->hwnd = hwndFromPoint;
+			}
+		}
 	}
 
     return CFrameWnd::PreTranslateMessage(pMsg);