]> git.saurik.com Git - wxWidgets.git/commitdiff
SetCursor() doesn't set cursor for children of the window any more
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 28 Feb 1999 14:16:33 +0000 (14:16 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 28 Feb 1999 14:16:33 +0000 (14:16 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1827 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/window.tex
src/msw/window.cpp

index b5bc55cf75c4442f476e503b14a5f2aba8815ece..e26756621098750603cad501fd8d403ac3859352 100644 (file)
@@ -1685,10 +1685,9 @@ implements the following methods:\par
 
 \func{virtual void}{SetCursor}{\param{const wxCursor\&}{cursor}}
 
-Sets the window's cursor. Notice that setting the cursor for this window also
-sets it for all the children of the window unless they have their own cursor
-(either explicitly set with the same function, or, in the case of Windows, a
-standard one for some of standard controls).
+Sets the window's cursor. Notice that setting the cursor for this window does
+not set it for its children so you'll need to explicitly call SetCursor() for
+them too if you need it.
 
 \wxheading{Parameters}
 
index 750f5c7c53093f0e67eab2e59cb7348ce9ad7cab..a3e3a9d72794b7586186cbee77617651b5134ea1 100644 (file)
@@ -1500,45 +1500,54 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
 
     case WM_SETCURSOR:
         {
-            // don't set cursor when the mouse is not in the client part
-            short nHitTest = LOWORD(lParam);
-            if ( nHitTest == HTCLIENT || nHitTest == HTERROR )
+            // don't set cursor for other windows, only for this one: this
+            // prevents children of this window from gettign the same cursor
+            // as the parent has (don't forget that this message is propagated
+            // by default up the window parent-child hierarchy)
+            if ( (HWND)wParam == hWnd )
             {
-                HCURSOR hcursor = 0;
-                if ( wxIsBusy() )
+                // don't set cursor when the mouse is not in the client part
+                short nHitTest = LOWORD(lParam);
+                if ( nHitTest == HTCLIENT || nHitTest == HTERROR )
                 {
-                    extern HCURSOR gs_wxBusyCursor; // from msw\utils.cpp
-
-                    hcursor = gs_wxBusyCursor;
-                }
-                else
-                {
-                    wxCursor *cursor = NULL;
-
-                    if ( m_windowCursor.Ok() )
+                    HCURSOR hcursor = 0;
+                    if ( wxIsBusy() )
                     {
-                        cursor = &m_windowCursor;
+                        // from msw\utils.cpp
+                        extern HCURSOR gs_wxBusyCursor;
+
+                        hcursor = gs_wxBusyCursor;
                     }
                     else
                     {
-                        extern wxCursor *g_globalCursor; // from msw\data.cpp
+                        wxCursor *cursor = NULL;
 
-                        if ( g_globalCursor && g_globalCursor->Ok() )
-                            cursor = g_globalCursor;
-                    }
+                        if ( m_windowCursor.Ok() )
+                        {
+                            cursor = &m_windowCursor;
+                        }
+                        else
+                        {
+                            // from msw\data.cpp
+                            extern wxCursor *g_globalCursor;
 
-                    if ( cursor )
-                        hcursor = (HCURSOR)cursor->GetHCURSOR();
-                }
+                            if ( g_globalCursor && g_globalCursor->Ok() )
+                                cursor = g_globalCursor;
+                        }
 
-                if ( hcursor )
-                {
-                    ::SetCursor(hcursor);
+                        if ( cursor )
+                            hcursor = (HCURSOR)cursor->GetHCURSOR();
+                    }
 
-                    // returning TRUE stops the DefWindowProc() from further
-                    // processing this message - exactly what we need because we've
-                    // just set the cursor.
-                    return TRUE;
+                    if ( hcursor )
+                    {
+                        ::SetCursor(hcursor);
+
+                        // returning TRUE stops the DefWindowProc() from
+                        // further processing this message - exactly what we
+                        // need because we've just set the cursor.
+                        return TRUE;
+                    }
                 }
             }
         }