彩票走势图

如何修改treeview的背景色

翻译|其它|编辑:郝浩|2004-01-12 21:41:00.000|阅读 1556 次

概述:

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

在通常情况下,treeview的背景色是不可以修改的,我们可以通过API实现,源码如下

Option Explicit

Private Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Const GWL_STYLE = -16&
Private Const TVM_SETBKCOLOR = 4381&
Private Const TVM_GETBKCOLOR = 4383&
Private Const TVS_HASLINES = 2&

Private Sub Form_Load()

Dim nodex As Node
Dim i As Integer
Dim lStyle As Long

Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0))
lStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lStyle - TVS_HASLINES)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lStyle)

TreeView1.Style = tvwTreelinesPlusMinusPictureText
TreeView1.BorderStyle = ccFixedSingle
With TreeView1.Nodes
Set nodex = .Add(, , "R", "Root")
nodex.BackColor = RGB(255, 0, 0)
For i = 1 To 10
Set nodex = .Add("R", tvwChild, "C" & i, "Child " & i)
nodex.BackColor = RGB(255, 0, 0)
nodex.EnsureVisible
Next
End With

End Sub


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP