]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/spinctrl.cpp
adding missing cast
[wxWidgets.git] / src / msw / spinctrl.cpp
index 73fb437fc071edef1f39925c6f800dd5746995c2..05965d0c3d7d377a6b7df701ca19c5238a36aa6c 100644 (file)
@@ -114,10 +114,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
 
 BEGIN_EVENT_TABLE(wxSpinCtrl, wxSpinButton)
     EVT_CHAR(wxSpinCtrl::OnChar)
-
     EVT_SET_FOCUS(wxSpinCtrl::OnSetFocus)
     EVT_KILL_FOCUS(wxSpinCtrl::OnKillFocus)
-    EVT_SPIN(wxID_ANY, wxSpinCtrl::OnSpinChange)
 END_EVENT_TABLE()
 
 #define GetBuddyHwnd()      (HWND)(m_hwndBuddy)
@@ -177,8 +175,20 @@ LRESULT APIENTRY _EXPORT wxBuddyTextWndProc(HWND hwnd,
             break;
 
         case WM_GETDLGCODE:
-            // we want to get WXK_RETURN in order to generate the event for it
-            return DLGC_WANTALLKEYS;
+            if ( spin->HasFlag(wxTE_PROCESS_ENTER) )
+            {
+                long dlgCode = ::CallWindowProc
+                                 (
+                                    CASTWNDPROC spin->GetBuddyWndProc(),
+                                    hwnd,
+                                    message,
+                                    wParam,
+                                    lParam
+                                 );
+                dlgCode |= DLGC_WANTMESSAGE;
+                return dlgCode;
+            }
+            break;
     }
 
     return ::CallWindowProc(CASTWNDPROC spin->GetBuddyWndProc(),
@@ -627,15 +637,37 @@ void wxSpinCtrl::SendSpinUpdate(int value)
     m_oldValue = value;
 }
 
-void wxSpinCtrl::OnSpinChange(wxSpinEvent& eventSpin)
+bool wxSpinCtrl::MSWOnScroll(int WXUNUSED(orientation), WXWORD wParam,
+                               WXWORD pos, WXHWND control)
 {
-    const int value = eventSpin.GetPosition();
-    if ( value != m_oldValue )
+    wxCHECK_MSG( control, false, wxT("scrolling what?") );
+
+    if ( wParam != SB_THUMBPOSITION )
     {
-        SendSpinUpdate(value);
+        // probable SB_ENDSCROLL - we don't react to it
+        return false;
     }
+
+    int new_value = (short) pos;
+    if (m_oldValue != new_value)
+       SendSpinUpdate( new_value );
+
+    return TRUE;
 }
 
+bool wxSpinCtrl::MSWOnNotify(int WXUNUSED(idCtrl), WXLPARAM lParam, WXLPARAM *result)
+{
+    NM_UPDOWN *lpnmud = (NM_UPDOWN *)lParam;
+
+    if (lpnmud->hdr.hwndFrom != GetHwnd()) // make sure it is the right control
+        return false;
+
+    *result = 0;  // never reject UP and DOWN events
+
+    return TRUE;
+}
+
+
 // ----------------------------------------------------------------------------
 // size calculations
 // ----------------------------------------------------------------------------