event BeforeShellMenuCommand (Command as String, ID as Long, Cancel as Boolean)
Fired before a context-menu item is executed.

 TypeDescription 
   Command as String A string expression that specifies context menu item selected.  
   ID as Long A long integer that represents the unique ID of selected menu item.  
   Cancel as Boolean A boolean expression that, if set to True, execution of selected context menu item will be denied. If set to False, menu item will be executed.  

Right clicking on a folder results in the folder's context menu being displayed. If some item from this menu is selected, the control fires a pair of events to notify you. Before the menu item is executed, this event is fired. After the menu item is executed, AfterShellMenuCommand event is fired.

When this event is fired, you may deny execution of the selected menu item. Command variable holds name of selected menu item, and nID variable holds its unique index inside menu-items collection. Depending on user's choice, setting Cancel value to True will deny execution of selected menu item.

When checking Command's value, please keep in mind that some menu items have underscored letters. For example, 'Open' menu item usually have letter 'O' with underscore, which means that pressing ALT+O will result in executing of 'Open' command. Such underscored letters are stored internally in Windows OS by prefixing such letter with a '&' sign. So, if you check Command, don't forget to include this sign into string you will check Command with.

Following following code will not work correctly:

   If Command = "Open" Then MsgBox "Folder will be opened"

because '&Open' and 'Open' is not the same string. Rather, use this line (tested in VB):

   If Command = "&Open" Then MsgBox "Folder will be opened"


Send comments on this topic.
© 1999-2006 Exontrol Inc, Software. All rights reserved.