Hamer
Hamer

Reputation: 1383

VirtualStringTree - Outside controls not passing TDragObject

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

Upvotes: 2

Views: 226

Answers (1)

TLama
TLama

Reputation: 76753

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.

Upvotes: 3

Related Questions