ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
ShellControls.TJamShellList.OnShellDragOver

Allows you to influence the Drop Operation that is performed when dropping a shell item.

Syntax
Pascal
property OnShellDragOver: TOnShellDragOverEvent;

Changing CopyMode temporary overrides the AllowedDropEffects setting. Please note when setting CopyMode to anything the drop target does not support the drop operation will fail. If CopyMode is set to e.g. TJamDropEffect.deLink and the drop target supports it dragging with the right mouse button will only show up the possibility to create a link.

In the following examples dragged items will be copied by default unless dragging is executed with the right mouse button or Shift is pressed at the same time.

procedure TMainForm.ShellListShellDragOver(sender, DropTarget: TObject;
  DroppedFiles: TStrings; KeyState, X, Y: Integer; var CopyMode: TJamDropEffect);
begin
  if CopyMode = deNone then
    exit; //do not change the drop action for items that cannot be handled by the shell.

  if (KeyState and MK_LBUTTON = MK_LBUTTON) then begin //only handle left button actions
    if (KeyState and MK_SHIFT = MK_SHIFT) then //if Shift is pressed move the dragged objects
      CopyMode := deMove
    else
      CopyMode := deCopy; //if shift isn't pressed, always copy, disregarding if it's on the same drive or if other keys are pressed.
  end
  else
   CopyMode := deDefault; //if the right button is pressed, let user decide which action to take
end;

This example illustrates custom handling of items that are not automatically handled by the shell.

procedure TMainForm.ShellListShellDragOver(sender, DropTarget: TObject;
  DroppedFiles: TStrings; KeyState, X, Y: Integer; var CopyMode: TJamDropEffect);
begin
  //allow single pdf files to be dragged over existing pdf files.
  if (CopyMode = deNone) then begin
    if (DropTarget is TJamShellListItem) and (Uppercase(ExtractFileExt(TJamShellListItem(DropTarget).FullPath)) = '.PDF')
      and (DroppedFiles.Count = 1) and (Uppercase(ExtractFileExt(DroppedFiles[0])) = '.PDF')
    then
      CopyMode := deCopy;
  end;
end;