Sample Explorer Toolbar

Create an IE toolbar almost with VB

Download goes here. If you like it, rate it here.


Functionality  Prerequisites  Installation  Usage  How it works  Open issues  Change log


News as of October 2004

The sample toolbar has been enhanced seriously. I added a textbox and a button thus answering lots of questions how to deal with this more complex UI. This required the focus handling to be revised. It now became more generic so that your code in frmToolbar can fully concentrate on the business logic. You can tab from the toolbar to other IE areas and back to the same toolbar control. You can now use accelerators to trigger button clicks.

Additionally the coding has been enabled for Log4VB. This allows you to track which functions are called when and allows to trouble-shoot your toolbar even at the customer site. Log4VB comes as freeware and shareware version. If you like my toolbar you may honor this by licensing Log4VB.


Functionality

You want to have your own IE toolbar like Google or eBay? Writing Explorer Toolbar with pure VB seems to be one of the last challenges in the VB world. I tried hard and I guess came a step further compared to Eduardo Morcillo's 'Shell Extension' code. The main difficulty is that the CoolBar in the Common Control ActiveX component doesn't support variable-length buttons, which makes it more or less useless for an Explorer toolbar implementation. This forces you to use API calls to create the toolbar. Eduardo's go-ahead was to create the textbox on the toolbar via an API call as well. I wanted to avoid this because this makes it more difficult to handle events and set attributes of the textbox. My code re-uses the textbox from a VB form. Additionally it takes the dropdown menus associated with the two toolbar buttons from the same VB form. Another difficulty was to handle certain accelerator keys like Backspace within the toolbar. I found a simpler solution for this compared to Eduardo's code.

The toolbar has a very simple functionality. I simply wants to show how you can build one with as much VB as possible. 


Prerequisites
  • VB6 runtime (naturally)
    Download
  • The VB project makes use of Eduardo's OLELIB.TLB and OLELIB2.TLB. To avoid a version hell please download the typelib stuff directly from Eduardo's site. Make sure to copy both to \Windows\System32. This is only required when you want to recompile the VB project. It is not required at runtime.
    Download.
  • mscomctl.ocx needs to be installed. This is the case on most machines that ever ran a VB-compiled program. If not, use:
    Download
  • The code was developed under Window XP / IE6. I tested it hasty with Win2k/IE5.0 and Win98/IE 5.0 and it worked. A problem with the latter was fixed in version 1.0.3.

Installation

This page is intended for developers, who want to build their own toolbar. Therefore the installation procedure described here is a manual one. Download the ZIP file containing the binaries and sources. Compile the project SampleBar.vbp to a DLL or register the DLL in the download package. Be sure to refer to have the Version Compatibility set to Binary or Project Compatibility. Merge the file install.reg into the registry. This tells IE about the new toolbar. Open a new IE window. Go to New > Toolbars in the IE menu and switch on "Klemid's Sample Toolbar". After that, the new toolbar should appear.

!!! The latest version (1.71) of Edanmo's olelib.tlb and olelib2.tlb needs to reside in \Windows\System32 actually. Any other directory is not sufficient. Sorry for any inconvenience!


Usage

Seeing the new toolbar in IE, click into the text field, type a search value, and choose an item from the "Search At" menu. After a while the search result page should appear. You may also use Alt+K and Alt+S while the cursor is in the textbox. When you want to add new items to the "Search At" menu, you need to modify the code, currently. Asap I will provide a more sophisticated version of the toolbar on my Web site, which lets you customize the search sites.


How it works

Please inspect the source code for detailed explanations.

One frequently asked question:
When you clone my project to make your own, it's not quite obvious how to change the name appearing in the View > Explorer Bar. You need to change the description attribute of the CToolbar class. You can do this either in the VB Object Browser or by changing it in the source file clsToolbar.cls (using notepad not VB!).


Open issues (as of 02-Jul-2003)
  • It is not possible to get into the toolbars textbox using an accelerator key like it works with ALT+d and IE's address field.
  • I would be great if the textbox would resize with the toolbar. However, this is not supported.
  • The code involves subclassing (implementation taken from www.vbaccelerator.com). Debugging some areas of the code may therefore cause the application to freeze. To avoid this use the project SampleBar_debug.vbp. This project uses the COM object Subclassing.dll for subclassing. This DLL is contained in the ZIP. However you need to register it.
  • If an empty toolbar appears after the installation, most likely mscomctl.ocx is missing on your machine.
  • If there is no toolbar "Klemid's Sample Bar" appearing under View > Toolbars you either missed the step involving install.reg or the Explorer version is not appropriate.
  • Some downloaders experienced compile problems. An error [BadImplementsRefInCompatLib] occurred. This can be circumvented by compiling only with project compatibility. I'm not quite sure but I think this happens when the compatible dll was compiled on a machine with a newer olelib.tlb than the olelib.tlb on the machine compiling the actual dll. Please note that I won't provide Edanmo's TLB!

If anybody has fixed one of the open issues, I would be happy to consider this in my code.


Change log

27 Dec 2002 Initially submitted to www.klemid.de and www.pscode.com.
30 Dec 2002 Make install.reg useful for Win98 as well.
    Updated the prerequisites, installations, and open issues section
06 Apr 2003 Added hint how to change name
03 Mar 2004 Update links
03 Jul 2004 Modified AddToolbarButtons to prevent corrupted captions when new buttons are added
01 Aug 2004 Fixed the issue with TAB by adding WS_TABSTOP
10 Oct 2004 Add textbox and button. Totally revise focus handling. Add support for Log4VB.
28 Nov 2004 Sync with version at pscode.com
06 Jan 2005 Make it run under Win98 / IE5.0
07 Mar 2005 Fix problem with SampleBar_debug.vbp
14 Jun 2005 Added note about olelib.tlb and olelib2.tlb in the installation section