From 1acbfd013d06de1a1baa8bb09b33d0e362f32534 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 11 May 2010 10:39:42 +0000 Subject: [PATCH] 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 --- src/msw/window.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) 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; } -- 2.47.2