How to add ActiveX content
to your web pages

Section 1: About this Paper
Section 2: Brief Background
Section 3: Embedding Active Content: The <OBJECT> Tag
Section 4: Using the ActiveX™ Control Pad
Section 5: Using Visual InterDev®
Section 6: Providing Licensing Information
Section 7: Providing Digital Signing and Certification
Section 8: "Now that it's there, what do I do with it?"
Section 9: Resources for ActiveX Information
Section 10: Final Thoughts
Section 11: About FarPoint
Section 12: Notices

Section 1: About this Paper

This white paper explains how to add an ActiveX™ control (OCX) to your web page. Included in this document are instructions and overviews covering

This white paper assumes a basic understanding of HTML (Hypertext Markup Language) and the World Wide Web. If you need more information about creating web pages, explore the plethora of HTML how-to guides in your local bookstore. Due to its nature, this document does not cover the details of code downloading or VBScript™. You can obtain further information on both of these topics from Microsoft.

Return to top


Section 2: Brief Background

HTML was designed as a page description language for defining static pages. As originally designed, when users connected to a web site, pages were sent to their browsers and displayed. To change what was shown, a new page had to be loaded. If input was required from users, it was sent back to the web server, processed there, and then new pages were sent back to the users' browsers. No local processing or updates were possible.

With the advent of ActiveX comes the concept of active content. You can embed items that will run on the user's machine in the HTML code that creates a web page. These items can dynamically update their displays or validate user input without accessing the web server. An ActiveX control is a modular piece of software that has its own small graphical interface and can perform tasks, compute information, and communicate to other programs. They can be easily used and reused by any ActiveX-capable program or language, such as Internet Explorer™ and Visual Basic®. For example, the FarPoint Technologies™ Input Pro™ product offers a suite of user entry controls that can format and validate content as a user enters information into the control.

When an ActiveX-capable browser encounters a Web page with one or more ActiveX controls, it checks the user's local system registry to see if those controls already exist on the user's computer. If they do exist, the browser displays the page and activates the controls. If the controls are not already installed on the user's computer, the browser automatically finds and installs the control over the Web. The browser knows where to find the control because the appropriate Web site is coded into the tag that embeds the ActiveX control. By default, ActiveX controls are downloaded into an ActiveX control cache located in the \Windows\occache directory.

ActiveX technology relies on the user's browser being able to run the embedded content, the ActiveX control. For example, the first browser that had native support for ActiveX controls was Microsoft's Internet Explorer 3.0.

For more information about ActiveX in general, see Resources for ActiveX Information.

Return to top


Section 3: Embedding Active Content: The <OBJECT> Tag

HTML pages are made up of text separated by tags that define how the text should be displayed. You can use specialized tags to display images or to provide a link to another page. Microsoft has decided to use the <OBJECT> tag to place ActiveX controls in HTML pages.

The following example illustrates an object tag:

<OBJECT ID="fpBoolean1" CLASSID="CLSID:DD55D143-EBF7-11D0-8810-0000C0E5948C" CODEBASE="http://www.fpoint.com/max/inputpro.cab"> <PARAM NAME="BorderStyle" VALUE="0"> <PARAM NAME="BorderColor" VALUE="-2147483642"> <PARAM NAME="BorderWidth" VALUE="1"> <PARAM NAME="BooleanStyle" VALUE="0"> <PARAM NAME="TextFalse" VALUE="FarPoint Boolean"> </OBJECT>

The tag has the following parameters:

ID= A name for the object. The name should be unique among all other objects on the page.
CLASSID= A class ID number. Every ActiveX control has a unique class ID that was encoded into it during development. The browser uses this number to determine which control to load.

This number must be exactly correct or the control will not load. Thus, it is preferable to cut and paste these numbers into your object tag or to use a tool such as the ActiveX Control Pad to insert them. For more information, see "Using the ActiveX Control Pad."
CODEBASE= URL referring to where the ActiveX control can be acquired. When the page is loaded into the user's system, the browser checks the registry to determine if the system has the ActiveX control referenced by the CLASSID. If it does, then the local copy is used. Otherwise, the browser attempts to download the control from the URL designated by the CODEBASE tag.

For details on the intricacies of code downloading, see Microsoft's code download specification.
PARAM NAME="x" VALUE="y" Optional parameters to set properties of the ActiveX control when it is loaded. Each is expressed as a property NAME and a VALUE to set it to. Once the control is loaded, it is given these property settings by the browser. Which settings are supported depends on the ActiveX control.
DATA= An optional parameter providing binary data that sets properties and provides information about the control.

Close the object tag using the (</OBJECT>) tag after the parameter list.

This is not a complete list of possible options in the OBJECT tag, but these are the basic options needed to display a control on a web page. Further information on this tag can be found at the World Wide Web Consortium site, http://www.w3.org, under the topic "Inserting objects into HTML."

Return to top


Section 4: Using the ActiveX Control Pad

Adding controls by hand is not a simple process. The CLSID numbers are unwieldy to type, and it can be difficult to visualize the effects of the parameter settings on the control. To help with these difficulties, Microsoft created the ActiveX Control Pad, which can be obtained from their web site at http://www.microsoft.com.

The latest available version of the ActiveX Control Pad is version 1.0, dated January 13, 1997. A more recent and more powerful tool is the Microsoft Visual InterDev® web development system, which is described in Using Visual InterDev.

The ActiveX Control Pad lets you select controls from a list of available controls on your system. The controls are displayed in a design window, and you can change the properties of a control to achieve the appearance you want. The ActiveX Control Pad then generates the HTML code for you, including extracting the correct CLSID and setting the PARAM statements.

The ActiveX Control Pad provides a very basic HTML editor. However, you might find it easier to lay out your page in your preferred HTML editor, then load it into the ActiveX Control Pad to insert the ActiveX controls.

The following figure shows the ActiveX Control Pad, including an HTML page template.

The following instructions explain how to add an ActiveX control to your HTML page.

  1. Place the cursor where you want the control to appear.
  2. From the Edit menu, choose Insert ActiveX Control.
  3. The Insert ActiveX Control dialog is displayed, providing a list of all the registered ActiveX controls on your system, as shown in the following figure.

If the control you need does not appear in this list, you need to register it on your system using the control's install program or another tool such as Visual Basic® version 4.0 or later.
  1. Select the control that you want to insert in your HTML code from the list, and then select OK.
  2. The control appears in the Edit ActiveX Control window in the object editor, as shown in the following figure.

You can now set properties as you would in Visual Basic. If you prefer, for some controls you can right-click the control in the Edit ActiveX Control window to display property pages for setting properties.

You can also size the control itself in the Edit ActiveX Control window. Some properties may react differently than they do under Visual Basic. If a property refuses to take a value, it may have to be set at run time. For more information about run-time properties, see "Now that it's there, what do I do with it?".
  1. Once you have finished making changes to the control, close the Edit ActiveX Control window.
  2. The object editor generates and pastes the <OBJECT> tag for your control into the HTML page, along with all the parameter settings, as shown in the following figure.

The object editor generates PARAM tags for many of the control's properties, even if you did not change them from the defaults. It also automatically extracts the CLSID from your registry and adds it to the tag. Alternatively, the object editor might generate binary data that is added to the HTML page using the DATA tag.
If you click on the object symbol () you return to the object editor, where you can resize the control or change other properties. You can also directly edit the HTML lines, but your changes will not be checked by the object editor.

Return to top


Section 5: Using Visual InterDev

Since adding controls by hand is not a simple process, Microsoft created the Visual InterDev web development application, which can be obtained from their web site at http://www.microsoft.com. An earlier and less powerful (though free) tool is Microsoft ActiveX Control Pad.

Visual InterDev is a tool for creating dynamic web applications that support server-side scripts, especially ones that use server-side run-time ActiveX components. Visual InterDev also supports ActiveX design-time controls, which are regular ActiveX controls that can generate HTML-based content and can also automatically generate the server-side or client-side scripting required to accomplish tasks within a web site. You can use Visual InterDev to integrate ActiveX server components written in Java, Visual Basic, C, C++, or other languages that can create COM (Component Object Model) components.

Visual InterDev includes a client-side Script Wizard, first introduced with the ActiveX Control Pad. As with the Control Pad, the Script Wizard lets you add interactivity to Web pages based on actions and events associated with ActiveX controls. Visual InterDev also includes a version of the Microsoft FrontPage HTML editor, which lets you insert ActiveX controls, Java applets, and browser plug-ins in a true WYSIWYG environment with drag-and-drop control over characteristics such as the size and position of components. You can use the Object Editor to modify components in a visual editor, and the Object Editor will then generate the HTML syntax to bring the component into the Web page and execute it.

See Microsoft's paper "Using ActiveX Controls in Visual InterDev Web Applications," available at http://msdn.microsoft.com/library/techart/msdn_activexvid.htm, for general information about putting ActiveX controls on a web page using Visual InterDev.

There are several things to keep in mind when incorporating FarPoint controls in your web pages using Visual InterDev. You must use Visual Basic to create a UserControl. Generally, you put your third-party controls inside of your UserControl component. You must:

  1. Make your UserControl component licensed. (In the project properties dialog on the General tab, check the "Require License Key" checkbox.)
  2. Add the license for the UserControl component to the LPK file. Do not add the licenses for the controls contained in the UserControl component. (Read more about the LPK file.)

Return to top


Section 6: Providing Licensing Information

Note that licensed controls do not work inside the HTML Layout object in the ActiveX Control Pad.

When a web page contains ActiveX controls, these controls must be downloaded to the machine of the person viewing the web page. Therefore, each person viewing the page receives a copy of the controls on the web page. Licensing prevents the unlicensed use of controls downloaded in this manner.

ActiveX controls usually require a license file (.LIC) file to be used in a development environment. The .LIC file lets the creators of the control distribute it while protecting their ownership. When a browser loads an ActiveX control, it checks for the control's licensing. However, third-party owners of ActiveX controls do not allow you to distribute their .LIC files.

To allow ActiveX controls to work in browsers without the need for distributing .LIC files, Microsoft developed the license package (.LPK) concept. Each .LPK file contains run-time licensing information for all the ActiveX controls on a given web page. When the page is loaded into a browser, each control on the page is checked against the .LPK file. If the control is correctly referenced there, it is allowed to load. Otherwise, a license violation message is displayed. When you are developing pages using third-party controls, you must create an .LPK file for each page containing references to all the ActiveX controls directly on that page. You do not have to have run-time licensing information for ActiveX controls that are inside other objects on the page.

You can create an .LPK file using Microsoft's License Package Authoring Tool (LPK_TOOL). The tool is part of the Internet Client SDK (in the \bin subdirectory), available from the Microsoft website at http://www.microsoft.com. Some HTML authoring tools also help you create .LPK files.

When you create your page, you must place an LPK object as the first object on the page using the <OBJECT> tag. The LPK object points to an .LPK file that resides on your website.

Use the following steps to create your .LPK files and an LPK object using the Microsoft LPK Tool:

  1. Determine which controls are on your web page. There can be only one .LPK file referenced per web page, so that file must include all controls on that page.
  2. Once you have your list of controls, launch LPK_TOOL.EXE from the Internet Client SDK.
  3. The License Package Authoring Tool dialog appears, as shown in the following figure.

  4. The dialog lists all the ActiveX controls installed on your system.
  1. Select the Show only controls that support licensing check box to have the tool step through all the controls on your system to verify that they support the .LPK system.
  2. When complete, select all the controls that are directly on your web page and click Add to add them to the package you are creating.
  3. Click Save & Exit to create the .LPK file and specify the path and file name.
  4. Place the following code on your HTML page as the first <OBJECT> tag:<OBJECT CLASSID = "clsid:5220cb21-c88d-11cf-b347-00aa00a28331"><PARAM NAME="LPKPath" VALUE="inppro.lpk"></OBJECT>

    Replace inppro.lpk with the name of your LPK file.

    This code must be the first use of the <OBJECT> tag on your page for it to work correctly. This placement invokes the licenser system in the browser.
  1. Place the .LPK file on your website in the same directory as your HTML files.

Return to top


Section 7: Providing Digital Signing and Certification

When you connect to a web page that contains an ActiveX control, that control is actually downloaded to your system and runs in your computer. This has the potential to allow viruses or other malicious code to run on your system.

To help avoid this problem, Microsoft has devised a system of code signing that they refer to as Authenticode™. In its default mode, Internet Explorer does not allow an ActiveX control to download unless it is verifiably signed and certified. The signing process is done by the company that created the ActiveX control.

The company provides corporate information to a certifying authority such as Verisign™. The certifying authority then issues a cryptographic key and certificate that the developer uses to sign their OCX, DLL, and CAB files. The signature allows the browser to verify that the ActiveX it is downloading has not been tampered with. The browser then displays the certificate for the control, and asks the user whether to let the control be installed and registered on the system.

Controls come signed and certified from the manufacturer. You should be able to download the control from a web page and see the certificate displayed. (Note: Once you have installed a certified control onto your system the certificate is no longer displayed when the control is loaded). As long as you are using signed ActiveX controls directly, you do not need to do anything further.

If you are going to create your own OCX controls, or you are putting several OCX controls into a cabinet (.CAB) file, you need to contact a certifying authority and get the certificate to sign your code and .CAB files. You can obtain code-signing tools to use with the certificate from Microsoft.

Return to top


Section 8: "Now that it's there, what do I do with it?"

The preceding sections have described all you need to do to embed an ActiveX object in your HTML page. However, to control interaction with the embedded object, you have to write code. Microsoft's chosen method is VBScript, a subset of the Visual Basic command set.

The ActiveX Control Pad provides a tool called Script Wizard as a means of adding code to your page. (Visual InterDev also provides a Script Wizard. While the instructions and illustrations in this section use the Script Wizard from the ActiveX Control Pad, the Script Wizard from Visual InterDev is similar.)

Access the Script Wizard from the Tools menu by choosing Script Wizard. The Script Wizard appears. The Script Wizard displays the objects on your page and the events to which they respond. Select Code View (near the bottom of the window) to view the wizard in Code View, as shown in the following figure.

In Code View, you can type in VBScript statements for the event procedure. Code changes that you make are pasted back into your HTML page when you exit the Script Wizard. A code symbol then appears on theleft bar of the ActiveX Control Pad, similar to the symbol for the object editor. Click the symbol to reopen the code for editing.

A discussion of VBScript is beyond the scope of this document, but you can find documentation for the language on Microsoft's web site (http://www.microsoft.com).

Return to top


Section 9: Resources for ActiveX Information

These resources contain additional ActiveX literature, example code, downloads, or links to other useful sites with ActiveX information and material. Please check back for updated listings. If you know of an ActiveX site or book that you would like to see listed, please let us know.

Please note that the following addresses link to other sites. Because these sites and the books that follow them are not affiliated with FarPoint Technologies in any way, we can not make any guarantees about or promote any of their content.


Microsoft
http://www.microsoft.com/activex/

ActiveX Resource Center
http://www.active-x.com

CNET: The Computer Network
http://www.activex.com

World Wide Web Consortium
http://www.w3.org

Designing and Using ActiveX Controls
Tom Armstrong
ISBN 1558515038

ActiveX All in One: A Web Developer's Guide
Zane Lang
ISBN 0136190995

ActiveX Sourcebook: Build an ActiveX-Based Web Site
Ted Coombs, Jason Coombs, Donald Brewer
ISBN 0471167142

Laura Lemay's Web Workshop: ActiveX and VBScript
Rogers Cadenhead, Paul Omax
ISBN 1575212072

Return to top


Section 10: Final Thoughts

As with all technology, safeguard your work by saving it frequently and creating regular backups.

This document provides only an overview of embedding ActiveX controls. For more information about using the tools, refer to the help files provided with the ActiveX Control Pad and with Visual InterDev. For the latest information about the ActiveX Control Pad and Visual InterDev products, refer to Microsoft's web site (http://www.microsoft.com). For the latest information on HTML, refer to the W3C website (http://www.w3.org).

Return to top


Section 11: About FarPoint

FarPoint Technologies, Inc., a privately held company with corporate headquarters located in Morrisville, North Carolina, USA, is a leading developer and publisher of professional components for Windows development. Our award-winning tools benefit leading corporations, software companies, and independent consultants around the world as a cost-effective solution for building distributed enterprise-wide applications for commercial or in-house use. From the CEO to our newest team member, our goals are the same: to provide you with the innovative tools and support you need to effectively compete in today's competitive development market.

FarPoint's foundation began in 1991 (then Prescription Software) by re-introducing Drovers Professional Toolbox for Windows, what is believed to be the first development package available for the professional Windows developer, with thirteen new DLLs, including a fully featured spreadsheet control. Developers using languages such as C or C++ quickly realized the benefits of using our pre-built DLLs instead of spending their valuable resources to develop these controls internally.

The advent of Visual Basic 1.0 presented FarPoint with a new opportunity in the professional development market. After Microsoft asked that our spreadsheet be made available for their users, we introduced the first spreadsheet control ever available for Visual Basic in our product Visual Architect. Along with the spreadsheet control, Visual Architect offered formatted-edit controls in this new VBX format. The rising popularity of Visual Basic and our controls allowed us to introduce several new products to the market in the coming months: Spread/VBX, Aware/VBX, Grid/VBX, Tab/VBX, and Tab Pro, while continuing support for Professional Toolbox for Windows.

Today, FarPoint is one of the oldest and most respected vendors in the industry. We continue to cater our products to professional Visual Basic and Visual C++ developers by offering our components as a 32-bit ActiveX control, 16- and 32-bit DLLs, and a VBX control.

Contacting Us

Please contact us if you have questions or comments about this paper or FarPoint products.

Web site http://www.fpoint.com  
Phone Main (919) 460-4551
  Sales (800) 645-4913
E-mail Main farpoint@fpoint.com
  Sales fpsales@fpoint.com
  Technical Support fpsupport@fpoint.com
Fax (919) 460-7606

Return to top


Section 12: Notices

This white paper last updated: August 13, 1999

This white paper was developed to assist FarPoint Technologies customers in their use of ActiveX technology. The information in this document represents the view of FarPoint Technologies, Inc. on the topics discussed, as of the publication's date. The continually changing market conditions and general dynamic nature of the computer business mandates that FarPoint Technologies cannot guarantee the accuracy of any information published after the date of publication. This white paper was prepared solely for informational purposes. FarPoint Technologies makes no warranties, expressed or implied, in this document.

Information in this document is subject to change without notice and does not represent a commitment on the part of FarPoint Technologies, Inc.

© 1996, 1999 FarPoint Technologies, Inc. All rights reserved.

Unless otherwise noted, all names of companies, products, street addresses, and persons contained herein are part of a completely fictitious scenario or scenarios and are designed solely to document the use of a FarPoint Technologies, Inc., product.

Input Pro is a trademark of FarPoint Technologies, Inc.

ActiveX, Internet Explorer, Microsoft, VBScript, Visual Basic, and Visual InterDev are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. HomeSite is a registered trademark of Allaire Corporation. Other brand and product names are trademarks or registered trademarks of their respective holders.

This guide was produced using Allaire™ HomeSite®.