Click here to Skip to main content
14,931,390 members
Articles / Desktop Programming / Windows Forms
Posted 17 Apr 2008

Tagged as


86 bookmarked

Internet Explorer Toolbar Creation

Rate me:
Please Sign up or sign in to vote.
3.10/5 (47 votes)
17 Apr 2008CPOL5 min read
base code with instruction how to create you own plug-in for internet explorer
Image 1


This article provides the base code for the development of a professional toolbar for Internet explorer.
While the other articles provide a good starter for toolbar concept, they still lack some bits that are needed for professional applications and supporting look & feel for Vista as well as XP along with complete setup.
This article is best suited for newcomers to toolbars that want to get a working project in 5 minutes.
I still recommend further reading in the related articles for those of you that want to get more thorough understanding about the internals of the BandObject component.


While developing my Password Manager toolbar ,I started looking for code samples and articles in the Net. I found some very useful ones (like Pavel Zolnikov's article) that helped me a lot to start basic toolbar implementation.

But then I found some bits of problems such as :
- toolbar do not show in IE7
- toolbar problems in Vista and bad look & feel on Vista
- problems with the installation
- toolbar do not show after installation and more .....

Since I had to deal with all these problems in order to get it working professionally,I spent days to find out all the comments and forums that solve those issues.

I try here to provide the most "Clean" toolbar implementation for all of you guys ,beginners and experts , that want to experience the fun of creating toolbars without the plumbing hassles.

There are still some small issues remaining and I hope that with the help of some keen coders we can manage to solve all issues and provide the perfect Toolbar class.

Using the Code

Simply extend the Toolbar class . you can rename it to whatever name you want.

I provided in the sample a simple button and label . it is a regular WinForm ToolStrip so you can put here all ToolStrip items.

Accessing the Browser and DOM

Use the Explorer property to access the WebBrowserClass.I added for simplicity the Navigate(string url) and NewWindow(string url) methods.

The "Constants" class:

class Constants 

  public const string ToolbarName = "Sample Toolbar"; 

  public const string ToolbarHelpText = "Sample Toolbar Help Text";   

  public const string ToolbarGUID = "4D02E7E6-5930-4b51-B9B0-9F21B3789400"; 

  public const int ToolBarWidth = 160; 

  public const string Assembly = "Toolbar, Version=, Culture=neutral, 


You MUST create a new GUID for your toolbar instead of the one supplied with oolbarGUID.

It is advised to sign the released assembly with different .snk file (ToolbarKey.snk) . in that case the PublicKeyToken will be changed, so you will need to revise it in the Assembly const string.

To extract the public key token from dll you can use sn -T from VS2005 tools.

Debugging , Rebuilding & Development

In order to debug the toolbar you can remove the remark from the constructor

    public Toolbar()


Alternatively you can use the "Attach to Process" option of VS2005 IDE and attach to IE.

When you update the toolbar's code , you do not need to unistall and reinstall it ,you just need to re-register it in the GAC.

go to Start-->Setting-->Control Panel-->Administrative Tools

select "Microsoft .NET Framework 2.0 Configuration" .

right-click on the "Assebly Cache" , choose "Add" and add the toolbar dll.

Points of Interest

The use of BHO to show toolbar after installation

BHO (Browser Helper Object) is simmilar to Toolbar (BandObject) except of the GUI capabilities.

I use the BHO only for the purpose of showing the toolbar immediatly after installation.

At the setup I register the BandObject as BHO by adding it to the registry:

     RegistryKey bhoKey = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft
\Windows\CurrentVersion\Explorer\Browser Helper Objects\" + guid); 
     bhoKey.SetValue("NoExplorer", 1, RegistryValueKind.DWord);    

At first time the SetSite method is called for the BHO object the ShowToolbar method is called.

public virtual void SetSite(object pUnkSite) 
  if (pUnkSite is IInputObjectSite) { 
  else if (pUnkSite is InternetExplorer) 
    // this code is executed by the BHO in order to show the toolbar immediatly 
    // after the installation 

The ShowToolbar is responsible to Show the toolbar using the ShowBrowserBar

method , and then remove the BHO from the registry since it have no use any more.

\Explorer\Browser Helper Objects\{" + Constants.ToolbarGUID + "}");

Painting the toolbar's background according to the theme

When I first tested the toolbar on Vista I got it pretty ugly gray background instead of the smooth gradient style of IE7 of Vista. I digged to find a solution to this and found the fantastic "Geer's Blog" that gave me just the answer I was looking for.

The code snippet that is responsible to inherit the background of the toolbar looks like that :

[DllImport("uxtheme", ExactSpelling = true)] 
public extern static Int32 DrawThemeParentBackground(IntPtr hWnd, IntPtr hdc,
 ref Rectangle pRect);

protected override void OnPaintBackground(PaintEventArgs e) 
 if (this.BackColor == Color.Transparent) 
   IntPtr hdc = e.Graphics.GetHdc(); 
   Rectangle rec = new Rectangle(e.ClipRectangle.Left, e.ClipRectangle.Top,
 e.ClipRectangle.Width, e.ClipRectangle.Height);
   DrawThemeParentBackground(this.Handle, hdc, ref rec);

Toolbar location

I admit that I didn't get it perfect yet ,the ability to locate the toolbar everywhere I like.I had it working pretty good on XP but then found out that it do not work well on Vista. I also tried to remember the location of the toolbar by implementing IPersistStream ,but it didn't work.

Finally I comporized on a static toolbar and that works fine both in Vista & XP .

The flag in GetBandInfo that is responsible for the location and other layout behaviors is:


Process Scope

All BandObjects that are created with "new window" or "new tab" are in the same process so you can use a static member in order to communicate between them.for convenience I added a static list of all the toolbars in the process: ToolbarsCollection .

I used this collection in my Password Manager to synchronize login\logout and other operations between the toolbars.

Launching IE from the desktop or the quick-launch create new process so in that ase the collection won't work.

About the Setup

I used the very basic setup project provided by VS2005. Almost all the setup code that is responsible for registry operations : COM registration, BandObject registration & BHO registration is done in the ToolbarInstaller calss which derives from System.Configuration.Install.Installer

Another thing I do in the setup is the registration in the GAC by explicitely selecting the GAC folder in the File System. I could register the toolbar in the GAC with code using the Publish class. but this is out of the scope


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Sharon Salmon
CEO LogOnce -
Israel Israel
I have been writing code for more than 12 years in C C++ Java & C#.
Since 2004 I had been specializing in .Net C# .
ever since I discovered C# I am a big fan of it.
I live in Tel-Aviv Israel
I recently founded new software startup.
My Company site is


Comments and Discussions

QuestionIssue in creating setup Pin
Member 37671609-Oct-13 1:52
MemberMember 37671609-Oct-13 1:52 
QuestionCouple of Issues with IE 9 on Windows 7 Pin
Prutha Tester11-Sep-12 3:06
MemberPrutha Tester11-Sep-12 3:06 
QuestionIt's not working in windows 2008 R2 64bit. IE 8 Pin
sj.abhilash10-Jul-11 19:54
Membersj.abhilash10-Jul-11 19:54 
GeneralInstall Question Pin
Member 287088111-Dec-10 23:16
MemberMember 287088111-Dec-10 23:16 
GeneralToolbar Pin
underscore_dot11-Jan-10 4:13
Memberunderscore_dot11-Jan-10 4:13 
QuestionDo you support windows server 2000 2003 and server 2008 ? Pin
Battosaiii6-Oct-09 0:53
MemberBattosaiii6-Oct-09 0:53 
I tried to install this into windows server 2000 with internet explorer 6 but the machine has a problem.
I got a dll not found error with uxtheme. Then i was asked to reboot the machine.
I also cannot see it on windows server 2003 . Do I need to modify the properties of internet explorer ?
AnswerRe: Do you support windows server 2000 2003 and server 2008 ? Pin
Battosaiii6-Oct-09 23:00
MemberBattosaiii6-Oct-09 23:00 
GeneralUsing a TextBox Pin
Florian Kunz1-Feb-09 22:29
MemberFlorian Kunz1-Feb-09 22:29 
GeneralRe: Using a TextBox Pin
User 27738834-Feb-09 4:14
MemberUser 27738834-Feb-09 4:14 
GeneralRe: Using a TextBox Pin
Mathelem16-Apr-09 6:58
MemberMathelem16-Apr-09 6:58 
QuestionHow to change label text after it loaded Pin
makseek23-Dec-08 10:32
Membermakseek23-Dec-08 10:32 
AnswerRe: How to change label text after it loaded Pin
Philipp Kratzer13-Feb-09 0:37
MemberPhilipp Kratzer13-Feb-09 0:37 
QuestionImplementing OS skin for toolbar in Vista Pin
nvikas71-Dec-08 18:05
Membernvikas71-Dec-08 18:05 
AnswerRe: Implementing OS skin for toolbar in Vista Pin
Sharon Salmon1-Dec-08 21:26
MemberSharon Salmon1-Dec-08 21:26 
Questionhow to generate OnDocumentComplete Event in this example Pin
ronak-webdeveloper20-Nov-08 20:37
Memberronak-webdeveloper20-Nov-08 20:37 
GeneralThe Backspace key can not use Pin
wosi29-Jul-08 22:09
Memberwosi29-Jul-08 22:09 
GeneralRe: The Backspace key can not use Pin
Sinja223-Jun-10 18:40
MemberSinja223-Jun-10 18:40 
GeneralIE7 and XP Pin
Member 163330828-Jul-08 7:19
MemberMember 163330828-Jul-08 7:19 
GeneralRe: IE7 and XP Pin
Member 163330828-Jul-08 8:02
MemberMember 163330828-Jul-08 8:02 
QuestionToolbar will not display Pin
marc22110-Jul-08 3:44
Membermarc22110-Jul-08 3:44 
AnswerRe: Toolbar will not display Pin
Sharon Salmon11-Jul-08 21:29
MemberSharon Salmon11-Jul-08 21:29 
QuestionRe: Toolbar will not display Pin
marc22115-Jul-08 9:45
Membermarc22115-Jul-08 9:45 
AnswerRe: Toolbar will not display Pin
charithmkd13-Oct-10 17:15
Membercharithmkd13-Oct-10 17:15 
Questiontoolbar can not move Pin
Member 35224788-Jul-08 18:48
MemberMember 35224788-Jul-08 18:48 
AnswerRe: toolbar can not move Pin
Sharon Salmon11-Jul-08 21:14
MemberSharon Salmon11-Jul-08 21:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.