KB_Soft Group - Software Vendor's Development Partner
Start page
Site map
Contacts
   



   

Introduction

One of our clients addressed to KBSoft with an idea to create a commercial toolbar for Internet Explorer. The idea was simple � it was necessary to implement a toolbar for Internet Explorer 7.0 containing the following elements:

  • company logo;
  • search field, allowing to send a search request to an arbitrary site and display the results in the browser;
  • expand buttons, containing arbitrary number of links;
  • drop-down lists displaying RSS-channels.

We started to work on this task and started with a choice of a platform. As it turned out, it is not a simple thing to make a toolbar for Internet Explorer with a declared functionality. It is necessary to deal with Com-components, interact with browser and store cashed data somewhere. Fortunately, it appeared that it is possible to do everything on .Net 2.0. platform, which simplified the task a lot. The result of our work is given below � it is IEToolbarEngine component, presenting high level interface for toolbar and its elements creation. Perhaps, this component will allow you to implement own toolbars or you will find some useful data for the implementation of own projects in MS Visual Studio environment in the description of this device.

 

Usage

IEToolbarEngine is inherited from BandObject component, written by Pavel Zolnikov and described in the article �Extending Explorer with Band Objects using .NET and Windows Forms�. We, in KBSoft, modified it so it would be possible to build our toolbar in Internet Explorer. After that, we wrote a small library of classes enabling to add different elements into the toolbar.

If to speak generally, the toolbar presents itself UserControl with System.Windows.Forms.ToolStrip component placed on it. At the loading of this control, CreateToolbarItems function is activated, which should be paid great attention, as the main initialization of toolbar elements happens in it. You can bring changes into it for creation of your own toolbar. Its fragment is given below.

   

internal void CreateToolbarItems ()
{
    try
    {
        �
        //Get current assembly.
        Assembly currentAssembly = 
            Assembly.GetAssembly( this.GetType() );
        
        //Links cration.
        Link link1 = new Link("Home page", 
            "http://kbsoft-group.com/");

        Link link2 = new Link("Clear Search History", 
            IEToolbarEngine.WrapInternalCommand(IEToolbarEngine.cmdClearHistory));

        //Getting image from resources
        Image img = Image.FromStream( 
            currentAssembly.GetManifestResourceStream("IEToolbarEngine.main.png") );

        //Create toobar item.
        menu = new MainMenu( this, "Company", "Main", 
                new Link[] { link1, link2 }, img);

        //Add item to internal collection         
        items.Add (menu);
        �
    }
}

   

A creation of one toolbar element is demonstrated here, this element contains a logo and a brief drop-down menu. An item is created with the help of MainMenu class. Two links and an image are added to it. Classes diagram displaying a simple architecture of toolbar elements is given below:

   

 

   

A created element will look like that:

 

Title text, tips, array of links (KeyValuePair class objects, where Key - menu item text and value � link for transfer at a click on it) and a link to the image received from the assembly resources are given to MainMenu class constructor.

 

Let us note, for those who are curious, that name of a resource embedded into the assembly is formed from the default namespace name, and from the resource name itself (hence, the line IEToolbarEngine.main.png).

After a creation, it is necessary to add a new element into the collection of IEToolbarEngine Items class.

Creation of several elements is demonstrated in IEToolbarEngine project attached to this article. Lets view them in consequence.

   

SearchBoxItem

new SearchBoxItem (this, "", "terms to serach!",
               "http://www.google.ru/search?q={0}",
               "Search here", "Search", "Click to search",new Size (160, 16), 
               FlatStyle.System, img);
   

SearchBoxItem class presents itself a search line with a button starting the search. The line can navigate to an arbitrary site supporting a search with parameters specified in GET request.

The following parameters are specified to the constructor: link to IEToolbarEngine class, line which will be displayed in combobox for item of search history clearing, prompt line, search line, pop-up prompt line, text on search button, search field size, its style and a link to the image for search button. This element will look like that:

 

 

A few words about search line format. There are q={0} parameter in it. Here q is parameter name, used in your search query, and {0} will be automatically substituted to the line which a user enters into search line. If there is another parameter name in your search query, it should be staned instead of q.

   

LinkListItem

LinkListItem(this, "Advantages", "Advantages", 
                    new Link[] { link1, link2, link3, link4 }, img);
   

Simple list with links. Constructor parameters- link to IEToolbarEngine class, button text, tooltip text, array of elements. The exterior is shown below:

 

   

RssTicker

RssTicker(this, "RSS", "RSS Channel", 
    "http://www.euro2008.uefa.com/rss/index.xml", 1440, img, "RSSChannel");
   

This element presents itself a list of links received from RSS feed. For that, a link to RSS-feed and a period of channel update is given to a constructor. The string � a unique name of RSS-channel, which will be used for creation of a cash-file in application folder in "Application Data\IEToolbar\Cache", should be transmitted the last.

The resulting element looks like that:

 

   

Installation Project

Also the demo project contains an installation project IEToolbarInstallation, generating Setup.exe file, which allows to install the toolbar to the user machine and delete it if necessary. It is created by the means of MS Visual Studio. The moments, connected with the implementation of installation project which should be paid attention to, are given below.

There is IEToolbarInstaller class, derived from System.Configuration.Install.Installer in toobar assembly (IEToolbar.dll, is created by IEToolbarEngine project). In order to show the installer that this class methods should be started in the process of installation, it is marked by RunInstallerAttribute attribute. Install and Uninstall methods are overriden in it. Install implements a registration of a build as COM-server. Uninstall, correspondingly, cancels its registration.

 

RegisterAssembly function of class RegistrationServices is used for registration. It is necessary to note, that this assembly is not installed in GAC, that is why registration should be implemented with AssemblyRegistrationFlags.SetCodeBase key. For that, it is necessary for the assembly to be strongly named, otherwise, registration can go in a wrong way.

The installer is given a directive to search this class in the build at the installation and start its actions Install and Uninstall. For that, a new action is added into "Custom Actions" section in the project, for which, IEToolbr.dll file of build is selected in "custom action surce" field.

Basic for IEToolbarEngine class BandObject contains Register and Unregister functions. Register is started in the process of registration and executes adding of keys, necessary to embed the toolbar into Internet Explorer, into the windows register. Unregister is started at the installation and deletes the information, connected with the toolbar, from the windows register.