How to create IE add-ons in VB.NET, C#, C++
for Internet Explorer: IE6, IE7 and IE8

Add-in Express™
for Internet Explorer® and Microsoft® .net

Add-in Express Home > Add-in Express for Internet Explorer > Online Guide > Programming Internet Explorer addons

Creating an IE add-on project

How to create Internet Explorer add-on - Flash video Add-in Express for Internet Explorer allows you to quickly create add-ons for IE 6 (32-bit), IE 7 and IE 8 (32-bit and 64-bit). It adds several project templates to the Extensibility folder of the New Project dialog. To see the dialog, choose the “File | New | Project…” menu.

New IE project

As you can see, there are IE Add-on, IE Bar and IE Toolbar project templates in this dialog. They produce projects that differ in small details such as type names. You can't create IE toolbars in the IE Bar project and vice versa, you can't create IE bars in the IE Toolbar project. IE Add-on allows combining toolbars and IE bars in one project. However, the most essential difference lies in their deployment. The only IE extension type that is installable by a standard user is IE Bar. All other project types require administrative privileges when your solution is installed on the target PC.

To create a project, select an appropriate project template icon and click OK. This invokes the Add-in Express project wizard that allows selecting a programming language for your Internet Explorer project (VB in our IE project) as well as other options (see also Version-neutral IE add-ons).

Selecting a programming language  
 
The project wizard allows selecting the programming language and interop assemblies to be used in your project. Selecting a programming language is of course a straightforward action. Choosing the correct interop requires understanding. The following table illustrates this option in more detail:

Interop Assemblies option

IE version installed on the development PC

IE versions supported by the add-on

  • Version-neutral (IE 6 and higher)

IE6, IE7, or IE8

IE6, IE7 and IE8

  • For the currently installed IE version

IE6

IE6, IE7 and IE8

  • For the currently installed IE version

IE7

IE7 and IE8

  • For the currently installed IE version

IE8

IE8

To access properties or methods defined in a newer IE version, you use late binding (see Type.InvokeMember in MSDN). To use constants defined in a newer IE version, you must know them; we suggest using the .NET Reflector to obtain constants defined in newer versions of IE. As to events, the IE module provides all events; just use an appropriate one.

The second window of the project wizard allows choosing between using the existing .SNK file or creating a new one.

Add-in Express project structure

A newly created IE solution is shown below:

Typical Internet Explorer solution
 
Let's walk through the files.

The files in the Loader folder (adxloader.dll, adxloader64.dll and adxloader.dll.manifest) allow your add-on to load to Internet Explorer. You use the manifest to tune this process. See Add-in Express Loader.

The files in the Resources folder are just sample icons for toolbar buttons. They are pre-added to Icons.resx (see Adding a custom button to IE toolbar). They serve as placeholders only and you need to replace them with actual icons in your add-on.

GlobalData.vb – a class that can store data available for all add-on instances within the process.

IEModule.vb – the heart of the project; provides a number of properties, methods and events that relate to the add-on and its UI.

MyIEAddon1.snk – a strong-name key file.

IEModule.vb

IEModule is a core part of your IE add-on. From some point of view, it is the add-on itself. It specifies the name of your Internet Explorer add-on. It stores components that represent toolbars, toolbar buttons, menu items, context menu items, and Explorer bars created by your add-on. In addition, it is a container for other components required for the add-on to function. Finally, it communicates with the IE application to provide you with a complete set of IE events such as BeforeNavigate2 and DownloadComplete.

You access the module's designer and code via the context menu in the Solution Explorer window.

Note. The designer surface of the IEModule provides a context menu revealing a number of commands; you use these commands to add Add-in Express components to the module.

Solution Explorer window

For a newly created project, the module contains the code shown below. Pay attention to the IEApp and HTMLDocument properties; you will certainly use them in your code.


Imports System
Imports System.Runtime.InteropServices
Imports System.ComponentModel
Imports System.Windows.Forms
Imports IE = Interop.SHDocVw

'Add-in Express for Internet Explorer Module
 _
Public Class IEModule
 Inherits AddinExpress.IE.ADXIEModule

#Region " Component Designer generated code. "
 'Required by designer
 Private components As System.ComponentModel.IContainer

 'Required by designer - do not modify
 'the following method
 Private Sub InitializeComponent()
 Me.components = New System.ComponentModel.Container()
 '
 'IEModule
 '
 Me.ModuleName = "MyIEAddon1"
 End Sub
#End Region

#Region " Add-in Express automatic code "

 'Required by Add-in Express - do not modify
 'the methods within this region

 Public Overrides Function GetContainer() As _
 System.ComponentModel.IContainer
 If components Is Nothing Then
 components = New System.ComponentModel.Container
 End If
 GetContainer = components
 End Function

  _
 Public Shared Sub RegisterIEModule(ByVal t As Type)
 AddinExpress.IE.ADXIEModule.RegisterIEModuleInternal(t)
 End Sub

  _
 Public Shared Sub UnregisterIEModule(ByVal t As Type)
 AddinExpress.IE.ADXIEModule.UnregisterIEModuleInternal(t)
 End Sub

  _
 Public Class IECustomContextMenuCommands
 Inherits AddinExpress.IE.ADXIEModule.ADXIEContextMenuCommandDispatcher

 End Class

  _
 Public Class IECustomCommands
 Inherits AddinExpress.IE.ADXIEModule.ADXIECommandDispatcher

 End Class
#End Region

 Public Sub New()
 MyBase.New()

 'This call is required by the Component Designer
 InitializeComponent()

 End Sub

 Public Sub New(ByVal container As IContainer)
 MyBase.New(container)

 container.Add(Me)
 'This call is required by the Component Designer
 InitializeComponent()

 End Sub

 Public ReadOnly Property IEApp() As IE.WebBrowser
 Get
 Return CType(Me.IEObj, IE.WebBrowser)
 End Get
 End Property

 Public ReadOnly Property HTMLDocument() As mshtml.HTMLDocument
 Get
 Return CType(Me.HTMLDocumentObj, mshtml.HTMLDocument)
 End Get
 End Property

End Class


See an example of an IE6 and IE7 add-on with source code.

Add-in Express for Internet Explorer <<

>> Creating custom IE toolbars

Back to Add-in Express for Internet Explorer homepage