Implementing Web Browser Band Using ATL HTML Control

The Web Browser Bands were introduced in IE 4.0 , they provide a child window (can be both Horizontal and Vertical ) within the main explorer window. The Search, History and Favourites bars are examples of this bar.

These bands can be used to customise the explorer, to display information and for taking user input.

To create these bars we have to implement and register a band object. The band objects are COM objects which exist inside a container (i.e IE for Explorer Bars). Two main aspects for these band objects are: 

a) How they are registered
Bands must be registered as an OLE in-process server that supports apartment threading, the band objects must be registered for appropriate component category. The category determines the object type and it's container: The Vertical Explorer Bar requires registration in CATID_InfoBand and the Horizontal Explorer Bar requires registration in CATID_CommBand.

b) The interfaces they expose
The interfaces a band object must implement are IDeskBand, IObjectWithSite and IPersistStream. We will get into the specifics of interfaces later in the article. If the band object is to accept user input it has to implement IInputObject  and for a context menu it has to implement IContextMenu.

About the ATL HTML Control

The HTML control hosts the Intrenet Explorer WebBrowser control thus giving you access to script parsing, rendering and browsing fcilities of IE. By default the user interface of the control is provided by the WebBrowser Control, this covers the entire area of the control. The UI is rendered based on the HTML included in the resource of your project.

The control exposes two interfaces: one is for the clients of the control and the other with an UI suffix is used to extend the object model of the Web Browser(being hosted by our control). The script which can access the object model can also access this interface (as window.external) and can call its functions .Your C++ code can access the object model in this function . This communication process can be exploited to accomplish a variety of tasks. For further details on HTML control Dr Richard Grimes book (Professional ATL COM Programming) is the panacea.

About Registration:

For object registration as in-process server I have used the code provided by ATL. For Registring the band object for Category CATID_InfoBand (for Vertical Explorer Band) I have used interface ICatRegister exposed by the Component Categories manager object CLSID_StdComponentCategoriesMgr.

About the Interfaces:

IObjectWithSite This is very critical interface. The explorer calls the IObjectWithSite::SetSite Method passing its site's unknown pointer.The following things are achieved during this call.
If the pointer being passed is not NULL  then site is being set , using this pointer i obtain the IOleWindow Interface and get the parent window's handle and store it. I then create my HTML control as child of this window. I store the pointer to IInputObject site Interface for use later.Also I obtain a pointer to the IWebBrowser2 interface of the IE (parent) and store for use later.The IObjectWithSite::GetSite wraps call to sites QueryInterface.
IPersistStream Since there is no persistent data there is only minimal implementation of this interface.
IDeskBand This interface inherits from IDockingWindow and IOleWindow.The IOleWindow::GetWindow returns the child window handle and ContextSensitive help is not implemented .The IDockingWindow::ShowDW and CloseDW have been implemented but ResizeBorder is not required to be implemented.The IDeskBand::GetBandInfo is used by Explorer to specify the Explorer Bar's identifier and viewing mode.It also may request one or more pieces of information by filling the dwMask member of the DESKBANDINFO structure that is passed as the third parameter

Interaction With the Script:

I have implented a function named OnNag( ) of the interface ICHTMUI (the interface used by the webbrowser control as explained earlier).The script calls this finction passing the dispatch pointer to the HTML anchor element and the string representing the site to navigate to.I use the IWebBrowser2 interface pointer stored earlier to navigate to the site.Thus a click in the Band object causes navigation in the main IE Window.

The band.dll can be downloaded and registered .The menu item is added in View | Explorer Bars. On selecting the menu the Explorer bar is created .The explorer bar has links to some sites, to which one can navigate( in the main IE Window) by clicking on them

The project can be downloaded and by modifying the HTML resource (carefully) you add your own links and customise the GUI of the band.

References:

The article "Creating Custom Explorer Bars and Desk Bands" in SBN

Download demo project - 27 KB

Download DLL - 9 KB



Comments

  • How to create Toolbar/Menubar in IE using VB

    Posted by Legacy on 01/27/2004 12:00am

    Originally posted by: BRajesh

    Hi
    
    I am BRajesh, I need u'r help regarding VB.

    I want how to add my own toolbar/menubar in IE or Outlook
    express using VB. I have done in MS Outlook. But I want
    Outlook express/IE. It's possible. But how?. If u find any
    idea else u have any source code?, please help me.

    Hope u to the needful for me

    Thanks
    BRajesh

    Reply
  • flash in my web browser

    Posted by Legacy on 11/17/2003 12:00am

    Originally posted by: thesuperdummy

    I call up a web page into my browser in c#. This web page plays a flash .swf file. When i click anywhere in the browser, the focus goes to a textbox. But when I click the embedded flash .swf, it doesn't, i'm assuming because the flash file is it's own component.
    How do I pass the focus back to the web browser component when I click the embedded flash .swf???
    Would I need to reference the Flash component somehow???

    Reply
  • How to disabled right click of webbrowser control in vb

    Posted by Legacy on 10/29/2003 12:00am

    Originally posted by: Yogesh Jawanjal

    can anybody tell me how to disabled right click of web browser control in visual basic

    Reply
  • how to raise powerpoint action in webbrowser

    Posted by Legacy on 10/13/2003 12:00am

    Originally posted by: archana

    Hi,


    I am using webbrowser as container for powerpoint in vb6. How can i run an exe which has been set as action there.

    Thanks
    Archana

    Reply
  • How can I set the size of my toolband dynamically?

    Posted by Legacy on 08/19/2003 12:00am

    Originally posted by: SaiSrinivas

    Hi
    I need to set the size of my toolband at runtime.Can you sujject how to do it?

    Thanks
    Sai

    Reply
  • How do i add tool button on a band object

    Posted by Legacy on 06/30/2003 12:00am

    Originally posted by: Vishwas Gupta

    i have added a band object to explorer.now i want to add some some buttons on it. how can i.
    if someone knows about it ..please help me out.

    thanx in advance !
    vishwas gupta

    Reply
  • Add FullScreen to IE contextmenu?

    Posted by Legacy on 06/05/2003 12:00am

    Originally posted by: geekmee

    How can I add the Fullscreen on/off functionality to the IE contextmenu?

    I just barely know enough VBScript to get me in trouble.

    Thanks.

    Reply
  • Uninstall band

    Posted by Legacy on 06/03/2003 12:00am

    Originally posted by: Martin

    Hi. How do I uninstall the "Morning Band"?


    / Martin

    Reply
  • Minimum explorer bar size

    Posted by Legacy on 03/22/2003 12:00am

    Originally posted by: dgmikes

    How can I create a very very thin vertical explorer bar? The minimum width I can get is 76 (or so) pixels - I want like 12 pixels.

    Reply
  • Win32 ToolBand in Explorer

    Posted by Legacy on 01/31/2003 12:00am

    Originally posted by: Mark Hibbert

    I have created a ToolBand using Win32 C++, when I install it, it works fine in IE. But when I go into My Computer and select it from here, the application bombs out with an 'Application Error' and that's it.

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

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • Due to internal controls and regulations, the amount of long term archival data is increasing every year. Since magnetic tape does not need to be periodically operated or connected to a power source, there will be no data loss because of performance degradation due to the drive actuator. Read this white paper to learn about a series of tests that determined magnetic tape is a reliable long-term storage solution for up to 30 years.

Most Popular Programming Stories

More for Developers

RSS Feeds