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.

            Internet Explorer


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"

            Internet Explorer
                    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


  • API

    Posted by Legacy on 07/07/2003 12:00am

    Originally posted by: Mobeen

    But I want to Disable the IE toolbar and some options from menue bar , Is there any API thru which I do this thanx

  • How to host a web browser control from an MFC Application

    Posted by Legacy on 11/29/2002 12:00am

    Originally posted by: chandrika


  • How to test ActiveX Control creating VC++ using ATL in internet

    Posted by Legacy on 11/12/2002 12:00am

    Originally posted by: swaminathan

    How to test ActiveX  Control creating VC++ using ATL in internet

  • Hightlight text, right click on it and have that text searched at a particular search engine.

    Posted by Legacy on 04/10/2002 12:00am

    Originally posted by: Corey Laliberte


    I have an idea that could save lots of time. I want to be able to highlight a piece of text and have that text searched at a particular search engine. Most of the time it is appended to the search engine URL at the end. I was wondering if there was a way to do this? What would I need to do in order for this to occur?

    Corey Laliberte

  • How can i use beforenavigate2...?

    Posted by Legacy on 03/07/2002 12:00am

    Originally posted by: Vishal

    i'm trying to use beforenavigate2 event of shdocvw.dll in vc++ , but i could not create a proper smart pointer as
    it shows functions in class but it gives compile time error
    that function not found , plz let me know how to solve this problem
    thanks and regards,

  • Adding Sub-menus to the IE context menu

    Posted by Legacy on 02/12/2002 12:00am

    Originally posted by: Stuart Menzies

    I can add extra menu items onto my IE context menu.  
    Does anyone know how to add second/third/fourth level menu options onto these.

    i.e. I have created menu items at the following level:
    Internet Explorer
    Home = "www.mysite.com"

    but, can I add sub menus off of the 'home' level ???

    Thanks in advance

    Stuart Menzies

    PS a previous question asked how to call an exe :

    Just call it within a html page with some VBscript or Javascript, like :

    <SCRIPT LANGUAGE="VBscript" defer>
    Set WshShell = CreateObject("WScript.Shell")
    WshShell.Run "C:\\Folder\\Program.exe ", 1,0

  • How can I embed a browser into my c++ app WITHOUT mfc ???

    Posted by Legacy on 01/26/2002 12:00am

    Originally posted by: Lutz Rosema


    I'm trying to embed a browser without MFC, but MS has no sample sourcecodes :(

  • Screen scraping

    Posted by Legacy on 01/10/2002 12:00am

    Originally posted by: Frank

    I want to pull down a page and parse the contents to pass selected data to a speech engine. FOr instance, I want the system to read me the weather forecast. Suggestions on how to accomplish this or sample code showing capture of the page would be great. Thanks.

  • How about running an application instead of an URL?

    Posted by Legacy on 10/19/2001 12:00am

    Originally posted by: Dacy

    Is there a way to write as a default value for Home key something like: Home = "c:\myapp.exe"? I've tried but nothing happened...

    Thank a lot,

  • i can't find subdirectory res and its files, i am crying...

    Posted by Legacy on 04/03/2001 12:00am

    Originally posted by: Ida Zhang

    i can't find subdirectory res and its files, i am crying...

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • Enterprises are increasingly looking to platform as a service (PaaS) to lower their costs and speed their time to market for new applications. Developing, deploying, and managing applications in the cloud eliminates the time and expense of managing a physical infrastructure to support them. PaaS offerings must deliver additional long-term benefits, such as a lower total cost of ownership (TCO), rapid scalability, and ease of integration, all while providing robust security and availability. This report …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date