More than modifying the modifier, you must change the operation you are about to perform in the OnDragOver event handler. So, to add the CTRL key as a modifier of the copy operation, you should write something like the following. The value of the Effect parameter set in this case also changes the drag cursor depending on the selected operation. Except that this value is passed to the OnDragDrop event, where you can determine what to do with the dropped source:
procedure TForm1.VirtualStringTree1DragOver(Sender: TBaseVirtualTree; Source: TObject; Shift: TShiftState; State: TDragState; Pt: TPoint; Mode: TDropMode; var Effect: Integer; var Accept: Boolean); begin Accept := True; if Shift = [ssCtrl] then Effect := DROPEFFECT_COPY; end;
In the OnDragDrop event OnDragDrop you can determine the effect that was used:
procedure TForm1.VirtualStringTree1DragDrop(Sender: TBaseVirtualTree; Source: TObject; DataObject: IDataObject; Formats: TFormatArray; Shift: TShiftState; Pt: TPoint; var Effect: Integer; Mode: TDropMode); begin case Effect of DROPEFFECT_COPY: ShowMessage('DROPEFFECT_COPY'); DROPEFFECT_MOVE: ShowMessage('DROPEFFECT_MOVE'); end; end;
TLama source share