X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/289532452089421ddadbd4726a8469511a19ab76..96c9640205933ad0673d5af2c96af0816c50160c:/src/msw/spinctrl.cpp diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index 19e302e6d4..0017413e0a 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -119,11 +119,21 @@ LRESULT APIENTRY _EXPORT wxBuddyTextWndProc(HWND hwnd, // is clicked with the "?" cursor case WM_HELP: #endif - spin->MSWWindowProc(message, wParam, lParam); - - // The control may have been deleted at this point, so check. - if ( !::IsWindow(hwnd) ) - return 0; + { + WXLRESULT result; + if ( spin->MSWHandleMessage(&result, message, wParam, lParam) ) + { + // Do not let the message be processed by the window proc + // of the text control if it had been already handled at wx + // level, this is consistent with what happens for normal, + // non-composite controls. + return 0; + } + + // The control may have been deleted at this point, so check. + if ( !::IsWindow(hwnd) ) + return 0; + } break; case WM_GETDLGCODE: @@ -254,6 +264,14 @@ void wxSpinCtrl::NormalizeValue() // construction // ---------------------------------------------------------------------------- +void wxSpinCtrl::Init() +{ + m_blockEvent = false; + m_hwndBuddy = NULL; + m_wndProcBuddy = NULL; + m_oldValue = INT_MIN; +} + bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, const wxString& value, @@ -263,13 +281,6 @@ bool wxSpinCtrl::Create(wxWindow *parent, int min, int max, int initial, const wxString& name) { - m_blockEvent = false; - - // this should be in ctor/init function but I don't want to add one to 2.8 - // to avoid problems with default ctor which can be inlined in the user - // code and so might not get this fix without recompilation - m_oldValue = INT_MIN; - // before using DoGetBestSize(), have to set style to let the base class // know whether this is a horizontal or vertical control (we're always // vertical) @@ -287,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; @@ -378,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; } @@ -592,7 +611,7 @@ void wxSpinCtrl::DoSetToolTip(wxToolTip *tip) wxSpinButton::DoSetToolTip(tip); if ( tip ) - tip->Add(m_hwndBuddy); + tip->AddOtherWindow(m_hwndBuddy); } #endif // wxUSE_TOOLTIPS