![]() |
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 |
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.
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.
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."
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.
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:
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:
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.
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).
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
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).
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.
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 | |
| Main | farpoint@fpoint.com | |
| Sales | fpsales@fpoint.com | |
| Technical Support | fpsupport@fpoint.com | |
| Fax | (919) 460-7606 |
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®.