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)