ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
ShellControls.TJamShellList.OnBeforeShellCommand

This event occurs, before a context menu command is executed.

Syntax
Pascal
property OnBeforeShellCommand: TOnBeforeShellCommand;

This event is triggered if a command from the context menu should be executed. It was either chosen from the shell context menu or triggered by a keyboard event.

procedure TMainForm.ShellListBeforeShellCommand(Sender: TObject;
  const Command: string; Items: IItemIdListCollection;
  var AllowExecute: Boolean);
begin
  if Items.Count <> 1 then
    exit;
  //suppress the default action for text files. 
  if (TShellCommand(Command) in [TShellAction.saDefault, TShellAction.saOpen]) and
    (UpperCase(ExtractFileExt(Items[0].Path)) = '.TXT') then begin

    AllowExecute := false;

    //additionally you might handle the action yourself.
    ShowMessage('Custom action');
  end;
end;