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

Reply via email to