X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/baccb514311d801fc4268e10bbccdb7f0b566522..7b9da2077d0975db6c965a85c91d5aca671ab5e3:/src/msw/spinctrl.cpp?ds=sidebyside diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 983181c466..d37468bbf0 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -33,6 +33,8 @@ #include "wx/wx.h" #endif +#if wxUSE_SPINCTRL + #if defined(__WIN95__) #include "wx/spinctrl.h" @@ -42,6 +44,8 @@ #include #endif +#include // for INT_MIN + // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- @@ -69,6 +73,7 @@ static const int MARGIN_BETWEEN = 1; bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, + const wxString& value, const wxPoint& pos, const wxSize& size, long style, @@ -149,9 +154,37 @@ bool wxSpinCtrl::Create(wxWindow *parent, // associate the text window with the spin button (void)::SendMessage(GetHwnd(), UDM_SETBUDDY, (WPARAM)m_hwndBuddy, 0); + if ( !value.IsEmpty() ) + { + SetValue(value); + } + return TRUE; } +// ---------------------------------------------------------------------------- +// wxTextCtrl-like methods +// ---------------------------------------------------------------------------- + +void wxSpinCtrl::SetValue(const wxString& text) +{ + if ( ::SetWindowText((HWND)m_hwndBuddy, text.c_str()) ) + { + wxLogLastError("SetWindowText(buddy)"); + } +} + +int wxSpinCtrl::GetValue() const +{ + wxString val = wxGetWindowText(m_hwndBuddy); + + long n; + if ( (wxSscanf(val, wxT("%lu"), &n) != 1) ) + n = INT_MIN; + + return n; +} + // ---------------------------------------------------------------------------- // when setting font, we need to do it for both controls // ---------------------------------------------------------------------------- @@ -214,3 +247,7 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height) } #endif // __WIN95__ + +#endif + // wxUSE_SPINCTRL +