Results 1 to 7 of 7

Thread: Treeview1 Hot Tracking change color? [RESOLVED]

  1. #1

    Thread Starter
    Lively Member recpack's Avatar
    Join Date
    May 2004
    Location
    Phoenix, Arizona
    Posts
    75

    Treeview1 Hot Tracking change color? [RESOLVED]

    Greetings!

    My question for today is this:

    [Code}
    Treeview1.hottracking=True
    [/CODE]

    I would not only like it to hottrack but also change color of the node when it does... oh say... vbblue

    I have tried several things in the Treeview Mousemove event but it's not happening for me. Can anyone give me some advise?

    Thank you
    Last edited by recpack; Jun 7th, 2004 at 10:59 AM.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    This works, but if you have a lot of nodes, the looping that this does may not be good. I may be able to improve it but here's what I have so far.

    VB Code:
    1. Private Sub Treeview1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    2.     Dim MouseOverNode As MSComctlLib.Node
    3.     Dim lngNodes As Long
    4.    
    5.     On Error Resume Next
    6.    
    7.     For lngNodes = 0 To tvwDemo.Nodes.Count
    8.         Treeview1.Nodes(lngNodes).BackColor = vbWhite
    9.     Next
    10.    
    11.     Set MouseOverNode = Treeview1.HitTest(x, y)
    12.     MouseOverNode.BackColor = vbBlue
    13.  
    14. End Sub

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    OK, this is better.

    VB Code:
    1. Option Explicit
    2. Private mNode As MSComctlLib.Node
    3.  
    4. Public Property Get PreviousNode() As MSComctlLib.Node
    5.  
    6.     Set PreviousNode = mNode
    7.  
    8. End Property
    9.  
    10. Public Property Let PreviousNode(ByVal pNode As MSComctlLib.Node)
    11.  
    12.     Set mNode = pNode
    13.  
    14. End Property
    15.  
    16. Private Sub Treeview1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    17.     Dim MouseOverNode As MSComctlLib.Node
    18.    
    19.     On Error Resume Next
    20.    
    21.     PreviousNode.BackColor = vbWhite
    22.     Set MouseOverNode = Treeview1.HitTest(x, y)
    23.     MouseOverNode.BackColor = vbBlue
    24.     PreviousNode = MouseOverNode
    25.  
    26. End Sub

  4. #4

    Thread Starter
    Lively Member recpack's Avatar
    Join Date
    May 2004
    Location
    Phoenix, Arizona
    Posts
    75
    Hello once again Marty-

    Hey that worked pretty cool. I tried it on a tree with 172 nodes and it makes the tree flicker when I mousemove.

    If I may... Let me clarify the effect I am looking for -
    HotTracking underline still visable
    node background retain it's white color and node text (forecolor) blue. So really the only thing changing is the text color.

    Either way you gave me something to go on, and I am now going to continue to search the forum on "hottracking"

    Thanks again!



    PS Oops.. I posted this after your second post.. I'll try that second one.

  5. #5

    Thread Starter
    Lively Member recpack's Avatar
    Join Date
    May 2004
    Location
    Phoenix, Arizona
    Posts
    75
    I tried the second method, though too me (a complete amature) it looks more efficient.... Still get the flicker when the tree has alot of nodes (currently 172).

    Still a cool piece of snippet for me. Thx.

  6. #6

  7. #7

    Thread Starter
    Lively Member recpack's Avatar
    Join Date
    May 2004
    Location
    Phoenix, Arizona
    Posts
    75
    Thanks for your response and help once again Marty- I searched around and your right, there is no real easy, clean way of doing it.. Im gonna abort that idea for now. Have a great day!

    Peace

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