[英]How to make a CTreeCtrl item centrally displayed?
I know that the function EnsureVisible(HTREEITEM hItem)
can show hItem
by scrolling the bar of the CTreeCtrl
control. 我知道该函数EnsureVisible(HTREEITEM hItem)
可以通过滚动CTreeCtrl
的栏来显示hItem
。 But sometimes the hItem
is displayed either beside the top or beside the bottom of the control, which is so unfriendly for users. 但是有时hItem
会显示在控件的顶部或底部旁边,这对用户来说非常不友好。 I want the item to be shown in the middle of the control. 我希望该项目显示在控件的中间。 Any good solutions? 有什么好的解决方案吗?
You would have to scroll the CTreeCtrl
manually. 您必须手动滚动CTreeCtrl
。 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. 调用CTreeCtrl::EnsureVisible()
使该项目可见,然后调用CTreeCtrl::GetItemRect()
检索该项目的当前坐标,然后调用CWnd::ScrollWindow/Ex()
指定必要的偏移量以将该项目放置在所需的位置它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.