Creating Band Object Using ATL HTML Control ++
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
- Creating Custom Explorer Bars, Tool Bands, and Desk Bands
- Explorer Bar Style Guide
- Q202009, BUG: Error Accessing Window.external in ATL DHTML Control
- Q214842, PRB: Installed DeskBand Not Displayed in Taskbar Shortcut Menu
- Q247705, PRB: Explorer Bar Does Not Appear in Internet Explorer 5.01
Downloads
Download demo project - 54.6 KbDownload source - 50.1 Kb

Comments
Opening Link in Main Browser
Posted by maverick786us on 03/14/2011 10:23amAuto/Manual Load/Unload ?
Posted by TBoneX on 07/04/2006 09:57amGreat 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
ReplyRelease crush
Posted by ethan on 07/17/2004 10:14pmwhen compile release config, opening band in ie throw exception. why?
ReplyHow do I intercept keystroks
Posted by yirgalem on 06/02/2004 11:43amI 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
ReplyHow can I add ActiveX control on IE BAND
Posted by Legacy on 01/06/2004 12:00amOriginally 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.
Replythnaks
Balkrishna Talele
Win32 Unicode ?
Posted by Legacy on 09/09/2003 12:00amOriginally posted by: Shashank Sharma
ReplyLanguage Support for ATL
Posted by Legacy on 08/04/2003 12:00amOriginally posted by: Ahmed Birry
does the Supports Arabic language ??? if any body here can help please !!!
ReplyPls Help me :Plugging Active X Controls in IE toolbar
Posted by Legacy on 01/11/2003 12:00amOriginally posted by: Arivu
ReplyDeveloping Search ToolBar for IE
Posted by Legacy on 10/23/2002 12:00amOriginally 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.
ReplyHow create tool band?
Posted by Legacy on 10/15/2002 12:00amOriginally posted by: Nickolay
How create tool band for IE?
ReplyLoading, Please Wait ...