From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Tue, 11 May 2010 10:39:42 +0000 (+0000)
Subject: Fix position for wxKeyEvents in wxMSW.
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/1acbfd013d06de1a1baa8bb09b33d0e362f32534

Fix position for wxKeyEvents in wxMSW.

Use ScreenToClient() instead of painstakingly (and incorrectly) transforming
the position in this function itself.

Closes #12024.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64286 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/msw/window.cpp b/src/msw/window.cpp
index baf0318950..b747396699 100644
--- a/src/msw/window.cpp
+++ b/src/msw/window.cpp
@@ -5619,20 +5619,10 @@ wxKeyEvent wxWindowMSW::CreateKeyEvent(wxEventType evType,
     event.SetTimestamp(::GetMessageTime());
 #endif
 
-    // translate the position to client coords
-    POINT pt;
-#ifdef __WXWINCE__
-    GetCursorPosWinCE(&pt);
-#else
-    GetCursorPos(&pt);
-#endif
-    RECT rect;
-    GetWindowRect(GetHwnd(),&rect);
-    pt.x -= rect.left;
-    pt.y -= rect.top;
-
-    event.m_x = pt.x;
-    event.m_y = pt.y;
+    // translate the position to client coordinates
+    const wxPoint mousePos = ScreenToClient(wxGetMousePosition());
+    event.m_x = mousePos.x;
+    event.m_y = mousePos.y;
 
     return event;
 }