Check for range on wxSpinCtrl and wxSpinButton's GetValue()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31165 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -220,16 +220,22 @@ wxSize wxSpinButton::DoGetBestSize() const
|
|||||||
|
|
||||||
int wxSpinButton::GetValue() const
|
int wxSpinButton::GetValue() const
|
||||||
{
|
{
|
||||||
|
int n;
|
||||||
#ifdef UDM_GETPOS32
|
#ifdef UDM_GETPOS32
|
||||||
if ( wxTheApp->GetComCtl32Version() >= 580 )
|
if ( wxTheApp->GetComCtl32Version() >= 580 )
|
||||||
{
|
{
|
||||||
// use the full 32 bit range if available
|
// use the full 32 bit range if available
|
||||||
return ::SendMessage(GetHwnd(), UDM_GETPOS32, 0, 0);
|
n = ::SendMessage(GetHwnd(), UDM_GETPOS32, 0, 0);
|
||||||
}
|
}
|
||||||
#endif // UDM_GETPOS32
|
#endif // UDM_GETPOS32
|
||||||
|
|
||||||
// we're limited to 16 bit
|
// we're limited to 16 bit
|
||||||
return (short)LOWORD(::SendMessage(GetHwnd(), UDM_GETPOS, 0, 0));
|
n = (short)LOWORD(::SendMessage(GetHwnd(), UDM_GETPOS, 0, 0));
|
||||||
|
|
||||||
|
if (n < m_min) n = m_min;
|
||||||
|
if (n > m_max) n = m_max;
|
||||||
|
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinButton::SetValue(int val)
|
void wxSpinButton::SetValue(int val)
|
||||||
|
@@ -436,6 +436,9 @@ int wxSpinCtrl::GetValue() const
|
|||||||
long n;
|
long n;
|
||||||
if ( (wxSscanf(val, wxT("%lu"), &n) != 1) )
|
if ( (wxSscanf(val, wxT("%lu"), &n) != 1) )
|
||||||
n = INT_MIN;
|
n = INT_MIN;
|
||||||
|
|
||||||
|
if (n < m_min) n = m_min;
|
||||||
|
if (n > m_max) n = m_max;
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user