2008. július 10., csütörtök
How to detect if a TreeView has a scrollbar and how to change its position?
Problem/Question/Abstract:
How to detect if a TreeView has a scrollbar?
How to change the scrollbar in a TreeView (if it has one)?
Answer:
procedure TForm1.FormMouseWheelDown(Sender: TObject;
Shift: TShiftState;
MousePos: TPoint;
var Handled: Boolean);
var
iMin, iMax: Integer;
bTreeViewVertScrollBarVisible: Boolean;
begin
bTreeViewVertScrollBarVisible := True;
GetScrollRange(Form1.TreeView1.Handle, SB_VERT, iMin, iMax);
if iMin = iMax then
bTreeViewVertScrollBarVisible := False; // No scrollbar visible
if bTreeViewVertScrollBarVisible then
begin
iPos := GetScrollPos(Form1.TreeView1.Handle, SB_VERT);
SetScrollPos(Form1.TreeView1.Handle, SB_VERT, iPos + 1, True);
// Don't set Handled to True!
// If you do that then ONLY the scrollbar changes but NOT the
// content of the TreeView!
end;
end;
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése