X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0edeeb6d96d31d342a6a283d2a9b625a1d0a7b96..e6d18909c9cb124feaab32966f2aa44c2f0b0617:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 96bf25a0b5..f7e310659d 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -1354,7 +1354,15 @@ wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); wxASSERT_MSG( IsVisible(item), wxT("The item you call GetNextVisible() for must be visible itself!")); - return wxTreeItemId(TreeView_GetNextVisible(GetHwnd(), HITEM(item))); + wxTreeItemId next(TreeView_GetNextVisible(GetHwnd(), HITEM(item))); + if ( next.IsOk() && !IsVisible(next) ) + { + // Win32 considers that any non-collapsed item is visible while we want + // to return only really visible items + next.Unset(); + } + + return next; } wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const @@ -1362,7 +1370,15 @@ wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const wxCHECK_MSG( item.IsOk(), wxTreeItemId(), wxT("invalid tree item") ); wxASSERT_MSG( IsVisible(item), wxT("The item you call GetPrevVisible() for must be visible itself!")); - return wxTreeItemId(TreeView_GetPrevVisible(GetHwnd(), HITEM(item))); + wxTreeItemId prev(TreeView_GetPrevVisible(GetHwnd(), HITEM(item))); + if ( prev.IsOk() && !IsVisible(prev) ) + { + // just as above, Win32 function will happily return the previous item + // in the tree for the first visible item too + prev.Unset(); + } + + return prev; } // ----------------------------------------------------------------------------