+ // sanity check
+ wxASSERT_MSG( pSpin->m_hWndBuddy == hWndBuddy,
+ _T("wxSpinCtrl has incorrect buddy HWND!") );
+
+ return pSpin;
+} // end of wxSpinCtrl::GetSpinForTextCtrl
+
+int wxSpinCtrl::GetValue() const
+{
+ long lVal = 0L;
+ char zVal[10];
+
+ ::WinSendMsg( GetHwnd()
+ ,SPBM_QUERYVALUE
+ ,MPFROMP(zVal)
+ ,MPFROM2SHORT( (USHORT)10
+ ,SPBQ_UPDATEIFVALID
+ )
+ );
+ lVal - atol(zVal);
+ return lVal;
+} // end of wxSpinCtrl::GetValue
+
+void wxSpinCtrl::OnChar (
+ wxKeyEvent& rEvent
+)
+{
+ switch (rEvent.KeyCode())
+ {
+ case WXK_RETURN:
+ {
+ wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_ENTER
+ ,m_windowId
+ );
+ wxString sVal = wxGetWindowText(m_hWndBuddy);
+
+ InitCommandEvent(vEvent);
+ vEvent.SetString((char*)sVal.c_str());
+ vEvent.SetInt(GetValue());
+ if (GetEventHandler()->ProcessEvent(vEvent))
+ return;
+ break;
+ }
+
+ case WXK_TAB:
+ //
+ // Always produce navigation event - even if we process TAB
+ // ourselves the fact that we got here means that the user code
+ // decided to skip processing of this TAB - probably to let it
+ // do its default job.
+ //
+ {
+ wxNavigationKeyEvent vEventNav;
+
+ vEventNav.SetDirection(!rEvent.ShiftDown());
+ vEventNav.SetWindowChange(rEvent.ControlDown());
+ vEventNav.SetEventObject(this);
+ if (GetParent()->GetEventHandler()->ProcessEvent(vEventNav))
+ return;
+ }
+ break;
+ }
+
+ //
+ // No, we didn't process it
+ //
+ rEvent.Skip();
+} // end of wxSpinCtrl::OnChar
+
+void wxSpinCtrl::OnSpinChange(
+ wxSpinEvent& rEventSpin
+)
+{
+ wxCommandEvent vEvent( wxEVT_COMMAND_SPINCTRL_UPDATED
+ ,GetId()
+ );
+
+ vEvent.SetEventObject(this);
+ vEvent.SetInt(rEventSpin.GetPosition());
+ (void)GetEventHandler()->ProcessEvent(vEvent);
+ if (rEventSpin.GetSkipped())
+ {
+ vEvent.Skip();
+ }
+} // end of wxSpinCtrl::OnSpinChange