X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a02b2a9d31b9ebc9cb13e0ea744169bc355e2ea0..7447d53c35249d42128d6243c90998f03882859a:/src/msw/spinctrl.cpp?ds=sidebyside diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 7919453f85..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,22 +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); - // If necessary, set the textual value. Don't do it if it's the same as the - // numeric value though. - if ( value != wxString::Format("%d", initial) ) - { + // 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 - { - m_oldValue = initial; - } + m_blockEvent = false; return true; } @@ -445,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(); @@ -604,7 +611,7 @@ void wxSpinCtrl::DoSetToolTip(wxToolTip *tip) wxSpinButton::DoSetToolTip(tip); if ( tip ) - tip->Add(m_hwndBuddy); + tip->AddOtherWindow(m_hwndBuddy); } #endif // wxUSE_TOOLTIPS