Skip to content

Commit 7522680

Browse files
committed
Some improvemnts for issue #1283
1 parent b18ed65 commit 7522680

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Source/VirtualTrees.DragnDrop.pas

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ class function TVTDragManager.GetTreeFromDataObject(const DataObject: TVTDragDat
244244
function TVTDragManager.DragEnter(const DataObject : IDataObject; KeyState : Integer; Pt : TPoint; var Effect : Integer) : HResult;
245245
var
246246
Medium: TStgMedium;
247+
HeaderFormatEtc: TFormatEtc;
247248
begin
248249
if not Assigned(FDropTargetHelper) then
249250
CoCreateInstance(CLSID_DragDropHelper, nil, CLSCTX_INPROC_SERVER, IID_IDropTargetHelper, FDropTargetHelper);
@@ -265,11 +266,16 @@ function TVTDragManager.DragEnter(const DataObject : IDataObject; KeyState : Int
265266
end;
266267
FDragSource := GetTreeFromDataObject(DataObject);
267268
Result := TreeView.DragEnter(KeyState, Pt, Effect);
268-
StandardOLEFormat.cfFormat := CF_VTHEADERREFERENCE;
269-
if (DataObject.GetData(StandardOLEFormat, Medium) = S_OK) and (FDragSource = FOWner) then
269+
HeaderFormatEtc := StandardOLEFormat;
270+
HeaderFormatEtc.cfFormat := CF_VTHEADERREFERENCE;
271+
if (DataObject.GetData(HeaderFormatEtc, Medium) = S_OK) and (FDragSource = FOWner) then
270272
begin
271273
FHeader := FDragSource.Header;
272274
FDRagSource := nil;
275+
end
276+
else
277+
begin
278+
fHeader := nil;
273279
end;
274280
end;
275281

@@ -284,6 +290,7 @@ function TVTDragManager.DragLeave : HResult;
284290
FIsDropTarget := False;
285291
FDragSource := nil;
286292
FDataObject := nil;
293+
fHeader := nil;
287294
Result := NOERROR;
288295
end;
289296

0 commit comments

Comments
 (0)