X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bcdeea5a5b347dd2de201ca5f8c7b1f17e2b1034..e83c4d401206ff9d5568f03ade6d9713c57bdd51:/src/msw/spinctrl.cpp diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 7d79dc76d9..921d767fb0 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -298,6 +298,10 @@ bool wxSpinCtrl::Create(wxWindow *parent, WXDWORD exStyle = 0; WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ; + // Scroll text automatically if there is not enough space to show all of + // it, this is better than not allowing to enter more digits at all. + msStyle |= ES_AUTOHSCROLL; + // propagate text alignment style to text ctrl if ( style & wxALIGN_RIGHT ) msStyle |= ES_RIGHT; @@ -389,21 +393,25 @@ bool wxSpinCtrl::Create(wxWindow *parent, // associate the text window with the spin button (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0); + // If the initial text value is actually a number, it overrides the + // "initial" argument specified later. + long initialFromText; + if ( value.ToLong(&initialFromText) ) + initial = initialFromText; + SetValue(initial); + m_oldValue = initial; + // Set the range in the native control SetRange(min, max); + // Also set the text part of the control if it was specified independently + // but don't generate an event for this, it would be unexpected. + m_blockEvent = true; if ( !value.empty() ) - { SetValue(value); - m_oldValue = (int) wxAtol(value); - } - else - { - SetValue(wxString::Format(wxT("%d"), initial)); - m_oldValue = initial; - } + m_blockEvent = false; return true; } @@ -444,7 +452,7 @@ void wxSpinCtrl::SetValue(int val) // to leave it like this, while we really want to always show the // current value in the control, so do it manually ::SetWindowText(GetBuddyHwnd(), - wxString::Format(wxT("%d"), val).wx_str()); + wxString::Format(wxT("%d"), val).t_str()); } m_oldValue = GetValue(); @@ -603,7 +611,7 @@ void wxSpinCtrl::DoSetToolTip(wxToolTip *tip) wxSpinButton::DoSetToolTip(tip); if ( tip ) - tip->Add(m_hwndBuddy); + tip->AddOtherWindow(m_hwndBuddy); } #endif // wxUSE_TOOLTIPS