Customize Internet Explorer main menu,
add IE context menu commands: VB.NET, C#
Add-in Express™ Add-in Express Home > Add-in Express for Internet Explorer > Online Guide > Customizing IE main menu and context menus Customizing IE main menu and context menusAdd-in Express allows customizing any top-level item of the Internet Explorer main menu and adding custom context menu items in IE6, IE7, IE8, IE9, IE10 and IE11. Customizing Internet Explorer main menuYou add an ADXIEMainMenu component onto the IE module and use the property editor of the ADXIEMainMenu.Items property to add a custom item to a specified top-level menu item (of the ADXIEMainMenuItem type). The required steps are listed below. Right-click the designer surface of the IE module and choose Add Main Menu in the context menu. This adds an ADXIEMainMenu component onto the IE module. In the Properties window, open the property editor of the ADXIEMainMenu.Items property. In the property editor window, add an ADXIEMainMenuItem specifying a top-level item in the BuiltinMenu property; top-level menu items are File, Edit, etc. Select the top-level item, add an ADXIEMenuItem and set its properties. In this sample project, we set the properties as shown below: Now you can handle the OnClick event of the ADXIEMenuItem. The sample code below demonstrates showing / hiding an IE bar. The same approach is applicable for an Internet Explorer toolbar. VB.NET
Note that specifying the ADXIEMenuItem.Shortcut property requires setting the HandleShortcuts property of the module to true. When IE creates its main menu, ADXIEMainMenu receives the OnCreateMenu event. Then all top-level menu items receive the OnCreatePopupMenu event. Also, just before a menu item is created and shown, it receives the OnCreateMenuItem event. And finally. It's not possible to create a custom top-level menu item. Custom item in Help menuYour custom item added to the Help menu of Internet Explorer can look similar to this: Customizing IE context menusTo create a custom context menu item, add an item to the ContextMenu collection of the IEModule and specify the item's properties: caption and contexts available for the context menu item. Naturally, you need to handle the Click event of the context menu item. Pay attention to the Contexts and ExtendedContexts properties of top-level context menu items; you can use these properties for refining the context-sensitivity of your context menu items. Say, if you choose Anchor in the Contexts property, you will be able to choose Anchor and Link in ExtendedContexts. In the same fashion, you can limit your context menu items to any given HTML control type(s). When Internet Explorer creates its context menu for the first time, the OnCreateContextMenu event of the IE module is raised; you can use this event for any sort of initialization. Before a given context menu item is created, it receives the OnCreateContextMenuItem event; at this moment you can change its visibility, caption, position, etc. The sample code below shows how to get the right-clicked and selected elements: VB.NET
The MyWinApiWindow type above is a simple class implementing the System.Windows.Forms.IWin32Window interface (see below). The window handle for MyWindow is supplied by the ParentHandle property of the module that returns the handle (hwnd) of the tab window. Note that you must show messages in this way; otherwise your message box may be shown behind the IE window. VB.NET
C#
Custom item added to IE context menuYour custom item in the context menu of Internet Explorer can look like this: |