]> git.saurik.com Git - wxWidgets.git/commitdiff
IsVisible() shouldn't return true if item is out of screen (bug 640607)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 21 Sep 2003 19:37:35 +0000 (19:37 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 21 Sep 2003 19:37:35 +0000 (19:37 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index ae62dd3d88d64ff4ca619f6ce20aa199602a068b..9921773c960160da57d241440b0854c783cd8da7 100644 (file)
@@ -1336,8 +1336,18 @@ bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const
     // the HTREEITEM with TVM_GETITEMRECT
     *(HTREEITEM *)&rect = HITEM(item);
 
-    // false means get item rect for the whole item, not only text
-    return SendMessage(GetHwnd(), TVM_GETITEMRECT, false, (LPARAM)&rect) != 0;
+    // true means to get rect for just the text, not the whole line
+    if ( !::SendMessage(GetHwnd(), TVM_GETITEMRECT, true, (LPARAM)&rect) )
+    {
+        // if TVM_GETITEMRECT returned false, then the item is definitely not
+        // visible (because its parent is not expanded)
+        return false;
+    }
+
+    // however if it returned true, the item might still be outside the
+    // currently visible part of the tree, test for it (notice that partly
+    // visible means visible here)
+    return rect.bottom > 0 && rect.top < GetClientSize().y;
 }
 
 bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const