asilcot,
Try this,
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>
#include <GuiScrollBars.au3>
#include <ScrollBarConstants.au3>
Global $iScrollUp=False
Global $iScrollDown=False
;Create GUI
$hWnd = GUICreate("Auto Scroll Treeview", 300, 600, (@DesktopWidth/2)-150, (@DesktopHeight/2)-300, BitOR($WS_SIZEBOX,$WS_SYSMENU,$WS_MINIMIZEBOX,$WS_MAXIMIZEBOX))
;Create Treeview
Global $iTreeView = GUICtrlCreateTreeView(0, 0, 300, 600, BitOR($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_SHOWSELALWAYS,$WS_GROUP,$WS_TABSTOP), $WS_EX_CLIENTEDGE)
Global $hTreeView = GUICtrlGetHandle($iTreeView)
;Initialize Scrollbar
_GUIScrollBars_Init($hTreeView)
;Populate Treeview
_GUICtrlTreeView_BeginUpdate($hTreeView)
For $i=0 To 200
_GUICtrlTreeView_Add($hTreeView, 0, "Item" & $i,0,0)
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
GUISetState()
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $GUI_EVENT_CLOSE
Exit
Case $GUI_EVENT_MOUSEMOVE
Local $tMPos = _WinAPI_GetMousePos(True, $hTreeView)
If DllStructGetData($tMPos, 2) <= 30 Then
;mouse moved into upper portion of treeview, set flag to scroll up
$iScrollUp=True
$iScrollDown=False
ElseIf DllStructGetData($tMPos, 2) >= 540 Then
;mouse moved into lower portion of treeview, set flag to scroll down
$iScrollUp=False
$iScrollDown=True
Else
;mouse is not in either upper or lower portion of treeview, so don't move
$iScrollUp=False
$iScrollDown=False
EndIf
EndSelect
If $iScrollUp Then
If _GUIScrollBars_GetScrollInfoPos($hTreeview, $SB_VERT) <> _GUIScrollBars_GetScrollInfoMin($hTreeview, $SB_VERT) Then
;Move scrollbar up 1
;_GUIScrollBars_ScrollWindow($hTreeView, 0, 1)
_GUIScrollBars_SetScrollInfoPos($hTreeview, $SB_VERT, _GUIScrollBars_GetScrollInfoPos($hTreeview, $SB_VERT)-1)
_GUICtrlTreeView_EndUpdate($hTreeView) ; <------------- added to re-draw treeview
EndIf
;Sleep(50)
EndIf
If $iScrollDown Then
If _GUIScrollBars_GetScrollInfoPos($hTreeview, $SB_VERT) <> _GUIScrollBars_GetScrollInfoMax($hTreeview, $SB_VERT) Then
;Move scrollbar down 1
;_GUIScrollBars_ScrollWindow($hTreeView, 0, -1)
_GUIScrollBars_SetScrollInfoPos($hTreeview, $SB_VERT, _GUIScrollBars_GetScrollInfoPos($hTreeview, $SB_VERT)+1)
_GUICtrlTreeView_EndUpdate($hTreeView) ; <------------- added to re-draw treeview
EndIf
;Sleep(50)
EndIf
WEnd
kylomas
edit: there is an interesting discussion of a related issue >here...
I tried the alternate suggestions from this thread but they did not work. Maybe scrollbars are a different animal, don't know, never used them.