In This Chapter
ActiveX Overview
Using ActiveX Controls
Optimizing ActiveX for Internet Explorer 4 Using ActiveX Controls in Web Pages Listing and Removing ActiveX Controls Signing ActiveX Code
Using Multimedia Controls
ActiveX Overview
ActiveX enables software components to interact with each other in a networked environment, regardless of the language in which they were created. Embracing both Java and Microsoft industry-standard component object model (COM) technology, ActiveX makes writing Internet applications as easy as writing applications for the operating system. You can create ActiveX components that provide standard application features and functions and then easily reuse the components in current networking and stand-alone applications.
The following sections describe how you can use ActiveX with Internet Explorer 4. For more information, see the Microsoft Internet Client Software Developers Kit (SDK) and visit the Microsoft Developer Network at http://www.microsoft.com/msdn/
as well as the SBN programming workshop at http://msdn.microsoft.com/workshop/
.
For information about troubleshooting authoring for Internet Explorer, see Appendix G.
Using ActiveX Controls
ActiveX controls are components (or objects) you can insert into a Web page or application to provide sophisticated formatting features and animation. ActiveX controls are small and versatile, and open limitless opportunities for creating spectacular Web content. ActiveX controls can be written in most programming languages, including Java, C++, and Microsoft Visual Basic. ActiveX controls can be easily reused by others in their Web pages and applications.
The open, component architecture of ActiveX enables you to create dynamic Web content and applications using proven COM technology, scripts, and software components (including Java applets). This architecture enables stand-alone applications to interact with each other. You can run ActiveX components in Internet Explorer that interact with other applications and components. For example, you could use a database access applet that interacts with a script to display multimedia graphics of data in Internet Explorer.
Because ActiveX controls are based on COM, the controls are language-independent. Java is an excellent programming language for both implementing and using COM objects, and Java and COM integrate seamlessly. COM makes Java a distributed language. Every public Java class is a COM object and can be called remotely just like any other COM object. COM gives Java direct access to native code. Any COM object appears to the programmer as a Java object. There is no need for large class libraries that wrap existing objects; the existing objects can be called directly.
Hundreds of ActiveX controls are available today with functionality ranging from a timer control (which simply notifies its container at a particular time) to full-featured spreadsheets and word processors. If you can imagine it, you can do it with an ActiveX control.
Optimizing ActiveX for Internet Explorer 4
Internet Explorer 4 complies with the OLE Controls 1996 (OC96) specification for host containers. Therefore, ActiveX control developers can now create faster, smaller, and more integrated controls that include:
-
Windowless controls. These controls allow creation of transparent and nonrectangular controls, which combined with 2-D placement, enable Web publishers to overlap controls on a page. The multimedia controls included with Internet Explorer 4 are all windowless and take advantage of this functionality.
-
Apartment-model controls. Internet Explorer is a threaded container. For better performance, controls used inside Internet Explorer 4 should be marked as Apartment or Free Threaded.
-
Quick Activation. The complex "QI Dance" that control writers needed to write is greatly simplified with Quick Activation. In most cases, a single call can initialize most controls.
-
SBindHost service. Internet Explorer's support for the SBindHost service allows controls to download additional data asynchronously. This results in better performance for controls that download images or other complex data.
Controls written for previous versions of Internet Explorer work in Internet Explorer 4, but don't take advantage of these new OC96 enhancements. You can rewrite older controls to take advantage of the OC96 enhancements, but the control will not work in previous versions of Internet Explorer. Of course, you can always provide separate controls for browsers that don't comply with OC96.
With Internet Explorer 4, ActiveX controls have full access to the Document Object Model of Dynamic HTML. A control can now read its host page and modify all elements in the page at any time. Anything you can do in a script, you can do from an ActiveX control. You can use ActiveX controls to extend the capabilities of Dynamic HTML and create a wide range of interactive and animated Web page applications.
For example, you can apply filters and transitions to windowless controls, such as Microsoft DirectAnimation™ controls, to easily create spectacular multimedia effects. For more information, see "Multimedia Controls" later in this chapter.
Using ActiveX Controls in Web Pages
You can add ActiveX controls to your Web pages by using the standard HTML OBJECT element. The OBJECT element includes a set of PARAM elements that you use to specify which data the control should use and to control the appearance and behavior of the control.
To use an ActiveX control in a Web page, you refer to its Class ID Number as shown in the following example:
<OBJECT CLASSID="CLSIDXXXXXxxx…" ID="the name of the control"
CODEBASE="URL of .ocx or .CAB file" #="version number">
<PARAM NAME="parameter name" VALUE="value">
<PARAM NAME="parameter name" VALUE= "value">
</OBJECT>
The CLASSID and version number of the control are generated when the control is compiled.
When downloading ActiveX controls is enabled in the security options, Internet Explorer 4 downloads controls and stores the controls on users' computers. Installed controls are used for Web pages that reference the control. Internet Explorer compares the version number of the installed control to the version number specified on the Web page. If a new version of a control is available, Internet Explorer downloads, stores, and uses the new version.
Listing and Removing ActiveX Controls
Internet Explorer 4 stores ActiveX controls in the following special Windows directory:
C:\Windows\Downloaded Program Files
You can open this directory using Windows Explorer to list installed ActiveX controls, to view information about the installed controls, to update the control with the latest version, or to remove controls.
Windows Explorer lists the following properties for installed controls:
-
Program File
-
Total Size
-
Status
-
Creation Date
-
Last Accessed
-
Version
You can use the control's Properties dialog box to view more detailed information about the controls.
To view detailed information about a control
-
Select the General, Dependency, or Version tab to view information about the control.
If your browser does not support inline frames, click here to view on a separate page.
|
Option
|
Description
|
|
General Tab
|
|
|
Type
|
Displays the type of control. If the type is Shortcut, you are viewing the properties for the shortcut to an item, not for the original item.
|
|
Created
|
Displays the date that the control was created.
|
|
Last Accessed
|
Displays the date that the control was last opened.
|
|
Total Size
|
Displays the size of the control files.
|
|
ID
|
Displays the Class ID (CLSID) for this control. This is the same ID that appears in the OBJECT element in the Web page.
|
|
Status
|
Displays whether the control is installed, damaged, or unplugged. Damaged means that one or more of the dependency files has been deleted. Unplugged means that an installation program has registered the .ocx file in a location different from where the code download installed it.
|
|
CodeBase
|
Displays the URL from which the control was installed. Internet Explorer uses this URL to update the control.
|
|
Dependency Tab
|
|
|
File name
|
Lists the files on your computer, which this control requires to run. If any of these files are missing, the control will not work.
|
|
Package name
|
Lists any Java packages on your computer, which this object requires in order to run. If any of these packages are missing, the control will not work.
|
|
Version Tab
|
|
|
Version
|
Displays the version number of this control. Internet Explorer compares this version number to the version number appearing in the OBJECT element in the Web page to determine if a more current version is available.
|
|
Description
|
Displays a description of the control.
|
|
Company
|
Displays the name of the publisher of the control.
|
|
Language
|
Displays the language version of the control.
|
|
Copyright
|
Displays the copyright information for the control.
|
To update a control
-
From Windows Explorer, right-click the control, and then click Update.
Internet Explorer downloads the latest version of the control from the Web.
To remove a control
Signing ActiveX Code
In Internet Explorer 4, you can set several security options for ActiveX controls and plug-ins to restrict the download of ActiveX controls for each security zone. For example, you can prevent the downloading of unsigned ActiveX controls from sites located in the Internet zone, but enable the downloading of unsigned ActiveX controls in the Local Intranet zone. For more information about setting security options for ActiveX controls, see "Customizing Security Zones" in Chapter 27, "Security Zones."
You should obtain a digital certificate from a Certificate Authority (CA) and digitally sign ActiveX controls consistent with your organization's security policy. You could decide not to sign controls for your Local Intranet zone, because you trust all of the sites. However, keep in mind that if you allow unsigned ActiveX controls to download automatically with no user intervention, you are also trusting any unsigned controls users may obtain from the Internet and reuse on your intranet. At a minimum, it is recommended that you sign ActiveX controls used for Web pages on the Internet to assure users of the integrity of your controls. For more information about digital certificates, see "Understanding Digital Certificates" in Chapter 28, "Digital Certificates."
You apply a digital signature to an ActiveX control at the time it is compiled. For more information, see "Signing Code with Microsoft Authenticode Technology" in the Microsoft Internet Client SDK.
Using Multimedia Controls
For Web publishers who want more multimedia effects than Dynamic HTML offers, Internet Explorer 4 includes the run-time version of the Microsoft DirectAnimation multimedia controls. A component of the DirectX® set of APIs, DirectAnimation provides unified, comprehensive support for such diverse media types as 2-D vector graphics, 3-D graphics, sprites, audio, and video, and a uniform time and event model.
Because DirectAnimation is a COM API with an underlying run-time engine, the DirectAnimation functionality can be accessed — in different ways — by a wide variety of programmers and authors:
-
HTML authors can integrate animation using the DirectAnimation controls.
-
Authors using VBScript or JScript, or Java applets, can program Web-page animation with Dynamic HTML.
-
Programmers using Java, Visual Basic, and Visual C++® development systems can develop ActiveX controls or full applications that require multimedia support and interactive features.
The DirectAnimation run-time controls provide Internet Explorer 4 with access to many of the DirectAnimation scripting functions and libraries to implement additional multimedia and animation effects. The run-time controls allow you to deliver impressive vector graphics, image, and animation content over the Web with little code and short download times. The run-time controls include:
-
Sequencer. Easily controls timing of events on pages.
-
Structured graphics. Provides high-quality, lightweight, scalable, rotatable graphics. Internet Explorer 4 provides programmatic access so you can dynamically add new graphic elements through script. For example, you can create HTML applications that read values from a data-bound control and then create appropriate graphs.
-
Effects. Alters any item on a Web page by applying a graphic filter. For example, you can add a glow filter and button bevel. The button bevel lets you dynamically create in/out beveled buttons from images and text.
-
Transitions. Alters any item on a page, or the page itself, over time.
-
Behaviors. Applies high-level behaviors to controls and Dynamic HTML elements.
-
Sprite. Creates animated images.
-
Sprite buttons. Creates animated multistate buttons.
-
Path. Easily moves objects across a two-dimensional path.
-
Mixer. Mixes multiple WAV files together dynamically.
-
Hot spot. Establishes regions of the screen that can process mouse clicks.
All of these controls are transparent, windowless, and can be seamlessly integrated with Dynamic HTML. You can easily add DirectAnimation content to your Web pages by using the DirectAnimation controls as OBJECT elements and setting parameters (PARAM elements) on these controls — without programming at all.
Because DirectAnimation is integrated with Dynamic HTML, it is especially suited to adding compact animation effects to Web pages. For example, you can include DirectAnimation controls as windowless controls on the page (overlaying other elements such as text) and apply filters and transitions to DirectAnimation controls.
For more information, see the DirectAnimation SDK (included with the Microsoft Internet Client SDK), and visit the SBN Workshop at http://msdn.microsoft.com/workshop/
.