From c2a117f4d1c80857b50004be0d0c7b4c07547ff9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Jan 2014 21:11:12 +0000 Subject: [PATCH] Fix mouse wheel event coordinates in wxFrame in wxMSW. The screen to client conversion for this event coordinates took the toolbar height into account twice, resulting in a wrong value if the event was handled in a frame that did have a toolbar. Closes #15812. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75563 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/window.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 225e13d531..21a5a71613 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -5606,9 +5606,15 @@ wxWindowMSW::HandleMouseWheel(wxMouseWheelAxis axis, // notice that WM_MOUSEWHEEL position is in screen coords (as it's // forwarded up to the parent by DefWindowProc()) and not in the client // ones as all the other messages, translate them to the client coords for - // consistency - const wxPoint - pt = ScreenToClient(wxPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); + // consistency -- but do it using Windows function and not our own one + // because InitMouseEvent() expects coordinates in Windows client + // coordinates and not wx ones (the difference being the height of the + // toolbar, if any). + POINT pt; + pt.x = GET_X_LPARAM(lParam); + pt.y = GET_Y_LPARAM(lParam); + ::ScreenToClient(GetHwnd(), &pt); + wxMouseEvent event(wxEVT_MOUSEWHEEL); InitMouseEvent(event, pt.x, pt.y, LOWORD(wParam)); event.m_wheelRotation = (short)HIWORD(wParam);