I would suggest that you use a timer. When you get your OnDragOver event and
you're in the scroll zone, do one scroll and then enable the timer. When you
get the next OnDragOver (or an OnDragDrop or OnEndDrag event) disable the
timer before you do anything else. In the timer event, disable the timer, do
one scroll, and then enable the timer again. Then you just have to
experiment with the timer speed to get a nice smooth effect.
Cheers,
Andrew Cooke.
> -----Original Message-----
> From: Aaron Scott-Boddendijk [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, March 03, 1999 9:50 AM
> To: Multiple recipients of list delphi
> Subject: [DUG]: Drag-scrolling
>
> We have a treeview in a form which allows dragging of nodes around inside
> the tree... (Iknow, I know, simple stuff, works fine)... However there is
> the
> need for having the treeview autoscroll during the drag so that nodes
> offscreen scroll into view.
>
> I hacked together this OnDragOver routine to perform the scrolling (which
> works)
> but since an OnDragOver event is fired on a mouse movement it scrolled
> only
> 1 node at a time. To replicate explorers constant scrolling I wanted to
> reenter
> the OnDragOver while the mouse was in the scroll-zone. To do this I
> called
> the tvDragOver recursively - this is not the correct method since it could
> potentially fill the stack.
>
> What IS the correct method to retrigger the OnDragOver event... A message?
> if so which one... Can someone suggest a replacement for the line:
> tvDragOver(Sender,Source,Pnt.X,Pnt.Y,State,Accept);
>
> procedure TForm1.tvDragOver(Sender, Source: TObject; X, Y: Integer;
> State: TDragState; var Accept: Boolean);
> const
> Boundry = 30;
> var
> N :TTreeNode;
> Pnt :TPoint;
> begin
> if (Y<=Boundry) or ((TV.Height-Boundry)<=Y) then begin
> Accept := False; {This will be replaced with the drop condition}
> N := TV.GetNodeAt(X,Y);
> if N<>nil then begin
> if Y<=Boundry then N := N.GetPrevVisible
> else N := N.GetNextVisible;
> if N<>nil then begin
> TV.Selected := N;
> Pnt := Mouse.CursorPos;
> Pnt := TV.ScreenToClient(Pnt);
> {Bad line below, naughty line, this line needs a good spanking}
> tvDragOver(Sender,Source,Pnt.X,Pnt.Y,State,Accept);
> end;
> end;
> end;
> Application.ProcessMessages;
> end;
>
> --
> Aaron Scott-Boddendijk
> Jump Productions
> (07) 838-3371 Voice
> (07) 838-3372 Fax
>
> --------------------------------------------------------------------------
> -
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz