Results 1 to 5 of 5

Thread: TreeView Autoscroll

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    8

    TreeView Autoscroll

    If the text of the node is very long,ensure visible property scrolls the treeview to the right most horizontally.
    While autoscrolling i want the image to be visible.Can this be done???
    Plzz help!

  2. #2
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: TreeView Autoscroll

    Try this:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
    4.      ByVal hwnd As Long, _
    5.      ByVal wMsg As Long, _
    6.      ByVal wParam As Long, _
    7.      ByRef lParam As Any) As Long
    8.  
    9. Private Const WM_HSCROLL As Long = &H114
    10. Private Const SB_LINELEFT As Long = 0
    11. '------------------------------------------------------------------
    12. Private Sub Command1_Click()
    13.   Dim i As Long
    14.  
    15.   TreeView1.Nodes("[color=maroon]Key[/color]").EnsureVisible
    16.  
    17.   For i = 1 To 4 'Scroll left 4 times to bring the icon into view
    18.     SendMessage TreeView1.hwnd, WM_HSCROLL, SB_LINELEFT, 0&
    19.   Next i
    20.  
    21. End Sub
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: TreeView Autoscroll

    why not just use SB_LEFT instead of SB_LINELEFT - or am i missing something?

  4. #4
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: TreeView Autoscroll

    SB_LEFT will fire a "Large Change". If the node is a childnode, it will scroll the scrollbar beyond that node's icon.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: TreeView Autoscroll

    BTW, using TVM_GETITEMRECT may be the best way to do this. (haven't tried it though)
    But using SB_LINELEFT is easier.

    If you are interested, see the StartLabelEdit Sub.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


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