]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
failed attempt to change the default action for GTK dnd (nothing changed finally)
[wxWidgets.git] / src / msw / window.cpp
index b3a276a34a3967c3fd63985e7fbefd4eef8e4734..27298fab610a257fb17434e735ce75a0dc3b557f 100644 (file)
@@ -131,7 +131,6 @@ extern MSG s_currentMsg;
 wxMenu *wxCurrentPopupMenu = NULL;
 #endif // wxUSE_MENUS_NATIVE
 
-extern wxList WXDLLEXPORT wxPendingDelete;
 extern const wxChar *wxCanvasClassName;
 
 // ---------------------------------------------------------------------------
@@ -770,6 +769,15 @@ int wxWindowMSW::GetScrollPage(int orient) const
 
 #endif // WXWIN_COMPATIBILITY
 
+inline int GetScrollPosition(HWND hWnd, int wOrient)
+{
+#ifdef __WXMICROWIN__
+    return ::GetScrollPosWX(hWnd, wOrient);
+#else
+    return ::GetScrollPos(hWnd, wOrient);
+#endif
+}
+
 int wxWindowMSW::GetScrollPos(int orient) const
 {
     int wOrient;
@@ -777,17 +785,11 @@ int wxWindowMSW::GetScrollPos(int orient) const
         wOrient = SB_HORZ;
     else
         wOrient = SB_VERT;
+
     HWND hWnd = GetHwnd();
-    if ( hWnd )
-    {
-#ifdef __WXMICROWIN__
-        return ::GetScrollPosWX(hWnd, wOrient);
-#else
-        return ::GetScrollPos(hWnd, wOrient);
-#endif
-    }
-    else
-        return 0;
+    wxCHECK_MSG( hWnd, 0, _T("no HWND in GetScrollPos") );
+
+    return GetScrollPosition(hWnd, wOrient);
 }
 
 // This now returns the whole range, not just the number
@@ -940,30 +942,44 @@ void wxWindowMSW::ScrollWindow(int dx, int dy, const wxRect *prect)
     ::ScrollWindow(GetHwnd(), dx, dy, prect ? &rect : NULL, NULL);
 }
 
-static void ScrollVertically(HWND hwnd, int kind, int count)
+static bool ScrollVertically(HWND hwnd, int kind, int count)
 {
+    int posStart = GetScrollPosition(hwnd, SB_VERT);
+
+    int pos = posStart;
     for ( int n = 0; n < count; n++ )
     {
         ::SendMessage(hwnd, WM_VSCROLL, kind, 0);
+
+        int posNew = GetScrollPosition(hwnd, SB_VERT);
+        if ( posNew == pos )
+        {
+            // don't bother to continue, we're already at top/bottom
+            break;
+        }
+
+        pos = posNew;
     }
+
+    return pos != posStart;
 }
 
-void wxWindowMSW::ScrollLines(int lines)
+bool wxWindowMSW::ScrollLines(int lines)
 {
     bool down = lines > 0;
 
-    ScrollVertically(GetHwnd(),
-                     down ? SB_LINEDOWN : SB_LINEUP,
-                     down ? lines : -lines);
+    return ScrollVertically(GetHwnd(),
+                            down ? SB_LINEDOWN : SB_LINEUP,
+                            down ? lines : -lines);
 }
 
-void wxWindowMSW::ScrollPages(int pages)
+bool wxWindowMSW::ScrollPages(int pages)
 {
     bool down = pages > 0;
 
-    ScrollVertically(GetHwnd(),
-                     down ? SB_PAGEDOWN : SB_PAGEUP,
-                     down ? pages : -pages);
+    return ScrollVertically(GetHwnd(),
+                            down ? SB_PAGEDOWN : SB_PAGEUP,
+                            down ? pages : -pages);
 }
 
 // ---------------------------------------------------------------------------
@@ -3116,6 +3132,16 @@ bool wxWindowMSW::HandleSetFocus(WXHWND hwnd)
     }
 #endif // wxUSE_CARET
 
+#if wxUSE_TEXTCTRL
+    // If it's a wxTextCtrl don't send the event as it will be done
+    // after the control gets to process it.
+    wxTextCtrl *ctrl = wxDynamicCastThis(wxTextCtrl);
+    if ( ctrl )
+    {
+        return FALSE;
+    }
+#endif
+
     wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId);
     event.SetEventObject(this);
 
@@ -3135,6 +3161,16 @@ bool wxWindowMSW::HandleKillFocus(WXHWND hwnd)
     }
 #endif // wxUSE_CARET
 
+#if wxUSE_TEXTCTRL
+    // If it's a wxTextCtrl don't send the event as it will be done
+    // after the control gets to process it.
+    wxTextCtrl *ctrl = wxDynamicCastThis(wxTextCtrl);
+    if ( ctrl )
+    {
+        return FALSE;
+    }
+#endif
+
     wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId);
     event.SetEventObject(this);
 
@@ -4377,19 +4413,27 @@ extern wxWindow *wxGetWindowFromHWND(WXHWND hWnd)
 #endif // wxUSE_SPINCTRL
 
 #endif // Win32
-
-            if ( !win )
-            {
-                // hwnd is not a wxWindow, try its parent next below
-                hwnd = ::GetParent(hwnd);
-            }
         }
     }
 
     while ( hwnd && !win )
     {
-        win = wxFindWinFromHandle((WXHWND)hwnd);
+        // this is a really ugly hack needed to avoid mistakenly returning the
+        // parent frame wxWindow for the find/replace modeless dialog HWND -
+        // this, in turn, is needed to call IsDialogMessage() from
+        // wxApp::ProcessMessage() as for this we must return NULL from here
+        //
+        // FIXME: this is clearly not the best way to do it but I think we'll
+        //        need to change HWND <-> wxWindow code more heavily than I can
+        //        do it now to fix it
+        if ( ::GetWindow(hwnd, GW_OWNER) )
+        {
+            // it's a dialog box, don't go upwards
+            break;
+        }
+
         hwnd = ::GetParent(hwnd);
+        win = wxFindWinFromHandle((WXHWND)hwnd);
     }
 
     return win;