-
Can anybody take a look on this code and tell me
what's wrong with it....please
'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
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()
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")
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, 204, 0) 'blau fosc
Next
Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(255, 204, 0))
Call SendMessage(TreeView1.hWnd, TVM_SETTEXTCOLOR, 0, ByVal RGB(0, 127, 0))
End Sub
Private Sub TreeView1_Click()
TreeView1.Refresh
End Sub
-
I'm not sure because I couldn't test it, but I think you have to write: Dim mNode as Object instead of: Dim mNode as Node.
I think it's not the only reason. Try it at first and if it doesn't function, than say and I'll try to find it out.
-
Maritsu?
Your code seems fine to me. Setting the text color works fine but the backgrounf is never set up properly. I means you
will get the background color working fine as long as as you do not implode or explode nodes, once you do do that some parts of the background color are gone leaving you with an inconsistent background color.
To me that API needs more work in the base,anyway if
you get through any other way let me know. I've got to go back to work now.
Bye
-
juliomont!!
After spending a loooooong time trying to solve this problem
some people told me that it's impossible to do it with the treeview control, so I've finally used an image as background color......I wasted so much time!!!
Adiosete!!!
Bye!
-
Maritsu,
Thank you for the e-mail. I also spent some time trying
to get that API doing what is suppose to do. Well that's the
way one get to learn new things, sometimes the solution is at hand other times one never gets it,but almost always there is a way around them.
Bye and good luck