Guest_imported
New member
- Jan 1, 1970
- 0
Could you please take a look on these code and tell me where is the mistake. When I click on a Node and it expands, some white boxes appears and I don't know how to solve the problem.
I'm sorry, but I'm new on vb ......
'API Call for Sending the message
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
'Constants for changing the treeview
Private Const GWL_STYLE = -16&
Private Const TVM_SETBKCOLOR = 4381&
Private Const TVM_GETBKCOLOR = 4383&
Private Const TVS_HASLINES = 2&
Private Const TV_FIRST As Long = &H1100
Private Const TVM_GETTEXTCOLOR As Long = (TV_FIRST + 32)
Private Const TVM_SETTEXTCOLOR As Long = (TV_FIRST + 30)
Private Sub Form_Load()
'This is last weeks code
'Declare Variables
Dim mNode As Node
Dim i As Integer
'Populate the list box
'Add the primary node
Set mNode = TreeView1.Nodes.Add(, , "Abuelo", "abuelo"
Set mNode = TreeView1.Nodes.Add("Abuelo", tvwChild, "Papa", "papa"
mNode.EnsureVisible
Set mNode = TreeView1.Nodes.Add("Papa", tvwChild, "Nieto1", "nieto1"
Set mNode = TreeView1.Nodes.Add("Papa", tvwChild, "Nieto2", "nieto2"
Set mNode = TreeView1.Nodes.Add("Nieto1", tvwChild, "Bisnieto", "bisnieto1"
For Each mNode In TreeView1.Nodes
mNode.BackColor = RGB(255, 0, 0) 'blau fosc
Next
'This is this weeks code
'Send a message to the treeview telling it to
'change the background It uses an RGB colour setting
Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0))
'Same as above except this one tells it to change
'the text colour
'Call SendMessage(TreeView1.hWnd, TVM_SETTEXTCOLOR, 0, ByVal RGB(255, 0, 0))
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Dim itmX As ListItem
If Node.Index <> 1 Then
If Node.Expanded = True Then
' Contrau el Node
Node.Expanded = False
Else: Node.Expanded = True 'Expandeix el Node
End If
End If
End Sub
I'm sorry, but I'm new on vb ......
'API Call for Sending the message
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
'Constants for changing the treeview
Private Const GWL_STYLE = -16&
Private Const TVM_SETBKCOLOR = 4381&
Private Const TVM_GETBKCOLOR = 4383&
Private Const TVS_HASLINES = 2&
Private Const TV_FIRST As Long = &H1100
Private Const TVM_GETTEXTCOLOR As Long = (TV_FIRST + 32)
Private Const TVM_SETTEXTCOLOR As Long = (TV_FIRST + 30)
Private Sub Form_Load()
'This is last weeks code
'Declare Variables
Dim mNode As Node
Dim i As Integer
'Populate the list box
'Add the primary node
Set mNode = TreeView1.Nodes.Add(, , "Abuelo", "abuelo"
Set mNode = TreeView1.Nodes.Add("Abuelo", tvwChild, "Papa", "papa"
mNode.EnsureVisible
Set mNode = TreeView1.Nodes.Add("Papa", tvwChild, "Nieto1", "nieto1"
Set mNode = TreeView1.Nodes.Add("Papa", tvwChild, "Nieto2", "nieto2"
Set mNode = TreeView1.Nodes.Add("Nieto1", tvwChild, "Bisnieto", "bisnieto1"
For Each mNode In TreeView1.Nodes
mNode.BackColor = RGB(255, 0, 0) 'blau fosc
Next
'This is this weeks code
'Send a message to the treeview telling it to
'change the background It uses an RGB colour setting
Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 0, 0))
'Same as above except this one tells it to change
'the text colour
'Call SendMessage(TreeView1.hWnd, TVM_SETTEXTCOLOR, 0, ByVal RGB(255, 0, 0))
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Dim itmX As ListItem
If Node.Index <> 1 Then
If Node.Expanded = True Then
' Contrau el Node
Node.Expanded = False
Else: Node.Expanded = True 'Expandeix el Node
End If
End If
End Sub