将 VB6 树视图中的节点设置为斜体

发布于 2024-10-17 09:37:07 字数 104 浏览 6 评论 0原文

我希望能够将树视图中各个节点上的文本设置为斜体。听起来很简单,但我一直没能找到方法。节点上没有允许它的属性。我可以将其设置为粗体或更改颜色或设置背景颜色,但不能将其设置为斜体。有谁知道该怎么做?

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似梦非梦 2024-10-24 09:37:07

你是对的,这听起来很简单。然而遗憾的是,在现实中做到这一点并不那么简单。 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!

暮年慕年 2024-10-24 09:37:07

没有简单的方法可以做到这一点。基本上,您必须:

  • 中的TreeView 控件
  • 使用 Microsoft Windows Common Controls 5.0 (SP2)子类控件的 hWnd
  • OCM_NOTIFY 消息检查 NM_CUSTOMDRAW
    • 在舞台上CDDS_PREPAINT返回CDRF_NOTIFYITEMDRAW
    • 在舞台上CDDS_ITEMPREPAINT选择传入的hDC中的自定义字体并返回CDRF_NEWFONT

也没有简单的方法从树视图节点获取hItem。我正在使用这种黑客方式:

Private Function pvGetHItem(oNode As ComctlLib.Node) As Long
    Call CopyMemory(pvGetHItem, ByVal ObjPtr(oNode) + 68, 4)
End Function

There is no easy way to make this. Basicly you have to:

  • use TreeView control from Microsoft Windows Common Controls 5.0 (SP2)
  • subclass control's hWnd
  • on OCM_NOTIFY message check for NM_CUSTOMDRAW
    • on stage CDDS_PREPAINT return CDRF_NOTIFYITEMDRAW
    • on stage CDDS_ITEMPREPAINT select custom font in passed hDC and return CDRF_NEWFONT

There is no easy way to get hItem from treeview node either. I'm using this hackish way:

Private Function pvGetHItem(oNode As ComctlLib.Node) As Long
    Call CopyMemory(pvGetHItem, ByVal ObjPtr(oNode) + 68, 4)
End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文