From 932324990328613e69526cb88e587de4024061c3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 10 Aug 2006 00:44:44 +0000 Subject: [PATCH] fixes for SetRange(): ensure that the value is valid for the new range; update the visible state of the spin arrows when range becomes [in]valid git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40541 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/spinbutt.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index ce9c6ed32f..43141278d6 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -258,6 +258,8 @@ void wxSpinButton::SetValue(int val) void wxSpinButton::SetRange(int minVal, int maxVal) { + const bool hadRange = m_min < m_max; + wxSpinButtonBase::SetRange(minVal, maxVal); #ifdef UDM_SETRANGE32 @@ -272,6 +274,18 @@ void wxSpinButton::SetRange(int minVal, int maxVal) ::SendMessage(GetHwnd(), UDM_SETRANGE, 0, (LPARAM) MAKELONG((short)maxVal, (short)minVal)); } + + // the current value might be out of the new range, force it to be in it + NormalizeValue(); + + // if range was valid but becomes degenerated (min == max) now or vice + // versa then the spin buttons are automatically disabled/enabled back + // but don't update themselves for some reason, so do it manually + if ( hadRange != (m_min < m_max) ) + { + // update the visual state of the button + Refresh(); + } } bool wxSpinButton::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam, -- 2.47.2