From: Vadim Zeitlin Date: Thu, 30 Aug 2012 20:23:03 +0000 (+0000) Subject: Fix position carried in wxSpin{Button,Ctrl} events for 32 bit values in wxMSW. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/63420bcccff426d195acaad19778465d87e43d62 Fix position carried in wxSpin{Button,Ctrl} events for 32 bit values in wxMSW. Don't use WM_VSCROLL message parameter as the position because it's a 16 bit value and is not enough for the spin controls using 32 bit range. Just use the current value available from the control itself instead. This fixes assert failures in the spin page of the widgets sample when changing the value of a control when it is > SHRT_MAX. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index 6d6f93e5b5..bea1fd143b 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -232,7 +232,7 @@ void wxSpinButton::SetRange(int minVal, int maxVal) } bool wxSpinButton::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, - WXWORD pos, WXHWND control) + WXWORD WXUNUSED(pos), WXHWND control) { wxCHECK_MSG( control, false, wxT("scrolling what?") ); @@ -243,7 +243,9 @@ bool wxSpinButton::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, } wxSpinEvent event(wxEVT_SCROLL_THUMBTRACK, m_windowId); - event.SetPosition((short)pos); // cast is important for negative values! + // We can't use 16 bit position provided in this message for spin buttons + // using 32 bit range. + event.SetPosition(GetValue()); event.SetEventObject(this); return HandleWindowEvent(event); diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 94baaf3809..95c63204e0 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -640,7 +640,7 @@ void wxSpinCtrl::SendSpinUpdate(int value) } bool wxSpinCtrl::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, - WXWORD pos, WXHWND control) + WXWORD WXUNUSED(pos), WXHWND control) { wxCHECK_MSG( control, false, wxT("scrolling what?") ); @@ -650,11 +650,13 @@ bool wxSpinCtrl::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, return false; } - int new_value = (short) pos; + // Notice that we can't use "pos" from WM_VSCROLL as it is 16 bit and we + // might be using 32 bit range. + int new_value = GetValue(); if (m_oldValue != new_value) SendSpinUpdate( new_value ); - return TRUE; + return true; } bool wxSpinCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *result)