ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
ShellBrowser.TOnBeforeShellCommand

The event that is fired before a shell command is executed.

Syntax
Pascal
TOnBeforeShellCommand = procedure (Sender: TObject; const Command: String; Items: IItemIdListCollection; var AllowExecute: Boolean) of object;
Parameters 
Description 
Sender 
The executing ShellBrowser. 
Command 
The command that is executed. TShellBrowser.InvokeContextMenuCommand for a list of commands. 
Items 
The affected Items. 
AllowExecute 
Set this to false if you don't want the command to be executed. 
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;