Creating Band Object Using ATL HTML Control ++

Environment: VC6 SP4, Windows 2000 SP2, IE55 Header files

There have been quite a few articles about Band Object already. However, when I was building my own band object, it sometimes took days just to search for the solution to a minor problem in creating a band object. Some of the articles provide the information about how to do this, but skips other steps; some show how to do this one thing, but it assumes that you know how to do all the steps prior to doing that. For this reason, I decided to put what I have done with band object together as a sample. I hope this article would be of help in saving some of you from being frustrated.

The Basics

Band objects are essentially COM objects that exist within a container. The container of a band object depends on the type to which the band object belongs. If the band object is a tool band, it will be contained by the Rebar Control that holds Internet Explorer's toolbars; if it is an Explorer Bar, it will be contained by Internet Explorer. Despite the difference between their functionalities, their basic implementations are similar. What really makes the difference is how the band object is registered, which in turn controls the type of the object and its container.

Since a band object is a COM object, it must implement IUnknown interface. In additional to IUnknown interface, all the band objects must implement IDeskBand, IObjectWithSite, and IPersistStream interfaces. A band object must also implement IInputObject interface, if it is to accept user input. To add items to the context menu, it must implement IContextMenu interface. Because band objects implement a child window, they must also implement a window procedure to handle Windows messaging. The window procedure can be implemented by using ATL message map (see sample code for more detail).

Registration

In addition to having their CLSIDs registered, the Explorer Bar and desk band objects must be registered for the appropriate component category. As previously mentioned, registering the component category determines the object type and its container. Tool bands do not have a CATID. The CATIDs for the three band objects that require them are:

Please reference to sample code for more detail (CGBand.cpp).

Frequently Asked Questions

When I am poking around CodeGuru and some other websites dedicated for developers, I often see people asking questions about band objects. Some of those questions that are frequently asked are:

  • Installed Explorer Bar not displayed in taskbar shortcut menu
  • How to automate Internet Explorer from a band object?
  • How to extract the HTML documents?
  • How to handle events fired by Internet Explorer?
  • How to solve 'window.external' problem?

The cause to the first problem is due to the Windows 2000 shell caches the available desktop band objects and only updates this cache if it senses that an installation application is run or if the cache location in the registry is not present. To solution proposed by Microsoft is to install your band object from an application that has the name Setup.exe or Install.exe. If the proposed solution is not feasible, you need to delete the following keys in Windows Registry before or after you install your band object:

HKEY_CLASSES_ROOT\\Component Categories\\{00021492-0000-
0000-C000-000000000046}\\Enum

HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Current
Version\\Explorer\\Discardable\\PostSetup\\Component
Categories\\{00021493-0000-0000-C000-000000000046}\\Enum

HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Current
Version\\Explorer\\Discardable\\PostSetup\\Component
Categories\\{00021494-0000-0000-C000-000000000046}\\Enum

I have included the solutions to other problems in the sample code. The solution to the 'window.external' problem is based on the resolution proposed in Q202009, in which Microsoft confirmed the problem to be a bug.

A Sample Implementation

In additional to demonstrating how to implement an Explorer Bar, this sample implementation also shows:

  • How to automate a Internet Explorer from a band object
  • How to extract HTML documents
  • How to handle the events fired by Internet Explorer from a band object
  • How to fix a bug that causes an error when accessing 'window.external' in an ATL DHTML control

For changing the title of the band object (Explorer Bar), look for CCGBandObj::GetBandInfo. For changing the title shown in taskbar shortcut menu, look for CGBandObj.rgs. For registration, look in CGBand::DllRegisterServer. For event handling, look in CCGBandObj::SetSite.

References

Downloads

Download demo project - 54.6 Kb
Download source - 50.1 Kb


Comments

  • Opening Link in Main Browser

    Posted by maverick786us on 03/14/2011 10:23am

    I made a slight modification with your code. Instead of buttons, its using hyperlinks. But when I open those hyperlinks, it opens in its own window. How can I make it open those links in the main window?
    
    Thanks in Advance

    Reply
  • Auto/Manual Load/Unload ?

    Posted by TBoneX on 07/04/2006 09:57am

    Great article. I created a deskband myself (taskbar) which works fine. However, after installing it (e.g. via regsvr32.exe /c deskband.dll ) and rebooting, explorer wont load it automatically. The user has to right-click onto the taskbar and choose "Toolbars" and then select the toolbar in order to activate it. How can I do programatically make explorer loading/unloading my deskbar and/or autoload it on startup? Any help would be greatly appreciated TBone

    Reply
  • Release crush

    Posted by ethan on 07/17/2004 10:14pm

    when compile release config, opening band in ie throw exception. why?

    Reply
  • How do I intercept keystroks

    Posted by yirgalem on 06/02/2004 11:43am

    I know the first answer already... which is to implement IOleControlSite and IInputObject and override some functions as demonstrated in http://www.microsoft.com/mind/0499/faq/faq0499.asp. I did all that and I still don't have any luck. I think it may be because the control is passed to CUICGBandObj in your sample and the CCGBandObj instance would not receive the events. In any case, I really need help so I can allow user to hit tab to get from one input control to another on the HTML page on the explorer bar, as well as be able to delete characters in text boxes in the HTML page. Please help... -Dan

    Reply
  • How can I add ActiveX control on IE BAND

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

    Originally posted by: Balkrishna Talele

    After completing my creation of band, I want to Add IWebBrowser View on that band , so that I should be able to scroll the Html tags or I can Marquee the html tags on that Activex Control. But this should be on the IE BAND...how to do that.
    thnaks
    Balkrishna Talele

    Reply
  • Win32 Unicode ?

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

    Originally posted by: Shashank Sharma

    For deployment on Win XP, should "Win32 Unicode" configuration be used ?
    

    Reply
  • Language Support for ATL

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

    Originally posted by: Ahmed Birry

    does the Supports Arabic language ??? if any body here can help please !!!

    Reply
  • Pls Help me :Plugging Active X Controls in IE toolbar

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

    Originally posted by: Arivu

    Dear all,
    
    

    I'm a beginer in VC++ development side.Could anybody help me to plug an Active X Control in IE tool bar?.It is a very urgent task..
    If you help me,it will save my job.

    Thanks,
    Arivu

    Reply
  • Developing Search ToolBar for IE

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

    Originally posted by: Vipin Singh

    I want to develop a toolbar for IE 5.0 and above. Can you please tell me how can I do it or is any one having a sample code that can attach a toolbar to IE window. Pls. reply as soon as possible as this is urgent. Any help will be greatly appreciated.

    Thanks,
    Vipin.


    Reply
  • How create tool band?

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

    Originally posted by: Nickolay

    How create tool band for IE?

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Agile methodologies give development and test teams the ability to build software at a faster rate than ever before. Combining DevOps with hybrid cloud architectures give teams not just the principles, but also the technology necessary to achieve their goals. By combining hybrid cloud and DevOps: IT departments maintain control, visibility, and security Dev/test teams remain agile and collaborative Organizational barriers are broken down Innovation and automation can thrive Download this white paper to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds