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;
// 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;
}
// 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();
wxSpinButton::DoSetToolTip(tip);
if ( tip )
- tip->Add(m_hwndBuddy);
+ tip->AddOtherWindow(m_hwndBuddy);
}
#endif // wxUSE_TOOLTIPS