]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
remove HWND association when DestroyWindow
[wxWidgets.git] / src / msw / window.cpp
index 3f8c4085f70dc197b4611404d513ec03b8b82f91..b8533b3dfbb39aa5756764f3b536645a71e38725 100644 (file)
@@ -365,6 +365,10 @@ bool wxWindow::Enable(bool enable)
     if ( hWnd )
         ::EnableWindow(hWnd, (BOOL)enable);
 
+    // VZ: no, this is a bad idea: imagine that you have a dialog with some
+    //     disabled controls and disable it - you really wouldn't like the
+    //     disabled controls eb reenabled too when you reenable the dialog!
+#if 0
     wxWindowList::Node *node = GetChildren().GetFirst();
     while ( node )
     {
@@ -373,6 +377,7 @@ bool wxWindow::Enable(bool enable)
 
         node = node->GetNext();
     }
+#endif // 0
 
     return TRUE;
 }
@@ -2662,29 +2667,65 @@ bool wxWindow::HandleSetCursor(WXHWND hWnd,
                                int WXUNUSED(mouseMsg))
 {
     // the logic is as follows:
+    // -1. don't set cursor for non client area, including but not limited to
+    //     the title bar, scrollbars, &c
+    //  0. allow the user to override default behaviour by using EVT_SET_CURSOR
     //  1. if we have the cursor set it unless wxIsBusy()
     //  2. if we're a top level window, set some cursor anyhow
     //  3. if wxIsBusy(), set the busy cursor, otherwise the global one
 
+    if ( nHitTest != HTCLIENT )
+    {
+        return FALSE;
+    }
+
     HCURSOR hcursor = 0;
-    bool isBusy = wxIsBusy();
-    if ( m_cursor.Ok() )
+
+    // first ask the user code - it may wish to set the cursor in some very
+    // specific way (for example, depending on the current position)
+    POINT pt;
+    if ( !::GetCursorPos(&pt) )
     {
-        hcursor = GetHcursorOf(m_cursor);
+        wxLogLastError("GetCursorPos");
     }
 
-    if ( !GetParent() )
+    int x = pt.x,
+        y = pt.y;
+    ScreenToClient(&x, &y);
+    wxSetCursorEvent event(x, y);
+
+    bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event);
+    if ( processedEvtSetCursor && event.HasCursor() )
     {
-        if ( isBusy )
+        hcursor = GetHcursorOf(event.GetCursor());
+    }
+
+    if ( !hcursor )
+    {
+        bool isBusy = wxIsBusy();
+
+        // the test for processedEvtSetCursor is here to prevent using m_cursor
+        // if the user code caught EVT_SET_CURSOR() and returned nothing from
+        // it - this is a way to say that our cursor shouldn't be used for this
+        // point
+        if ( !processedEvtSetCursor && m_cursor.Ok() )
         {
-            hcursor = wxGetCurrentBusyCursor();
+            hcursor = GetHcursorOf(m_cursor);
         }
-        else if ( !hcursor )
+
+        if ( !GetParent() )
         {
-            const wxCursor *cursor = wxGetGlobalCursor();
-            if ( cursor && cursor->Ok() )
+            if ( isBusy )
             {
-                hcursor = GetHcursorOf(*cursor);
+                hcursor = wxGetCurrentBusyCursor();
+            }
+            else if ( !hcursor )
+            {
+                const wxCursor *cursor = wxGetGlobalCursor();
+                if ( cursor && cursor->Ok() )
+                {
+                    hcursor = GetHcursorOf(*cursor);
+                }
             }
         }
     }