Results 1 to 4 of 4

Thread: TreeView

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    Post TreeView

    Is there some way to use API and maybe the SendMessage to modify the hottracking style in a treeview?

    To be more specific, I want to call a background color for the hottracking style, or atleast change the font from blue to another color and from underlie to bold.

    Can this be done, and how?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    on what event - what message - do you want to change the background color?
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    heres the code for the background color anyway - from MSDN:

    Code:
    Option Explicit
    
          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 Declare Function GetWindowLong Lib "User32" _
             Alias "GetWindowLongA" _
             (ByVal hWnd As Long, _
             ByVal nIndex As Long) As Long
    
          Private Declare Function SetWindowLong Lib "User32" _
             Alias "SetWindowLongA" _
             (ByVal hWnd As Long, _
             ByVal nIndex As Long, _
             ByVal dwNewLong As Long) As Long
    
          Private Const GWL_STYLE = -16&
          Private Const TVM_SETBKCOLOR = 4381&
          Private Const TVM_GETBKCOLOR = 4383&
          Private Const TVS_HASLINES = 2&
    
          Dim frmlastForm As Form
    
          Private Sub Form_Load()
              Dim nodX As Node
              Set nodX = TreeView1.Nodes.Add(, , "R", "Root")
              Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C1", "Child 1")
              Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C2", "Child 2")
              Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C3", "Child 3")
              Set nodX = TreeView1.Nodes.Add("R", tvwChild, "C4", "Child 4")
              nodX.EnsureVisible
              TreeView1.Style = tvwTreelinesText ' Style 4.
              TreeView1.BorderStyle = vbFixedSingle
          End Sub
    
          Private Sub Command1_Click()
             Dim lngStyle As Long
     
             Call SendMessage(TreeView1.hWnd, _
                               TVM_SETBKCOLOR, _
                               0, _
                               ByVal RGB(255, 150, 0))  'Change the background
                                                      'color to red.
    
          ' Now reset the style so that the tree lines appear properly
             lngStyle = GetWindowLong(TreeView1.hWnd, GWL_STYLE)
             Call SetWindowLong(TreeView1.hWnd, _
                               GWL_STYLE, _
                               lngStyle - TVS_HASLINES)
             Call SetWindowLong(TreeView1.hWnd, GWL_STYLE, lngStyle)
          End Sub
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I just want to change the background color of the node only as the mouse moves over it, like hot tacking. That's why I wanted to know if it was possible to change the hottracking styles?
    My evil laugh has a squeak in it.

    kristopherwilson.com

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