]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix position for wxKeyEvents in wxMSW.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 11 May 2010 10:39:42 +0000 (10:39 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 11 May 2010 10:39:42 +0000 (10:39 +0000)
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

src/msw/window.cpp

index baf0318950fe7043e748b2d5510d5b0a711dbbd7..b74739669998bf012430bc93ef33da61c7fa8bb2 100644 (file)
@@ -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;
 }