Die von VB erstellte TreeView-App ist für die Verwendung in der API-Umgebung verfügbar.
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 Deklarationsfunktion GetWindowLong Lib User32 Alias GetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Deklarationsfunktion 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&
Dimmen Sie frmlastForm als Formular
Privates Unterformular_Load()
Dimmen Sie nodX als Knoten
Setze nodX = TreeView1.Nodes.Add(, , R, Root)
Setze nodX = TreeView1.Nodes.Add(R, tvwChild, C1, Child 1)
Setze nodX = TreeView1.Nodes.Add(R, tvwChild, C2, Child 2)
Setze nodX = TreeView1.Nodes.Add(R, tvwChild, C3, Child 3)
Setze nodX = TreeView1.Nodes.Add(R, tvwChild, C4, Child 4)
nodX.EnsureVisible
TreeView1.style = tvwTreelinesText ' Stil 4.
TreeView1.BorderStyle = vbFixedSingle
Sub beenden
Privater Unterbefehl1_Click()
Dim lngStyle As Long
Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0))
'改变背景到红色
lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle - TVS_HASLINES)
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle)
Sub beenden
Option explizit
Private Deklarationsfunktion SendMessage Lib User32 Alias SendMessageA (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Deklarationsfunktion GetWindowLong Lib User32 Alias GetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Deklarationsfunktion 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&
Privates Unterformular_Load()
Nodex als Knoten dimmen
Dim i als Ganzzahl
Dim lStyle So lange
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
Mit TreeView1.Nodes
Setze nodex = .Add(, , R, Root)
nodex.BackColor = RGB(255, 0, 0)
Für i = 1 bis 10
Setze nodex = .Add(R, tvwChild, C & i, Child & i)
nodex.BackColor = RGB(255, 0, 0)
nodex.EnsureVisible
Nächste
Ende mit
Sub beenden