From 94ba85cf0fc6bdf02ba3bd244a02e35a8a7e15a5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 5 Jan 2014 21:10:17 +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/branches/WX_3_0_BRANCH@75559 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/window.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index f15e9ae7ab..2e93e4320a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -604,6 +604,7 @@ wxMSW: - Make "%lu" work with size_t arguments under Win64 (laro). - Fix wxRegion::Offset() with shared objects (Joost Nieuwenhuijse). - Fix wxSocket::Initialize() after Shutdown() (Laurent Poujoulat). +- Fix coordinates of EVT_MOUSEWHEEL in frames with toolbars (LtJax). wxOSX: 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);