Extending the IE Context Menu in your App using the Registry

.

The sample code given is compiled using Visual c++ 5.0, Windows 95

Internet Explorer 4.0 uses OLE Activex control and Active
Document interfaces to connect components.I will just briefly
talk about the Internet Explorer’s architecture. Mainly Internet
Explorer is just a small application which uses the internet
explorer 4.0 components for favourites maintenance,history
maintaenance and so on. This executable directly hosts the
SHDOCVW.DLL which is nothing but the web browser control.
SHDOCVW.DLL in turn hosts the MSHTML.DLL. Implementing the
webbrowser control is little bit difficult than implementing the
MSHTML.DLL.

MSHTML.DLL performs the HTML parsing and rendering in Internet
Explorer 4.0 and also exposes the HTML document through the
Dynamic HTML Object Model. This DLL hosts the scripting engines,
Java VM, ActiveX Controls, Plug_Ins, and the other components
that may be referenced in the HTML Document that is loaded. This
DLL implements the Active Document Server interfaces which allows
users to host this DLL using standard COM interfaces.

But if we host MSHTML.DLL then we should implement some of the
features which are already in the webbrowser control. I stop with
this and go on to explain our topic of this article. If any body
wants to study more about the internet explorer 4.0 architecture
and how to explore it then install INETSDK which is available for
download in the http://www.microsoft.com
or install it from the MSDN CD Pack.

If we write an application using WebBrowser Control. To learn
how to use WebBrowser Control refer to the article by Daniel
Harth http://www.codeguru.com/internet/webbrowser_control.shtml
Then if we right click on the window the webbrowser control will
display the default internet explorer’s context menu. But if we
want to modify it then what should we do? The answer is simple
just go to the windows registry and add a new menu item. Going
Crazy!! Just wait a moment I will explain. We can also control
the context menu programmaticallly which at present I am
exploring. I will update that later.

Menu Items can be added to the existing context menus of the
WebBrowser by placing entries in the registry and linking these
to URLs that execute what you want. To add additional items to
the standard WebBrowser context menus, open the following key.
Dont panic if you don’t have one just create it right there.


 HKEY_CURRENT_USER
    Software
        Microsoft
            Internet Explorer
                MenuExt

 

Under this key create another key which contains the text to be displayed in the menu.

The default value of this key will contain the URL which will be executed when the user selects this menu item.

The key name can include the ‘&’ character, which will
cause the character immediately following the ‘&’ to be
underlined. The URL will be loaded inside of a hidden HTML dialog
box, all of the script will be executed, and the dialog will be
closed. The hidden HTML dialog’s external.menuArguments
property contains the window
object of the window on which the context menu item was executed.

The following registry entry will add an item with the title
"Home" to the WebBrowser context menu and will execute
the URL "http://www.microsoft.com"

HKEY_CURRENT_USER
    Software
        Microsoft
            Internet Explorer
                MenuExt
                    Home = "http://www.microsoft.com"

 

The sample application hosts the WebBrowser control. Just add these entries in your windows registry and then run the sample application.In the application window right click and see the context menu "home" menu will be displayed.

If you find any bugs in this article or any comments feel free to mail me.

Download Sample (27 kb)

Article added on June 21 1998

More by Author

Must Read