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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.