Reputation: 2889
I know that the function EnsureVisible(HTREEITEM hItem)
can show hItem
by scrolling the bar of the CTreeCtrl
control. But sometimes the hItem
is displayed either beside the top or beside the bottom of the control, which is so unfriendly for users. I want the item to be shown in the middle of the control. Any good solutions?
Upvotes: 1
Views: 665
Reputation: 595392
You would have to scroll the CTreeCtrl
manually. Call CTreeCtrl::EnsureVisible()
to make the item visible, then call CTreeCtrl::GetItemRect()
to retrieve the item's current coordinates, and then call CWnd::ScrollWindow/Ex()
specifying the necessary offset to put the item wherever you want it.
Upvotes: 4