2

When dragging from a control onto the VirtualStringTree if the control has a TDragObject it is expected to use this as the Source in OnDragDrop and OnDragOver but it always returns the component. I believe this is a bug, but is there an alternate way of receiving another control's TDragObject without hacking TBaseVirtualTree?

procedure TIntelligenceCentralFrame.vstDragOver(Sender: 
  TBaseVirtualTree; Source: TObject; Shift: TShiftState; State: TDragState; 
  Pt: TPoint; Mode: TDropMode; var Effect: Integer; var Accept: Boolean);

Edit: Minimal Example

Hamer
  • 1,354
  • 1
  • 21
  • 34
  • This works fine as far as I remember. `Source` returns the source `TDragObject` as expected. Could you provide a minimal compilable example ? – TLama Jul 09 '14 at 14:40
  • I've added a small example with source. – Hamer Jul 09 '14 at 14:44

1 Answers1

3

That behavior is correct. You have used TDragControlObject as a drag object and this one should pass the assigned control to OnDragOver and OnDragDrop events. Reference describes that as:

When TDragControlObject is used, the OnDragOver and OnDragDrop events receive the control being dragged as the Sender, instead of the drag object itself.

Where Sender is the Source parameter of the virtual tree view's OnDragOver and OnDragDrop events. Solution is simple, use a different drag object. Or expect that you will get passed the assigned control when using the TDragControlObject drag object.

TLama
  • 75,147
  • 17
  • 214
  • 392
  • Much appreciated. The example that I provided as well as past code in our product were both always coming from TDragControlObject and I had assumed this must have always been an issue. Thanks again. – Hamer Jul 09 '14 at 15:25