From ad8ddd139179075f578c50ae1816d236cf86455d Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 28 Dec 2004 15:57:43 +0000 Subject: [PATCH] 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 --- src/msw/spinbutt.cpp | 10 ++++++++-- src/msw/spinctrl.cpp | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index 81857170d4..6e1ae0e4e5 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -220,16 +220,22 @@ wxSize wxSpinButton::DoGetBestSize() const int wxSpinButton::GetValue() const { + int n; #ifdef UDM_GETPOS32 if ( wxTheApp->GetComCtl32Version() >= 580 ) { // 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 // 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) diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index a88446e8c6..283d9fe0e3 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -436,6 +436,9 @@ int wxSpinCtrl::GetValue() const long n; if ( (wxSscanf(val, wxT("%lu"), &n) != 1) ) n = INT_MIN; + + if (n < m_min) n = m_min; + if (n > m_max) n = m_max; return n; } -- 2.45.2