Results 1 to 2 of 2

Thread: Treeview color...again

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    4

    Question Treeview color...again

    I have been trying to change the background color of a treeview control using the sendMessages api function. It works great unless I have the line style property set to rootlines. If I do then I get a white space to the left of each of the children nodes. I have tried using the code at http://www.mvps.orgURL=http://www.mv.../tveffects.htm]www.mvps.org[/URL] , but it still seems to have everything left of those stupid root lines white. any ideas?[

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    You could try subclassing the parent window and acting on the WM_CTLCOLOR* messages. You could do this with the EventVB.dll thus:

    VB Code:
    1. Option Explicit
    2.  
    3. Dim WithEvents vbLink As EventVB.APIFunctions
    4. Dim WithEvents vbWnd As EventVB.ApiWindow
    5.  
    6.  
    7. Private Sub Form_Load()
    8.  
    9. Set vbLink = New APIFunctions
    10. Set vbWnd = New ApiWindow
    11.  
    12. vbWnd.hWnd = Me.hWnd
    13. vbLink.SubclassedWindows.Add vbWnd
    14.  
    15. With TreeView1
    16.     .Nodes.Add , , "TOP", "Top level"
    17.     .Nodes.Add "TOP", tvwChild, "NEXT1", "Child 1"
    18.     .Nodes.Add "TOP", tvwChild, "NEXT2", "Child 2"
    19. End With
    20.  
    21. End Sub
    22.  
    23. Private Sub vbWnd_ControlColour(ByVal ControlType As EventVB.StandardControlTypes, ByVal DeviceContext As EventVB.ApiDeviceContext, ByVal ControlWindow As EventVB.ApiWindow, ColourBrush As EventVB.ApiLogBrush)
    24.  
    25. If ControlWindow.hWnd = TreeView1.hWnd Then
    26.     Dim colThis As New ApiColour
    27.     With colThis
    28.         .Red = 0
    29.         .Green = 0
    30.         .Blue = 255
    31.     End With
    32.    
    33.     Set ColourBrush.Colour = colThis
    34. End If
    35.  
    36. End Sub

    Hope this helps,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width