I am using Mike Lischke's excellent Virtual Treeview (VTV) and need to implement drag and drop from Windows Explorer to the VTV.
The following code (from the VTV help file) implements D&D within the VTV, but I need help with the code to allow the VTV to accept the list of files that have been dropped on it from Windows Explorer.
procedure TMainForm.VTDragDrop(Sender: TBaseVirtualTree; Source: TObject; DataObject: IDataObject;
const Formats: array of Word; Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode);
if Length(Formats) > 0 then
// OLE drag'n drop
// If the native tree format is listed then use this and accept the drop, otherwise recject (ignore) it.
// It is recommend by Microsoft to order available clipboard formats in decreasing detail richness so
// the first best format which we can accept is usually the best format we can get at all.
for I := 0 to High(Formats) do
if Formats[I] = CF_VIRTUALTREE then
case Mode of
AttachMode := amInsertBefore;
AttachMode := amAddChildLast;
AttachMode := amInsertAfter;
if Assigned(Source) and (Source is TBaseVirtualTree) and (Sender <> Source) then
AttachMode := amInsertBefore
AttachMode := amNowhere;
// in the case the drop target does an optimized move Effect is set to DROPEFFECT_NONE
// to indicate this also to the drag source (so the source doesn't need to take any further action)
Sender.ProcessDrop(DataObject, Sender.DropTargetNode, Effect, AttachMode);
// VCL drag'n drop, Effects contains by default both move and copy effect suggestion,
// as usual the application has to find out what operation is finally to do
All I need is a StringList result of the top level folders and files that were dropped and I can dive into the folders to get the complete tree.
I will increase the points by 100 if the solution is well commented so I can more easily learn from your solution.
Thank you in advance for all of your help!