JAM-Software / Virtual-TreeView

Virtual Treeview is a Delphi treeview control
http://www.jam-software.de/virtual-treeview/
642 stars 250 forks source link

AutoScroll does not respect AutoScrollDelay property #1259

Closed radioboss closed 2 months ago

radioboss commented 3 months ago

When something is dragged onto the list (DragType = dtVCL) from its bottom part, auto scroll happens immediately, without respecting the AutoScrollDelay property value. It happens in the TBaseVirtualTree.DragOver procedure on line 11371:

WindowScrolled := DoSetOffsetXY(Point(FOffsetX + DeltaX, FOffsetY + DeltaY), ScrollOptions, nil);

The TBaseVirtualTree.DetermineScrollDirections appears to be trying to handle this case in if FDragScrollStart = 0 then FDragScrollStart := timeGetTime; // Reset any scroll direction to avoid scroll in the case the user is dragging and the auto scroll time has not // yet elapsed. if ((Int64(timeGetTime) - FDragScrollStart) < FAutoScrollDelay) then Result := [];

But FDragScrollStart is always zero at this point, so the Result is not emptied and scrolling does occur in the TBaseVirtualTree.DragOver procedure.

Looks like a bug.

joachimmarder commented 3 months ago

Please respect our guidelines on the project homepage for submitting bugs. Please include your version of Virtual TreeView and Delphi, and attach a sample compiling project as ZIP to your report that allows to replicate the problem. If only small changes are required, a description is sufficient how a demo projects needs to be changed in order to replicate the bug. If you already have a solution, please supply a patch file.

joachimmarder commented 3 months ago

Repro steps

  1. Open the Advanced sample project.
  2. For GeneralAbilitesDemo.VST2 set AutoScrollDelay to 10000.
  3. Run the project and switch to page "General Abilities".
  4. Drag a file from Windows File Explorer to the bottom of the treeview control

Expected

The tree starts scrolling down after 10 seconds

Actual

The tree starts scrolling down after less than a second.

joachimmarder commented 3 months ago

The auto scroll delay is indeed not respected, however it seems that the scrolling is triggered from outside our control. Here is the call stack:

VirtualTrees.BaseTree.TBaseVirtualTree.DoSetOffsetXY((9427896, 15319823),[suoRepaintHeader,suoRepaintScrollBars,suoScrollClientArea,suoUpdateNCArea],nil)
VirtualTrees.BaseTree.TBaseVirtualTree.SetOffsetY(-1273)
VirtualTrees.BaseTree.TBaseVirtualTree.WMVScroll((277, (), 1, 1, (), 0, 0))
TControl.WndProc + $2C1
TWinControl.WndProc + $6AC
VirtualTrees.BaseTree.TBaseVirtualTree.WndProc((277, 65537, 0, 0, 1, 1, (), 0, 0, (), 0, 0, ()))
TWinControl.MainWndProc + $2F
StdWndProc + $16

Maybe this is a feature of newer Windows versions?

radioboss commented 3 months ago

I'm sorry I didn't follow the guidelines, I didn't know those existed :)

As for scrolling, if in the same Advanced sample project you disable the toAutoScroll in TreeOptions/AutoOptions for this VST2, no scrolling occurs, which looks like the VST has control whether to start scrolling or not.

I don't think it's Windows feature; this also occurs for regular VCL dragging inside the same program, e.g. add TListBox with a single item, set DragMode to dmAutomatic and drag this item over VST2 - scrolling also occurs immediately, not taking into account AutoScrollDelay.

joachimmarder commented 3 months ago

The Windows COM class CLSID_DragDropHelper is responsible for the auto-scrolling. See TVTDragManager.DragEnter() for more details: The method does not pass the control handle to prevent auto-scrolling in case toAutoScroll is not set.

radioboss commented 2 months ago

Ok thank you. I guess as this looks like it isn't a VirtualTree issue, this can be closed now.