Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As _ Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd _ As Long, ByVal nIndex As Long) As Long Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd _ As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = -16& Const TVM_SETBKCOLOR = 4381& Const TVS_HASLINES = 2&
Sub SetTreeViewBackColor(TV As TreeView, ByVal BackColor As Long) Dim lStyle As Long Dim TVNode As node For Each TVNode In TV.Nodes TVNode.BackColor = BackColor Next
SendMessage TV.hwnd, TVM_SETBKCOLOR, 0, ByVal BackColor lStyle = GetWindowLong(TV.hwnd, GWL_STYLE) SetWindowLong TV.hwnd, GWL_STYLE, lStyle And (Not TVS_HASLINES) SetWindowLong TV.hwnd, GWL_STYLE, lStyle End Sub |