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
This commit is contained in:
@@ -232,7 +232,7 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wxSpinButton::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
|
bool wxSpinButton::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
|
||||||
WXWORD pos, WXHWND control)
|
WXWORD WXUNUSED(pos), WXHWND control)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( control, false, wxT("scrolling what?") );
|
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);
|
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);
|
event.SetEventObject(this);
|
||||||
|
|
||||||
return HandleWindowEvent(event);
|
return HandleWindowEvent(event);
|
||||||
|
@@ -640,7 +640,7 @@ void wxSpinCtrl::SendSpinUpdate(int value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool wxSpinCtrl::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
|
bool wxSpinCtrl::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
|
||||||
WXWORD pos, WXHWND control)
|
WXWORD WXUNUSED(pos), WXHWND control)
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( control, false, wxT("scrolling what?") );
|
wxCHECK_MSG( control, false, wxT("scrolling what?") );
|
||||||
|
|
||||||
@@ -650,11 +650,13 @@ bool wxSpinCtrl::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
|
|||||||
return false;
|
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)
|
if (m_oldValue != new_value)
|
||||||
SendSpinUpdate( new_value );
|
SendSpinUpdate( new_value );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSpinCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *result)
|
bool wxSpinCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *result)
|
||||||
|
Reference in New Issue
Block a user