Author: Maarten de Haan
How to scroll a TTreeView?
Answer:
1 2 procedure TForm1.FormMouseWheelUp(Sender: TObject;
3 Shift: TShiftState;
4 MousePos: TPoint;
5 var Handled: Boolean);
6 7 var8 iPos: Integer;
9 10 begin11 iPos := GetScrollPos(Form1.TreeView1.Handle, SB_VERT);
12 SetScrollPos(Form1.TreeView1.Handle, SB_VERT, iPos - 1, True);
13 // Don't set Handled to True otherwise the scrollbar scrolls14 // but the content of the TreeView does NOT scroll!15 // I have not found a way to check if the TreeView has a scrollbar or not.16 // Maybe if you first call:17 // GetScrollRange(Form1.TreeView1.Handle, SB_VERT,lpMinPos,lpMaxPos);18 // and then:19 // if MaxPos = 0 and MinPos = 0 then there is no vertical scrollbar20 // if MaxPos <> 0 then there is a vertical scrollbar21 end;