Gord,
You can change the background color of the treeveiw. I found the following code on
http://www.msfn.org/board/index.php?showto...4&st=0&*******************************************************
Option Explicit 'Needed to make sure declared strings etc work
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 'Used to set the following tweak
Private Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long 'Get treeview handle
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long 'Set handle
Private Const GWL_STYLE = -16& 'The current style of treeview
Private Const TVM_SETBKCOLOR = 4381& 'Set Bground Color
Private Const TVM_GETBKCOLOR = 4383& "Get Bground Color
Private Const TVS_HASLINES = 2& 'Misc stuff needed
Dim frmlastForm As Form 'The form using
Private Sub Form_Load()
Dim nodX As Node 'Creates nodX as the default Node
Set nodX = TreeView1.Nodes.Add(, , "R", "Default Plugins") 'Cut all this out of a prog i doing currently

Set nodX = TreeView1.Nodes.Add("R", tvwChild, "DP1", "Bios")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "DP2", "Video")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "DP3", "Sound")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "DP4", "CD/DVD")
Set nodX = TreeView1.Nodes.Add("R", tvwChild, "DP5", "Controllers")
nodX.EnsureVisible ' Make sure it visible
TreeView1.Style = tvwTreelinesText ' Style 4.
TreeView1.BorderStyle = vbFixedSingle
ChangeTreeviewColor 'This will be eventually the event to change the color

End Sub
Private Sub ChangeTreeviewColor()
Dim lngStyle As Long 'Explained further on
Call SendMessage(TreeView1.hWnd, TVM_SETBKCOLOR, 0, ByVal RGB(216, 228, 248)) 'Sends a message setting the color defined in the RGB(x,x,x) color value
lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE) 'lngStyle will have the init handle of treeview control
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle - TVS_HASLINES) 'Sets handle
Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle) 'Sets handle
End Sub
*****************************************************************
I tweaked the code a bit and was able to replicate the same thing with alot less code. Here is my version:
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 'Used to set the following tweak
Private Const TVM_SETBKCOLOR = 4381& 'Set Bground Color
Private Const TVM_GETBKCOLOR = 4383& 'Get Bground Color
'Call this function in form load event
Private Sub ChangeTreeviewColor()
Call SendMessage(tvwMIS.hWnd, TVM_SETBKCOLOR, 0, ByVal (16764057))
End Sub
HTH,
Mehdi