+ if (i == wxNOT_FOUND)
+ return NULL;
+
+ // 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 (int)lVal;
+} // end of wxSpinCtrl::GetValue
+
+void wxSpinCtrl::OnChar (
+ wxKeyEvent& rEvent
+)
+{
+ switch (rEvent.GetKeyCode())
+ {
+ 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
+
+void wxSpinCtrl::OnSetFocus (
+ wxFocusEvent& rEvent
+)
+{
+ //
+ // When we get focus, give it to our buddy window as it needs it more than
+ // we do
+ //
+ ::WinSetFocus(HWND_DESKTOP, (HWND)m_hWndBuddy);
+ rEvent.Skip();
+} // end of wxSpinCtrl::OnSetFocus
+
+bool wxSpinCtrl::ProcessTextCommand(
+ WXWORD wCmd
+, WXWORD wId
+)
+{
+ switch (wCmd)
+ {
+ case SPBN_CHANGE:
+ {
+ wxCommandEvent vEvent( wxEVT_COMMAND_TEXT_UPDATED
+ ,GetId()
+ );
+ vEvent.SetEventObject(this);
+
+ wxString sVal = wxGetWindowText(m_hWndBuddy);
+
+ vEvent.SetString((char*)sVal.c_str());
+ vEvent.SetInt(GetValue());
+ return (GetEventHandler()->ProcessEvent(vEvent));
+ }
+
+ case SPBN_SETFOCUS:
+ case SPBN_KILLFOCUS:
+ {
+ wxFocusEvent vEvent( wCmd == EN_KILLFOCUS ? wxEVT_KILL_FOCUS : wxEVT_SET_FOCUS
+ ,m_windowId
+ );
+
+ vEvent.SetEventObject(this);
+ return(GetEventHandler()->ProcessEvent(vEvent));
+ }
+ default:
+ break;
+ }
+
+ //
+ // Not processed
+ //