Previous Page TOC Next Page



Chapter 1


An Overview of ActiveX


by Weiying Chen

Microsoft has unveiled an extensive new solution technology for the Internet called ActiveX. Microsoft ActiveX is a broad and powerful abstraction for Microsoft Internet Solutions. Content providers and Internet application developers now have a robust and extensible frameworks that enables them to develop a new generation of Internet applications.

Microsoft is aggressively adding features to the Win32 Application Programming Interfaces (APIs) that will let developers "Internet-enable" their applications. These new features are based on Object Linking and Embedding (OLE) technology so that developers who have made investments into Win32 and OLE applications can leverage their investments.

ActiveX exposes a set of APIs that enables developing a new generation of client/server applications for the Internet. ActiveX has interfaces to integrate almost every media technology within an application. It provides extensive support for animation, 3D virtual reality, real-time audio, and real-time video.

ActiveX gives developers an open framework for building innovative applications for the Internet. ActiveX technologies form a robust framework for creating interactive content using reusable components, scripts, and existing applications. Specifically, ActiveX technologies enable content providers and application developers to create powerful and dynamic Web content and Web server extensions quite easily. This feat is achieved by using ActiveX controls, Active client and server side scripts, and the Active document interfaces and ISAPI (Internet Server Application Programming Interface).

COM: The Fundamental "Object Model" for ActiveX and OLE


COM (Component Object Model) is the technical cornerstone for the ActiveX technology; it defines how objects expose themselves for use within other objects and how objects can communicate between processes and across a network. You can easily integrate COM objects for use in many languages, such as Java, Basic, and C++. COM objects are reusable binary components.

The following concepts are fundamental to COM:


ActiveX Object Model


There are two primary pieces to the ActiveX Object Model: the Microsoft HyperText Markup Language (HTML) Viewer component (MSHTML.dll) object and the Web Browser Control (shdocvw.dll). Both are in-process (DLL-based) COM objects.classes.

All interfaces defined in the ActiveX Object Model are "dual" interfaces. A "dual" interface means that the objects inherit from IDispatch and IUnknown. They can be used by client application at "early-bind" via Vtable and at "late bind" via OLE automation controller by using IDispatch::GetIdsOfNames and IDispatch::Invoke.vtable).

MSHTML is the HTML viewer part of Microsoft Internet Explorer 3.0. It is an in-process COM server and a Document Object. It can be hosted in OLE Document Object containers.

MSHTML implements the OLE Automation object model described in the HTML Scripting Object Model. With this object model, you can develop rich multimedia HTML content. VBScript running inline in the HTML and Visual Basic 4.0 running external to the HTML can use the object model.

The Web browser control object is an in-process COM Server. It also serves as a Document Object container that can host any Document Objects, including MSHTML, with the added benefit of fully supporting hyperlinking to any document type.

The Web browser control is also an OLE control. The IWebBrowser interface is the primary interface exposed by the Web Browser Control.

The Web browser control is the core of what customers see as "the Internet Explorer 3.0 product.". Internet Explorer 3.0 also provides a frame to host this control. Internet Explorer 3.0 supports the following HTML 3.x0 extensions:


ActiveX Controls


ActiveX Control (formerly known as OLE control) has a broader definition. It refers to any COM objects. For instance, the following objects are all considered an ActiveX control.

Note


A moniker acts as a name that uniquely identifies a COM object. It is a perfect programming abstraction for Uniform resource locator(URL).

ActiveX Control used inside scripting languages make this binary reusable components reused in the Internet world. Almost any type of media wrapped into an ActiveX control can be seamlessly integrated into your Web page. Sound, video, animation, or even credit-card approvals controls can be used within your Web page.

ActiveX Scripting


ActiveX Scripting is the interface for script engines and script hosts. Following this interface specification, the script vendors can use their custom script engine in any script host, such as IE 3.0. What's more, with its infrastructure, developers can choose any script language they prefer. A script is some executable block, such as a DOS batch file, Perl script or an EXE file.

ActiveX Scripting components can be grouped into two major categories: an ActiveX Scripting Engine and an ActiveX Scripting host. A host creates a script engine so that scripts can run against the host.

Here are some examples of ActiveX Scripting hosts:

The ActiveX Scripting Engine is an OLE COM object that supports the IOLEScript interfaces, with at least one of the IPersist interfaces and an optional IOleScriptParse interface.

ActiveX Scripting Engines can be developed for any language, such as

Microsoft ActiveX Scripting Languages products, such as Visual Basic Script and Java Script, can be used to "glue" together the functionality exposed in ActiveX Controls to create rich Web-based applications.

Active Documents


Active Documents are based on the OLE Document Objects (DocObjects, for short). The DocObjects technology is a set of extensions to OLE Compound Document technology. It is the core technology that makes Microsoft Office Binder work. Active Document also refers to any document that contains ActiveX controls, a Java Applet, or a Document Object.

One other obvious application for this technology is "Internet browsers." You can open richly formatted documents, such as Microsoft Word and Excel spreadsheets, directly in the browser.

Figure 1.1 shows how seamlessly the Word document placed in IE 3.0. The word toolbar is added to the browser, enabling you to work on the document while cruising the Internet.

Figure 1.1. Active document.

The following describes the general criteria for the document object container and the document object.

A Document Object container must implement the following objects and interfaces:

Similarly, Document Objects must implement the following objects and interfaces:

Objects

Containers

For more information on the Document Object, please refer to Chapter 19, "OLE Document Objects," in this book.

ActiveX Server and Server-Side Scripting Framework


The ActiveX Server Framework, another component of ActiveX technologies, is based on the Microsoft Internet Information Server (IIS). IIS is built on the Windows NT Advanced Server 3.51 or greater. This framework enables developers to take advantage of the powerful Microsoft Back Office family of products, such as Microsoft SQL, SNA, Management, and Exchange Server.

Server support consists of ActiveX Server-side scripting and the usage of Aside, Batch, or JavaScript.

The Common Gateway Interface (CGI) is also supported under the ActiveX Server Framework. Common Gateway Interface is a protocol used to communicate between your HTML forms and your program so that your program can extract the information from the form. A lot of languages can be used to write your program, as long as the language has the capability to read the STDIN, write to the STDOUT, and read the environment variables.

An HTTP server responds to a CGI execution request from a client browser by creating a new process, reading the input from the form through the environment variable, doing some processing with the form data and write the HTML response to the STDOUT.

The server creates one process for each CGI request received. However, creating a process for every request is time consuming and takes a lot of server resources. Using too many server resources can starve the server itself.

One way to avoid this is to convert the current CGI executable file into a Dynamic Link Library(DLL) so that the DLL can be loaded into the same address space as the server. The server can load the DLL the first time it gets a request. The DLL then stays in memory, ready to service other requests until the server decides it is no longer needed. There are two types of DLLs that can be created for this purpose: one is the Internet Server application (ISA), the other is the ISAPI filter.

An ISA(Internet server application) is also known as the Internet Server Extension. There are two entry points for this DLL, GetExtensionVersion and HttpExtensionProc.

HTTP Server first calls the ISA at the entry point of GetExtensionVersion to retrieve the version number of the ISAPI specification on which the extension is based. For every client request, the HttpExtensionProc entry point is called. Interaction between an HTTP server and an ISA is done through extension control blocks (ECBs). The ISA must be multithread-safe because multiple requests can be received simultaneously.

An ISAPI filter is a replaceable DLL that sits on the HTTP server to filter data traveling between web browser and HTTL server. Figure 1.2 shows the relationship between the HTTP server, ISA, and ISAPI filter.

Figure 1.2. HTTP server, ISA, and ISAPI filter.

ISAPI filter has the same entry point as the ISA. When the filter is loaded, it tells the server what sort of notifications it will accept. After that, whenever a selected event occurs, the filter is called and is given the opportunity to process the event.

ISAPI filters are very useful to provide the following functions:

You can also install Multiple filters can be installed on the server. The notification order is based on the priority specified by the filter, then the load order in the registry, the registry key for filter is under \HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\parameters\Filter DLLs\. After you install the filter, IIS must be restarted.

To ease the development of the server-side application, Microsoft also provides an Internet Personalization System (IPS) on top of the IIS. It provides a server side VBScript and a set of server components and a system installed with IIS on a web server computer to make the server-side scripting available. With this system installed, you can integrate Visual Basic Script commands and expressions into the HTML files, and calls out to server side OLE automation objects. When you point your browser to a script file, this system will process the script and return HTML to the browser. This allows developers to create more elaborate content with less effort. Server-side scripting will make the server-side development a piece of cake.

Active Animation and Movies


Active Animation (formally known as Active VRML; VRML stands for Virtual Reality Modeling Language) is an advanced markup language and a viewer for 3D multimedia. The Active Animation viewer is an ActiveX control and can be used inside client side VBScript in Microsoft Internet Explorer 3.0. Web pages that use Active VRML can include interactive 2D and 3D animation, accompanied by synchronized sounds. These effects can also be triggered by events from VBScript in IE 3.0 and from other scripting languages such as JavaScript.

Active Animation synchronizes all media interaction without developers needing to write low-level code. It supports the operation and media types such as 3D geometry, images, sound, montages, 2D and 3D points, and vectors, 2D and 3D transforms, colors, numbers, text, strings, characters, and so forth.

Note

The Active Movie is based on the Microsoft Active Movie Streaming Format (.ASF), a new data-independent format for storing and transmitting multimedia content across the Internet. Because .ASF files can be streamed, you can begin playback of these files immediately. Active Movie is an ActiveX control and can be used inside client-side VBScript or JavaScript.

.asf is an open and extendible data-independent format. With this format, you can combine and store different data objects such as audio objects, video objects, URLs, and HTML pages into a single synchronized multimedia stream. This encapsulation feature enables popular media types and formats, such as MPEG, .avi, .wav, and Apple QuickTime, to be synchronized and stored efficiently on a variety of servers.

.asf data is also network independent and can be transmitted over different protocols and networks, including TCP/IP, UDP, RTP, IPX/SPX, and ATM.

.asf also provides efficient packaging for different network transports, supports multiple-bit rates, error correction, and other multimedia-content storage and transmissions.

You can efficiently play back .asf content by using Active Movie, Microsoft's next generation, cross-platform video technology for the desktop.

Why Use ActiveX?


With ActiveX, you can make the most of Internet resources with less effort. ActiveX Controls and Scripting give you the infrastructure needed to add language- and tool-independent extensions to Web pages. Using ActiveX Controls lets developers take advantage of existing OLE development tools and the investment they have already made in OLE. ActiveX Scripting allows you to drop any scripting engine into IE 3.0, enabling developers to add behavior to Web pages in whatever scripting language they prefer.

ActiveX has also greatly improved extending the HTTP and FTP protocols. The ActiveX IBindXXX interfaces encapsulate a new protocol that supports the concept of binding to a URL dynamically from within your application. An application binds to a URL moniker, which then communicates through the appropriate protocol to activate the OLE object. This abstraction allows newly developed protocols to integrate into your existing objects, independent of your object design or expressed functionality.

Using the Internet Extensions for the Win32 API (WinINet) makes it easy for developers to add Internet access to their applications. WinINet abstracts the TCP/IP protocol-specific details and gives developers a simplified programming interface to access the internet instead of worrying about the WinSocket details. This API includes HTTP, FTP and Gopher access.

As with most systems, server efficiency and resource use becomes a concern when designing multi-user server applications for the Internet. The Internet Information Server offers a high-performance, secure, and extendible framework. An ISAPI Internet Server Applications (ISA) is a dynamic link library that loads into the same address space as the HTTP Server component versus CGI creates a separate process for every work request. Each new process in the CGI model requires more server resources. The advantage of developing an ISA rather than a CGI is high-level performance that requires considerably fewer resources, which frees up resources that can then be used by the server.

The Internet Database Connector allows ODBC database access through an HTTP request.

ISAPI filters can be used to enhance the Microsoft Internet Information Server with custom features, such as enhanced logging of HTTP requests, custom encryption, aliases for URLs, compression schemes, or new authentication methods. The filter applications sit between the client network connection to the HTTP server.

IIS has a few built-in ISAPI DLL. One of them is Httpodbc.dll which is called the Internet Database Connector. The Internet Database Connector allows ODBC database access through an HTTP request. Developers can use this feature to create Web pages with information from the database so that they can retrieve, insert, update, and delete information in the database based on user input and perform any other SQL commands.

Active Movie provides next-generation, cross-platform video; the Active Movie Stream Format solves several important synchronization issues in multimedia-content storage and transmission.

Active Animation gives you a powerful foundation for Internet interactive, animated, and multimedia-based content, targeting domains such as advertising, entertainment, online shopping, and technical illustration.

Microsoft is building an infrastructure around the client/server model that enables secure transactions, billing, and user authentication. IE 2.0 and 3.0 supports the secure socket layer (SSL) 2.0 and 3.0 version and personal communications technology (PCT) 1.0 version. Most importantly, ActiveX is built on Win32 and OLE, which enables developers to build on their existing investments. ActiveX is the doorway to a whole new world of Internet applications.

ActiveX Program Development


The most fundamental model that you should understand before embarking on ActiveX development is the COM (Component Object Model). This model is the same model as discussed in the OLE COM specification.

COM is the "Object Model" for ActiveX and OLE. Microsoft also provides OLE COM wizard and ActiveX Template Library (ATL) so that developers can develop lightweight, fast COM objects. ATL offers a template to write OLE automation server, OLE controls, and the very basic dual interface or any arbitrary COM objects. ATL also provides a custom AppWizard (called OLE COM AppWizard in VC 4.x project workspace) which can be used with Visual C++ 4.1 or later to create a COM object skeleton.

Microsoft Visual C++ 4.1 Development Studio integrates different AppWizards and Control Wizard to simplify the development process. Along with Visual C++ 4.x is version 4.x of the Microsoft Foundation Classes. 4.1. In Microsoft Visual C++ 4.2, there is new support for ActiveX programming, such as

Besides the tools, wizards, frameworks, and foundation classes, Microsoft also provides a set of specifications to implement certain ActiveX controls. For instance, it provides the OLE controls for Internet, Document object, ActiveX scripting interface, Hyperlink interface, and Asynchronous Moniker specification.

ActiveX controls can be easily manipulated by any scripting languages in IE 3.0. The scripting languages include Java script and the client side VBScript and JavaScript, or any other third party scripting language that implements the ActiveX scripting interface. ActiveX controls, particularly OLE automation servers, can also be used with the server side VBScript.

Microsoft also provides J++ to develop the Java Applet and Java Applications. Java Applet can be used as an ActiveX controls.

Besides these ActiveX client side script, Microsoft also provides a system on top of the IIS 2.0 to use the server-side VBScript. ActiveX controls, particularly OLE automation server, can be referenced in the server-side VBScript.

A variety of tools can be used to develop server-side components, such as Perl and C for CGI programming.

To facilitate developing ISAPI applications, Microsoft Visual C++ 4.x provides the ISAPI Extension Wizard and some foundation classes for ISAPI. Along with this, Microsoft also provides the ISAPI specification.

The Active Movie add-on tool kit includes tools to develop applications that handle streamed media. This tool kit allows software developers to integrate real-time audio and video content in virtually any type of application.

Active Animation and Active Movie controls can be manipulated through client-side VBScript. A developer can glue the control's functions together without the need for complex stream synchronization methods.

Summary


ActiveX is a technology that has the potential to change the way information is accessed and used on the Internet. Powerful abstractions based on OLE have been developed that enable fast, scaleable integration of your objects within the Internet. Microsoft is making a major effort to make the Internet everything it can possibly be. By using ActiveX, developers can make the best use of their system resources while providing instant, dynamic content and functionality in their Internet applications. How information is presented greatly affects how interesting and usable people find it.

Previous Page Page Top TOC Next Page