|
-
Jun 15th, 2001, 02:56 AM
#1
Thread Starter
Addicted Member
Treeview Node Highlighting
I'm trying to write some code that will highlight a node in a treeview control when you move your mouse over it or on the same vertical position (The same as the drop down combo list in the Windows Explorer).
This is what I've done so far:
Private Sub Form_Load()
Dim nodCur As Node
' Add some nodes
With TreeView1.Nodes
Set nodCur = .Add(, , , "One")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Two")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Three")
Set nodCur = .Add(, , , "Four")
Set nodCur = .Add(, , , "Five")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Six")
Set nodCur = .Add(, , , "Seven")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Eight")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Nine")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Ten")
End With
' Tidy up
Set nodCur = Nothing
End Sub
Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lngCounter As Long
Dim nodCur As Node
For lngCounter = 0 To TreeView1.Width Step 180
Set nodCur = TreeView1.HitTest(lngCounter, y)
If Not nodCur Is Nothing Then
Set TreeView1.DropHighlight = nodCur
Exit For
End If
Next
' Tidy up
Set nodCur = Nothing
End Sub
It works fine, until the horizontal scrollbar is displayed, because I can no longer use 0 to the Treeview1.Width as the area to search for the node, as the area is now wider.
How can I find out what the scrollable width of a treeview is, or is there a better way of doing this?
Cheers
-
Jun 15th, 2001, 03:17 AM
#2
Frenzied Member
Have you tried the HotTracking property ?
Your code seems to work well for me!
-
Jun 15th, 2001, 04:22 AM
#3
Thread Starter
Addicted Member
HotTracking only highlights a node when you move over it, which isn't what I'm looking for. I what to highlight a node when the mouse is on the same Vertical value as a node.
Added the following nodes and expand them all, and I'll try and explain the problem better.
Private Sub Form_Load()
' Declarations:
Dim nodCur As Node
' Add some node
With TreeView1.Nodes
Set nodCur = .Add(, , , "One")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Two")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Three")
Set nodCur = .Add(, , , "Four")
Set nodCur = .Add(, , , "Five")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Six")
Set nodCur = .Add(, , , "Seven")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Eight")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Nine")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Ten")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Eleven")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Twelve")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Thirteen")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Fourteen")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Fifteen")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Sixteen")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Seventeen")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Eighteen")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Nineteen")
Set nodCur = .Add(nodCur.Index, tvwChild, , "Twenty")
End With
End Sub
When you move your mousepointer over the treeview, the node on the same Y value is highlighted, UNLESS the node is not visible as it is outside the Treeview1 visible area.
I need some way of finding out how big the treeview scrollable areas is, so I can check the whole width for the node.
e.g.
Dim sngTreeviewLeft as Single
Dim sngTreeviewWidth as Single
For lngCounter = sngTreeviewLeft To sngTreeviewWidth Step 180
....
Next
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|