Working with ActiveX Controls

Microsoft Internet Explorer has supported the use of ActiveX controls since version 3.0, and the majority of modern development environments (like Microsoft Visual InterDev and Microsoft Visual Basic) make adding ActiveX controls to other Windows programs easy for developers. Although no current version of Netscape Navigator directly supports ActiveX, a plug-in from NCompass Labs Inc. (found at www.ncompasslabs.com) adds a level of ActiveX support to Netscape Navigator.

ActiveX controls are essentially traditional programs (written in C++ or Visual Basic, for example) that adhere to a certain set of standards. These programs can be used within other programs, most commonly browsers, to add functionality that would not otherwise be available. Many of the built-in controls referred to throughout this book are ActiveX controls—the tabular data control and the Structured Graphics control, for example. In addition to the built-in controls, thousands of other controls are available from Microsoft and many other companies.

No matter where the controls come from, the process of incorporating them into a Web page is basically the same. You can include either a built-in control or a third-party control by using the OBJECT element.

NOTE
To let users of the NCompass ScriptActive plug-in for Netscape Navigator access ActiveX controls on a Web page, a developer must do more than just use OBJECT elements. This plug-in (like all plug-ins) must be activated with an <EMBED> tag. NCompass provides tools that assist in the conversion of pages that use standard <OBJECT> tags so that they also include <EMBED> tags. For more information about getting a Web site to work under ScriptActive, consult the NCompass Labs Web site at www.ncompasslabs.com.

Anatomy of an OBJECT

When you include a third-party ActiveX control in your Web page, you enclose the control in <OBJECT> tags, just as you do for a built-in control. When a control is not already available on a client's system, however, additional information is necessary, as shown in Code Listing 22-1. This code sets up a popular ActiveX control, the Macromedia Flash control. This software is available as a Netscape plug-in, so the listing also uses an <EMBED> tag.

Notice the CODEBASE attribute in Code Listing 22-1. Internet Explorer allows software to be downloaded and installed based on the setting of this attribute, which, in this instance, specifies the location (URL) of a CAB file. A CAB file is a single compressed file that contains all the files necessary to install the ActiveX control on the user's computer. If the Web page is opened on a computer that does not have the ActiveX control already installed, the CAB file is (at the user's discretion) downloaded, extracted, and installed. The page can then load and run normally.

Code Listing 22-1.

 <HTML> <HEAD> <TITLE>Listing 22-1</TITLE> </HEAD> <BODY> <OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"   CODEBASE="http://active.macromedia.com/flash2/cabs/     swflash.cab#version=3,0,0,0" [Must be on previous line]   ID=INDEX WIDTH=95% HEIGHT=95%>   <PARAM NAME="movie" VALUE="myFile.swf">    <PARAM NAME="loop" VALUE="false">    <PARAM NAME="quality" VALUE="high">  <EMBED SRC="myFile.swf" LOOP="false" QUALITY="high" SWLIVECONNECT="false"   WIDTH="95%" HEIGHT="95%" TYPE="application/x-shockwave-flash"   PLUGINSPAGE="http://www.macromedia.com/shockwave/download/     index.cgi?P1_Prod_Version=ShockwaveFlash"> [Must be on previous line] </EMBED> </OBJECT> </BODY> </HTML> 

At the end of the CODEBASE setting, you see version information. The computer uses this information to compare the control it already has (if any) to the version available for downloading to ensure that it will be using the latest version. For this process to work, the CAB file must be built properly and the specified location must be correct.

Other than the inclusion of the additional information in the CODEBASE setting, the OBJECT element works the same for both built-in and external controls. Most controls have their own attributes, properties, and methods that can be set at design time or accessed through scripts. It is up to the developer of the control to provide the details about how to use it.



Dynamic HTML in Action
Dynamic HTML in Action
ISBN: 0735605637
EAN: 2147483647
Year: 1999
Pages: 128

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net