X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ed3d6ace492c5d54680a2c6fba746b8abd7f7b4e..69659fd770f615210efac4b4fa741b3ad6223616:/src/msw/spinbutt.cpp diff --git a/src/msw/spinbutt.cpp b/src/msw/spinbutt.cpp index ce9c6ed32f..4b3f25570c 100644 --- a/src/msw/spinbutt.cpp +++ b/src/msw/spinbutt.cpp @@ -25,6 +25,7 @@ #endif #ifndef WX_PRECOMP + #include "wx/msw/wrapcctl.h" // include "properly" #include "wx/app.h" #endif @@ -35,7 +36,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent) #include "wx/msw/private.h" -#include "wx/msw/wrapcctl.h" #ifndef UDM_SETRANGE32 #define UDM_SETRANGE32 (WM_USER+111) @@ -195,7 +195,7 @@ bool wxSpinButton::Create(wxWindow *parent, SubclassWin(m_hWnd); - SetBestSize(size); + SetInitialSize(size); return true; } @@ -256,8 +256,15 @@ void wxSpinButton::SetValue(int val) } } +void wxSpinButton::NormalizeValue() +{ + SetValue( GetValue() ); +} + void wxSpinButton::SetRange(int minVal, int maxVal) { + const bool hadRange = m_min < m_max; + wxSpinButtonBase::SetRange(minVal, maxVal); #ifdef UDM_SETRANGE32 @@ -272,6 +279,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,