Click or drag to resize

JamBaseShellListViewBeforeShellCommand Event

This event is fired when a shell command is to be executed, ie. via the context menu It is possible to permit the execution of the shell command by modifying the BeforeShellCommandEventArgs

Namespace:  Jam.Shell
Assembly:  ShellBrowser (in ShellBrowser.dll) Version: 7.1
Syntax
public event EventHandler<BeforeShellCommandEventArgs> BeforeShellCommand

Value

Type: SystemEventHandlerBeforeShellCommandEventArgs
Examples
Shows the analogue usage of the BeforeShellCommand event.
C#
using (ShellBrowser shellBrowser = new ShellBrowser(lFilePath))
{
    //The following code shows some variants to stop a context menu item from being executed.
    shellBrowser.BeforeShellCommand += (s, e) =>
    {
        if (e.Verb == ShellCommand.Open)
            e.Cancel = true;
        //this is equivalent to:
        if (e.Verb == ShellContextMenuCommand.Open)
            e.Cancel = true;
        //or
        if (ShellCommand.IsOpen(e.Verb))
            e.Cancel = true;

        //not all context menu commands have a "verb". If it is empty, then you can at least access the caption:
        if (ShellCommand.IsEmpty(e.Verb))
            System.Diagnostics.Debug.WriteLine(e.Verb.Caption);
    };
    shellBrowser.ShowContextMenu(Cursor.Position);
}
See Also