Results 1 to 5 of 5

Thread: TreeView MouseOver Node

  1. #1

    Thread Starter
    Member Myvar's Avatar
    Join Date
    Sep 2001
    Location
    Deutschland/Germany
    Posts
    34

    TreeView MouseOver Node

    Hello!

    Perhaps theres someone in the who is able to help me .....

    I use a TreeView (MS Common Controls 5.0 (SP2)), and it works fine so far.

    But: I need something witch displays Fond.Underlined and a Userdefined MouesIcon when the Users Mousepointer is over a spezified Node of the TreeView.

    This is what i have done so far:
    (Makes the spezified Node selected)

    Code:
    Private Sub tvwModule_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        Dim nodX As Node
        Set nodX = tvwModule.HitTest(X, Y)
    
        If Not nodX Is Nothing Then
            If Not nodX.Parent Is Nothing Then
                If Not nodX.Child Is Nothing Then
                Else
                    ' Only BabyNode will be selected
                    nodX.Selected = True
                End If
            End If
        End If
    
        Set nodX = Nothing
        
    End Sub
    There is a second Problem I cant resolve:
    (Maybe Simple)

    How do I make sure the TreeView first Row is displayed, even when the TreeView has Scrollbars?
    Right now it seems the TreeViews Scrollbars are scrolled to the middle of the TreeView, I want them at the Begin of the Control, e.G. at TreeViews Top and Left.

    Any ideas?

    Thanks in Advanced,

    MyVar.

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522
    This is to answer the second part.

    dim nd as node
    set nd = tvtreeview.nodes(1)
    nd.select = true
    nd.ensurevisible = true

  3. #3

    Thread Starter
    Member Myvar's Avatar
    Join Date
    Sep 2001
    Location
    Deutschland/Germany
    Posts
    34

    ScrollBars

    Thx, Dalceon. The second Problem is resolved. It works fine that Way.

    I just made some adjustments:
    Code:
        tvwModule.Nodes.Item(1).Selected = True
        Set nodX = tvwModule.Nodes(1)
        nodX.Selected = True
        nodX.EnsureVisible
    Now, some Ideas for the Primary Problem?

    Thanks in Advance,

    MyVar.

  4. #4
    Fanatic Member
    Join Date
    Sep 2000
    Location
    Over There
    Posts
    522
    this does most of what you want.
    without getting into some very complicated stuff, you can't underline individual items as far as I know.
    be sure to set the mouseicon under the picture tab of the properties page.

    let me know if this is what you need.



    VB Code:
    1. Option Explicit
    2. Dim previousnodx As Node
    3.  
    4.  
    5. Private Sub Form_Load()
    6. Dim i As Long
    7. Dim nd As Node
    8. Dim x As Integer
    9. Dim nd2 As Node
    10.  
    11.  
    12. For i = 1 To 10
    13.    Set nd = tvwModule.Nodes.Add(, , , "Number " & i)
    14.    For x = 1 To 3
    15.       Set nd2 = tvwModule.Nodes.Add(nd, tvwChild, , "Child " & x)
    16.    Next
    17. Next
    18.  
    19. End Sub
    20.  
    21. Private Sub tvwModule_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    22.  
    23.     Dim nodX As Node
    24.     Set nodX = tvwModule.HitTest(x, Y)
    25.     If Not nodX Is Nothing Then
    26.         If Not previousnodx Is Nothing Then
    27.            previousnodx.Bold = False
    28.         End If
    29.         Set previousnodx = nodX
    30.         If nodX.Parent Is Nothing Then
    31.               tvwModule.MousePointer = ccArrow
    32.                 nodX.Bold = False
    33.                  LockWindowUpdate 0&
    34.             Else
    35.                 ' Only BabyNode will be selected
    36.                 nodX.Selected = True
    37.                 tvwModule.MousePointer = 99
    38.                 nodX.Bold = True
    39.                  LockWindowUpdate 0&
    40.             End If
    41.     Else
    42.        tvwModule.MousePointer = ccArrow
    43.     End If
    44.     Set nodX = Nothing
    45.    
    46. End Sub

  5. #5

    Thread Starter
    Member Myvar's Avatar
    Join Date
    Sep 2001
    Location
    Deutschland/Germany
    Posts
    34

    Thumbs up [Three-Quater Solved] Not exactly what I want but ...

    Thanks Dalceon!

    This is not exactly what I am looking for but I like it!

    I have made some Adjustments, because .Bold didnt worked for me and *OhHowLuckyIam* there is no flickering, so I cleared out LockWindowUpdate.

    Since I have a 3 Dimension TreeView:

    +Root
    ||
    |+Child
    ||
    |||+Babys
    |
    +Root
    ||
    |+Child
    |
    +Root
    ||
    |+Child
    ||
    |||+Babys
    |
    +Root

    and using Common Controls 5.0 SP2, this workes for me:

    Code:
    Private Sub tvwModule_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        Dim nodX As Node
        Set nodX = tvwModule.HitTest(X, Y)
    
        If Not nodX Is Nothing Then
            tvwModule.MousePointer = ccArrow
            If Not nodX.Parent Is Nothing Then
                tvwModule.MousePointer = ccArrow
                If Not nodX.Child Is Nothing Then
                    tvwModule.MousePointer = ccArrow
                Else
                    tvwModule.MousePointer = 99
                    tvwModule.MouseIcon = LoadPicture(App.Path & _
                                      "\" & "Ressourcen\handkleinweiss.cur")
                End If
            End If
            nodX.Selected = True
        Else
           tvwModule.MousePointer = ccArrow
        End If
        Set nodX = Nothing
        
    End Sub
    Now each Node is Selected when the Mousepointer moves over them, but only over BabyNodes the MouseIcon is a WhiteHand.

    If you wanna see how it looks like now

    While only behind BabyNodes there is Code to be performed, this is a good Way to improve usability.

    It would be nice to show the BabyNodes Underlined, mabe there is a Way to do it simply? I do not wanna use 3.Party Components or a Ton of API Calls.

    If not, no Matter what. : )

    Thanks in Advanced,

    MyVar.

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