From caea927d3d6f6a2ad5f3b1ada1aa520a00e72ef7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Sep 2003 19:37:35 +0000 Subject: [PATCH] IsVisible() shouldn't return true if item is out of screen (bug 640607) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/treectrl.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index ae62dd3d88..9921773c96 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -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 -- 2.45.2