将 VB6 树视图中的节点设置为斜体
我希望能够将树视图中各个节点上的文本设置为斜体。听起来很简单,但我一直没能找到方法。节点上没有允许它的属性。我可以将其设置为粗体或更改颜色或设置背景颜色,但不能将其设置为斜体。有谁知道该怎么做?
I'd like be able to make the text on individual nodes in a treeview italic. It sounds simple but I haven't been able to find out how. There is no property on the node that allows it. I can make it bold or change the color or set the background color but not make it italic. Does anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你是对的,这听起来很简单。然而遗憾的是,在现实中做到这一点并不那么简单。 VB6 中的树视图控件是通用控件树视图的包装,但它没有公开该控件的大部分功能。您可以通过对控件进行子类化并将项目绘制事件处理为所有者绘制来执行您想要的操作。我没有方便地设置 VB6 IDE,但这里有一些很好的资源供您查看:
Brad Martinez 的有关 VB6 核心技巧的网站:
http://btmtz.mvps.org/treeview/
和我个人最喜欢的:
史蒂夫·麦克马洪 (Steve McMahon) 的 VBAccelerator 网站
http://www.vbaccelerator.com/home/VB /Code/Controls/TreeView/TreeView_Control/article.asp 它有一个非常好的自定义控件实现,您可以将其直接放入项目、源代码等中。
这两个网站和 Karl Peterson 的网站一样,对于 VB6 开发来说是不可或缺的:
http://vb.mvps.org/
祝你好运!
You are correct that it sounds simple. Sadly, however, it's not so simple to do in reality. The treeview control in VB6 is wrapper around the common controls treeview, but it does not expose much of the functionality of the control. You can do what you want by subclassing the control and handling the item paint event as owner draw. I don't have a VB6 IDE set up handy, but here are a couple of good resources for you to check out:
Brad Martinez's website on VB6 Hardcore tips:
http://btmtz.mvps.org/treeview/
and my personal favorite:
Steve McMahon's VBAccerator website
http://www.vbaccelerator.com/home/VB/Code/Controls/TreeView/TreeView_Control/article.asp which has a very nice custom control implementation that you can drop right into your project, source code and all.
These two website are indispensible for VB6 development along with Karl Peterson's site:
http://vb.mvps.org/
Good luck!
没有简单的方法可以做到这一点。基本上,您必须:
hWnd
OCM_NOTIFY
消息检查NM_CUSTOMDRAW
CDDS_PREPAINT
返回CDRF_NOTIFYITEMDRAW
CDDS_ITEMPREPAINT
选择传入的hDC
中的自定义字体并返回CDRF_NEWFONT
也没有简单的方法从树视图节点获取
hItem
。我正在使用这种黑客方式:There is no easy way to make this. Basicly you have to:
hWnd
OCM_NOTIFY
message check forNM_CUSTOMDRAW
CDDS_PREPAINT
returnCDRF_NOTIFYITEMDRAW
CDDS_ITEMPREPAINT
select custom font in passedhDC
and returnCDRF_NEWFONT
There is no easy way to get
hItem
from treeview node either. I'm using this hackish way: