如何使CTreeCtrl项集中显示? [英] How to make a CTreeCtrl item centrally displayed?

查看:120
本文介绍了如何使CTreeCtrl项集中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道函数 EnsureVisible(HTREEITEM hItem)可以显示 hItem c $ c> CTreeCtrl 控制。但有时, hItem 显示在控件的顶部或底部旁边,这对用户来说是不友好的。我想要的项目显示在控件的中间。

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?

推荐答案

您必须手动滚动 CTreeCtrl 。调用 CTreeCtrl :: EnsureVisible()以使项可见,然后调用 CTreeCtrl :: GetItemRect()项目的当前坐标,然后调用 CWnd :: ScrollWindow / Ex()指定必要的偏移量,将项目放在任何你想要的位置。

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.

这篇关于如何使CTreeCtrl项集中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆