The following code works in a TListBox. I assume that it will also work
in a TTreeView. I have the Timer1.Interval set to 250. Declare a
private variable sDirection : String.
Good luck,
Wayne
[code lang=”delphi”]procedure TfrmExportData.lbFieldsExportingDragOver(Sender, Source:
TObject;
X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := Sender = Source;
if (Accept) and (iStartItem = 0) then begin
iStartItem := lbFieldsExporting.ItemIndex;
end;
// handle the scrolling of the listbox
if Y < 0 then begin
// need to scroll the listbox up
sDirection := 'UP';
timer1.enabled := true;
end else begin
if y > lbFieldsExporting.height – 5 then begin
// need to scroll the listbox down
sDirection := ‘DOWN’;
timer1.enabled := true;
end else begin
// need to stop scrolling of the listbox
timer1.enabled := false;
end; // if y > lbFieldsExporting.height – 5 then begin
end; // if Y < 0 then begin
end;
procedure TfrmExportData.Timer1Timer(Sender: TObject);
begin
if sDirection = 'UP'
then PostMessage( lbFieldsExporting.handle, wm_vscroll,
sb_lineup,0)
else PostMessage( lbFieldsExporting.handle, wm_vscroll,
sb_linedown,0);
end;
[/code]
[tags]Delphi, Components, TreeView[/tags]
0 Kommentare zu “TreeView Scroll when Drag”