Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Sat Apr 19, 2008 6:12 am Post subject: HOWTO : Insert menu items at a non-default position in the contextmenu using a context menu extension |
|
|
By default, the ShellMenu.AddItem method adds menu items at a position specified by Windows. This position is stored in the StartIndex member of the GetMenuitemsEventArgs instance which is passed to the OnGetMenuItems method.
To add a menu item at another position, use ShellMenu.InsertItem method instead. The last parameter of this function specifies the 0-based position where the menu item will be inserted
[ C# ]
// Override following method to add your menu items to the context menu
protected override void OnGetMenuItems(LogicNP.EZShellExtensions.GetMenuitemsEventArgs e)
{
e.Menu.InsertItem("Menu item A", "menuitemA", "Menu Item A", 13);
//The last parameter specifies the 0-based position of the menu item in the context menu
}
[ VB .Net ]
' Override this method to add your menu items to the context menu
Protected Overrides Sub OnGetMenuItems(ByVal e As LogicNP.EZShellExtensions.GetMenuitemsEventArgs)
e.Menu.InsertItem("Menu item A", "menuitemA", "Menu Item A", 13)
'The last parameter specifies the 0-based position of the menu item in the context menu
End Sub |
|