views:

30

answers:

1

I need to add one menu item in IE context menu. It is similar with Google customized context menu "Search Google for xxx" when you right click on IE.

I did a research and found that overriding IDocHostUIHandler::ShowContextMenu in a IE BHO can customized IE context menu. The sample project can be found in Popup blocker project published in codeproject. It works well and is easy to implement. However this approach has a problem. The problem is it will conflict with other add-ons' context menu customization per MSDN.

In MSDN Internet Explorer Center forum, there are some discussions about this topic. However there is not a proper implementation posted.

If anybody has experience on this, please share your idea. Thanks!

+1  A: 

See Adding Entries to the Standard Context Menu on MSDN.

For some sample code, download and extract the Web Accessories for Internet Explorer 5 (the mechanism still works in IE versions up to and including 8). Look at ie5wa.inf and *.html for examples of various IE context menu extensions.

Note that the abive is achieved without COM, purely via one registry setting and a file containing a blob of script (Javascript, JScript, VBScript etc.) The script (JScript, VBScript) may in turn work with COM objects, should your menu action logic reside in such an object, e.g.

  • create a HKCU\Software\Microsoft\Internet Explorer\MenuExt\My &Context Menu" registry key (&` precedes the menu accelerator letter, if any)
  • set the default value for the key to point to a file containing the script code implementing the context menu action(s), possibly interacting with a COM object (must support IDispatch IIRC; also read up on the My Computer Security Zone)
  • create a binary contexts value (0x02 for images, 0x10 for selections, etc.) which regulates when the new context menu should be displayed

Cheers, V.

vladr