Utilice TreeView para configurar API.
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
Función de declaración privada GetWindowLong Lib User32 Alias GetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Función de declaración privada SetWindowLong Lib User32 Alias SetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Constante privada GWL_STYLE = -16&
Const privada TVM_SETBKCOLOR = 4381&
Const privada TVM_GETBKCOLOR = 4383&
Const privada TVS_HASLINES = 2&
Dim frmlastForm como formulario
Subformulario privado_Load()
Dim nodX como nodo
Establecer nodX = TreeView1.Nodes.Add(, , R, Raíz)
Establecer nodX = TreeView1.Nodes.Add(R, tvwChild, C1, Child 1)
Establecer nodX = TreeView1.Nodes.Add(R, tvwChild, C2, Child 2)
Establecer nodX = TreeView1.Nodes.Add(R, tvwChild, C3, Child 3)
Establecer nodX = TreeView1.Nodes.Add(R, tvwChild, C4, Child 4)
nodX.EnsureVisible
TreeView1.style = tvwTreelinesText ' Estilo 4.
TreeView1.BorderStyle = vbFixedSingle
Subtítulo final
Subcomando privado1_Click()
Atenuar lngStyle mientras sea largo
Llamar a SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0))
'改变背景到红色
lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
Llame a SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle - TVS_HASLINES)
Llamar a SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle)
Subtítulo final
Opción explícita
Función de declaración privada SendMessage Lib User32 Alias SendMessageA (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Función de declaración privada GetWindowLong Lib User32 Alias GetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Función de declaración privada SetWindowLong Lib User32 Alias SetWindowLongA (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Constante privada GWL_STYLE = -16&
Const privada TVM_SETBKCOLOR = 4381&
Const privada TVM_GETBKCOLOR = 4383&
Const privada TVS_HASLINES = 2&
Subformulario privado_Load()
Dim nodex como nodo
Atenuar i como entero
Atenuar el estilo mientras dure
Llamar a SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0))
lStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
Llame a SetWindowLong(TreeView1.hWnd, GWL_STYLE, lStyle - TVS_HASLINES)
Llamar a SetWindowLong(TreeView1.hWnd, GWL_STYLE, lStyle)
TreeView1.Style = tvwTreelinesPlusMinusPictureText
TreeView1.BorderStyle = ccFixedSingle
Con TreeView1.Nodes
Establecer nodex = .Add(, , R, Raíz)
nodex.BackColor = RGB(255, 0, 0)
Para i = 1 a 10
Establecer nodex = .Add(R, tvwChild, C & i, Child & i)
nodex.BackColor = RGB(255, 0, 0)
nodex.EnsureVisible
Próximo
Terminar con
Subtítulo final