devxlogo

SetTreeViewBackColor – Change the background color of a TreeView control

SetTreeViewBackColor – Change the background color of a TreeView control

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As _    Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As LongDeclare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd _    As Long, ByVal nIndex As Long) As LongDeclare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd _    As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongConst 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             ' set the BackColor for every node    For Each TVNode In TV.Nodes        TVNode.BackColor = BackColor    Next    ' set the BackColor for the TreeView's window    SendMessage TV.hwnd, TVM_SETBKCOLOR, 0, ByVal BackColor    ' get the current style    lStyle = GetWindowLong(TV.hwnd, GWL_STYLE)    ' temporary hide lines    SetWindowLong TV.hwnd, GWL_STYLE, lStyle And (Not TVS_HASLINES)    ' redraw lines    SetWindowLong TV.hwnd, GWL_STYLE, lStyleEnd Sub

See also  Monetize TikTok For Your Business
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist