Board index » delphi » Scrolling TreeView During A Drag Operation

Scrolling TreeView During A Drag Operation

Near as I can figure out tTreeView doesn't scroll itself during a drag
operation, so I have to write code to get it to do so.

Have I missed something obvious?
Does anyone have a nice way of doing this?

 

Re:Scrolling TreeView During A Drag Operation


Quote
"AlanGLLoyd" <alangll...@aol.com> wrote in message

news:20010315092044.11923.00000519@nso-fq.aol.com...

Quote

> Don't think so <g>

I was afraid of that.

Quote
> >Does anyone have a nice way of doing this?

> Admittedly you have to "waggle" the mouse slightly to get DragOver to be
> repeatedly called in the 6 pixel margin - but it works . . .

The mouse wagging was bothering me. What I have at this point is the
DragOver doing a GetHitTestInfo and firing up a timer when needed. The timer
then periodically checks the mouse position and scrolls if necessary. If I
ever get ambitious, I'll code the timer so that it speeds up the further
away from the control the mouse gets, a la Excel.

Re:Scrolling TreeView During A Drag Operation


In article <kd_r6.9913$TW.39...@tor-nn1.netcom.ca>, b...@bounceitattcanada.xnet
says...

Quote

>Near as I can figure out tTreeView doesn't scroll itself during a drag
>operation, so I have to write code to get it to do so.

>Have I missed something obvious?
>Does anyone have a nice way of doing this?

You could use Mike Lischke's excellent free replacements, Virtual Treeview or
TreeNT.

  http://www.lischke-online.de/Controls.html

Re:Scrolling TreeView During A Drag Operation


In article <kd_r6.9913$TW.39...@tor-nn1.netcom.ca>, "Bruce Roberts"

Quote
<b...@bounceitattcanada.xnet> writes:
>Near as I can figure out tTreeView doesn't scroll itself during a drag
>operation, so I have to write code to get it to do so.

>Have I missed something obvious?

Don't think so <g>

Quote
>Does anyone have a nice way of doing this?

This is one I did earlier for a ListBox and I've changed it for a TreeView but
have not tested it with a TreView <g>

procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
                State: TDragState; var Accept: Boolean);
begin
  Accept := true;
  with TreeView1 do begin
    if Y < 6 then
      TopItem := TopItem.GetPrev;
    if (Y > Height - 6) then
      TopItem := TopItem.GetNext;
  end; {with TreeView1}
end;

Admittedly you have to "waggle" the mouse slightly to get DragOver to be
repeatedly called in the 6 pixel margin - but it works . . .

Alan Lloyd
alangll...@aol.com

Re:Scrolling TreeView During A Drag Operation


Quote
"Rob Watt" <r.j.c.w...@RemoveThis.dundee.ac.uk> wrote in message

news:98ql1g$o0s$1@dux.dundee.ac.uk...

Quote

> You could use Mike Lischke's excellent free replacements, Virtual Treeview
or
> TreeNT.

>   http://www.lischke-online.de/Controls.html

The web page certainly make it look good. I'm in the process of downloading
it and will try it out. Thanks.

Re:Scrolling TreeView During A Drag Operation


In article <TC5s6.9970$TW.39...@tor-nn1.netcom.ca>, "Bruce Roberts"

Quote
<b...@bounceitattcanada.xnet> writes:
>The mouse wagging was bothering me. What I have at this point is the
>DragOver doing a GetHitTestInfo and firing up a timer when needed. The timer
>then periodically checks the mouse position and scrolls if necessary. If I
>ever get ambitious, I'll code the timer so that it speeds up the further
>away from the control the mouse gets, a la Excel.

You could make the code "waggle" the mouse as follows - it seems to work OK.
Unless it is an _enormous_ treeview, proportionate movement does not seem
necessary.

procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
const
  MM : integer = 1;
begin
  Accept := true;
  with TreeView1 do begin
    if Y < 10 then begin
      TopItem := TopItem.GetPrev;
      Sleep(100);
      MM := -MM;
      Mouse_Event(MOUSEEVENTF_MOVE, MM, 0, 0, 0);
    end; {if Y < 10}
    if (Y > Height - 10) then begin
      TopItem := TopItem.GetNext;
      Sleep(100);
      MM := -MM;
      Mouse_Event(MOUSEEVENTF_MOVE, MM, 0, 0, 0);
    end; {if (Y > Height - 10)}
  end; {with TreeView1}
end;

Alan Lloyd
alangll...@aol.com

Re:Scrolling TreeView During A Drag Operation


Quote
"AlanGLLoyd" <alangll...@aol.com> wrote in message

news:20010315140340.04576.00000322@nso-cq.aol.com...

Quote
> You could make the code "waggle" the mouse as follows - it seems to work
OK.
> Unless it is an _enormous_ treeview, proportionate movement does not seem
> necessary.

I learn something new every day. Never thought of doing it that way, now I
will.

I've been thinking more on proportionate movement and I think you are right
about not needing it. Especially in this case since I have to expand nodes
that are scrolled over - and in this case that's a relatively expensive
operation.

Other Threads