by Warren Ernst
Up to this point, the term "ActiveX" has been thrown around somewhat ambiguously (both by the media and myself), sometimes being spoken of as if it were a single program you must buy from Microsoft, sometimes as a
non-specific set of concepts and ideas that make Web pages more visually interesting and interactive, and sometimes as a way to make the Internet work with all the business programs you already use to create documents, spreadsheets, and presentations. With
all these different descriptions floating around, each with a certain degree of truth behind it, it's sometimes hard to figure out just what Microsoft (and everyone else) is talking about when referring to ActiveX.
Therefore, to try to nail down a description, ActiveX is a computing technology composed of several different components, each performing a specialized task with common elements that are programmed similarly. Some components add computing
power to Web pages, others allow document-objects to call viewing programs from across the Internet, and others add new capabilities to Web servers. All the components use methods that are, if not capable of being shared among each other, at least similar
to each other. All use Object Linking and Embedding (OLE) technology to some degree to perform their tasks and are usually programmed in a language fine-tuned to Windows and OLE, such as Microsoft's Visual C++. With ActiveX technologies, Windows
programmers will have a much easier time combining traditional Internet connectivity programs with powerful desktop software packages, and Internet users will find it easier to use the Internet to create business documents and use Web browsers to perform
computing tasks.
These technologies exist today and are being put into use for innovative programs and Web programs that you can explore with Internet Explorer and other programs available from Microsoft. This chapter breaks down the technology that comprises ActiveX
into its fundamental components. Subsequent chapters delve deeper into each component on an individual basis.
The fundamental element of ActiveX technology is the ActiveX control, formerly called an OLE control. An ActiveX control is a modular piece of software that performs tasks and computes information, communicates to other
programs, modules, and the Internet by using OLE, and can be easily used and reused by any program or programming environment that can "contain" ActiveX controls, such as Web browsers like Internet Explorer 3.0, or programming environments like
Visual Basic, Visual C++ 4.0, or FoxPro. Controls have computational power, communications power, and their own small graphical interface (though its GUI can be disabled for truly custom applications); they can be used like Java applets within Web pages or
as any other control in a program created with an ActiveX-compatible programming language. It's for this reason that the term "control" should mean something to Windows programmers, but it might not mean much to an Internet or business
application user who has no need to write programs that use controls.
There are many different types of ActiveX controls, each with different capabilities, but all with the potential to do many things. Some are especially adept at Web page special effects, so some of these are included with
Internet Explorer 3.0. Others are adept at numeric calculation or image manipulation and are included with programming languages. Some are good at manipulating databases and are included with Microsoft Access and FoxPro. And, of course, if a pre-existing
ActiveX control doesn't have the capabilities you need, you can create new ones yourself.
Since ActiveX controls can be as different from each other as the different programs on the shelf at a software store, it's somewhat difficult to say what all ActiveX controls share, can do, or have the potential for. And since new ones are being
written all the time, it's hard to predict what the majority of new ones will do. However, it is exactly this unknown application of ActiveX that makes the technology so exciting; it truly is an open technology! Despite the inability to predict where
ActiveX will take you, it's certainly worthwhile to at least consider the capabilities provided by ActiveX controls:
In case you haven't noticed, Web pages display only predetermined information in a Web browser and are incapable of generating new information from existing data. For that
matter, the HTML environment is limited because it can't manipulate existing data in any way. Web pages are static, unchanging lines of human-readable text that perform no computing task whatsoever. ActiveX controls, on the other hand, are capable of
computation and data manipulation.
Since ActiveX controls can easily be embedded within Web pages or entire programs, they provide a simple way to either add computing ability to Web pages or a specialized
computing task to a larger program. (See Figure 4.1.) To work in a Web page, the Web page browser must be able to "contain" ActiveX controlsto work in a custom-built application, the programming language must be able to "contain"
them, too. Currently, the Microsoft Internet Explorer 3.0 and the Netscape Navigator (with the NCompass ActiveX plug-in module) are ActiveX containers, so controls will be able to run in most people's browsing programs.
Figure 4.1. Once an ActiveX control is built, it can be used for a wide variety of purposes.
It's hard to discuss computing and manipulating data without considering performance at some point. It turns out that performance is a particularly significant benefit of using ActiveX controls, especially for manipulating
data. Since ActiveX controls hide the details of how the data computations are being performed, you're free to create a highly optimized data-processing control that yields speedy results for the calling application. Additionally, since ActiveX controls
can be written in any language, you gain the benefit of using a quicker language, like C++
over Basic (or Java), if you so choose.
Computing information without being able to share it through a wide array of methods can be a problem and can limit a control's usefulness
(which is a common Java applet problem), so ActiveX controls have many communications options available to them. First, since their lineage can be traced to OLE controls, ActiveX controls are completely conversant in the language of OLE. This means that
ActiveX controls can share data with or give instructions to any other OLE-capable object, including other ActiveX controls (even those in the same Web page), desktop applications like Word or Excel, the Web browser, or even the operating system itself.
This includes, but is not limited to, the host computer's file system, giving ActiveX controls the ability to read and write files.
Second, ActiveX controls can be fully TCP/IP enabled, already
aware of the popular conventions and protocols that make Internet-wide communication possible. This means that, with a few simple functions on the programmer's part, a control can send a request for a Web page at a URL with the HTTP protocol or retrieve a
remote file through FTP. When embedded in a "traditional business application," this means Internet connectivity might be only a pull-down menu away.
When these two powers of ActiveX controls are combined, OLE links could be introduced over the Internet itself. This would allow programs or modules of Web pages, desktop applications, and
ActiveX-enabled Web servers to share data and computational power like never before. Microsoft is currently working with the Internet community to make this new form of distributed computing a widely accepted standard, and it's already working at some
locations.
The ability of ActiveX controls to communicate widens the concept of workgroup computing to include the whole of the Internet. With OLE, it's possible to work with dynamically linked data in local workgroups. In other words, one person could have a
Word document containing an embedded Excel spreadsheet that's being modified by another person. The Word document is kept up-to-date with the spreadsheet through an OLE link, therefore allowing both people to jointly work on the task at hand. ActiveX
controls extend this capability beyond the local workgroup by providing a means to have linked information across the Internet, thereby making the physical location of each workgroup member less of an issue. This is a major step forward, especially for
those of us who like to work at home!
Finally, ActiveX controls are reasonably easy to create from scratch; if no control exists to perform the task you need, you can create one. Currently, you need Microsoft's Visual C++ programming environment and must follow the ActiveX programming guidelines (available electronically or on CD-ROM), but support for other languages will be available at some
point, including Java and Visual Basic. This is an important aspect of ActiveX controls: They can be implemented in any programming language. So if you already have significant programming experience, you can go the C++ route; if you want to keep things a
little more simple, you can use Visual Basic. Also, if you've jumped on the Java bandwagon, Microsoft has mentioned a future ability to build ActiveX controls using Java.
Since ActiveX controls are modular objects, you can introduce a certain degree of functionality to both your Web pages and all your programs by just creating one ActiveX control. You can then initialize it slightly
differently, depending on whether it's in a Visual Basic program or a Web page. The whole idea of developing modular controls is that they can be reused in many different ways. If you don't care to program an ActiveX control yourself, since they are so
easy to build and use, you might find one either in the public domain or a commercial market that suits your needs. You can then simply embed it within your workthe ultimate time saver!
For Internet users and Webmasters, the thought of custom-creating ActiveX controls using Visual C++ just to add some functionality to a Web page
might (and should) create some anxiety. Fortunately, there's another option for enabling OLE communications within Web pages that is fast, powerful, and easy to learn: ActiveX's scripting componentVisual Basic Script (or VBScript, or just VBS).
Similar in concept to JavaScript, VBScript is a Web page scripting language that has all the power (and more) of JavaScript, the gentle learning curve of Visual Basic, and the OLE communications power of ActiveX controls, all rolled into one. It is
written in plain English directly into Web pages, alongside the HTML coding in an HTML file, and is interpreted on the fly by the VBScript-enabled Web browser displaying the page, such as Internet Explorer 3.0. It may be the perfect scripting language for
the Internet because it has real computing power, can easily initialize ActiveX controls, and is relatively simple to learn.
Visual Basic Script is a subset of Windows' most popular programming language, Visual Basic 4.0, so people already familiar with VB will feel right at home with VBScript.
It's also a subset of Visual Basic for Applications (VBA), so if you write scripts and macros for Word or Excel, VBScript will also feel familiar. On the other hand, if you have never programmed in Visual Basic, you'll find that it isn't that hard to begin
writing useful scripts with VBScript and that these new skills will carry over beautifully for Visual Basic, which is a skill worth having if you work with Windows.
Visual Basic is a strain of BASIC (with lots of extras), which means it's among the easiest programming languages to learn if you have no programming experience. If you know another language already, your programming skills will carry over quickly.
This is very different from learning JavaScript, which requires in-depth knowledge of C++ and the basics of object-oriented programming to be used effectively. All you really need to start writing powerful scripts is general programming knowledge, not specialized C++ knowledge.
As a member of the ActiveX family of components, VBScript can communicate through OLE to any other OLE-compliant piece of software, which, as
has been mentioned, includes ActiveX controls, desktop applications like Word and Excel, Internet Explorer 3.0, and the operating system. Since it's so easy to write a VBScript that can easily communicate with such a wide variety of objects, a great number
of Web page possibilities open up to someone with just a little Visual Basic experience.
Since VBScripts can communicate with ActiveX controls, they can initialize controls within Web pages to work with Internet data. In fact, since VBScripts can interact with Web page users through forms, fairly generic controls can be custom-configured
to specific purposes on the fly. VBScripts can also modify Web page forms based on user input from other Web page forms or controls, or from other OLE-equipped applications or operating system calls. In short, VBScript can act like the "glue"
that binds Web page users, generic ActiveX controls, and information from business applications into new and active Web pages, the likes of which have never been seen before.
Part of the problem (well, "problem" is too strong a word) with the Web today is that it's at the mercy of the HTML file format. I say "problem" is too strong a word because,
were it not for the acceptance of HTML a couple years ago, the Web would not have become the popular communications medium it is today. However, now that the Internet has matured and users want more and different forms of information that just aren't
suited to HTML, there's a problem both for users and software developers.
To the software developer, the problem arises when you have a program that's well suited to Internet access, but creates or uses files that aren't HTML and aren't suitable for being converted into
HTML or embedded within HTML, such as three-dimensional models and real-time data feeds. What to do to ensure that anyone who comes across your Web page can see the data or information generated from your program? Your options weren't all that great until
ActiveX documents became a reality. In fact, programmers have been forced to divide their efforts and expertise between two entirely different types of programming: programming for local use and programming for the Internet. One of the primary goals of
ActiveX is to unify software development so that applications can be developed without regard for the differences between local access and Internet access.
One solution to moving applications to the Web is to make your program a "Helper Application," where it's called as a secondary window outside the browser. However, this increases window
clutter and might confuse users with a totally different interface. You might consider making your program a Netscape plug-in module, but doing so eliminates your interface entirely and reduces the
nature of your product to something that just works within another company's Web browser. You'd also have to compile a separate version just for Web browser use.
The new and alternate method is to write your program and the program's data structure as ActiveX documents, so that they both enjoy the benefits of OLE over the Internet.
Imagine using a file format able to automatically launch the program that can use it from directly within a Web browser. ActiveX
documents can. When Internet Explorer 3.0, an ActiveX document "container," comes across a file format it can't read that is an ActiveX document, the file's native program can launch within Explorer's window, combining Explorer's toolbar
and menus with those of the viewing program. The result is a file that opens without conversion in the same, single window used to view Web pages, but with the functionality required to manipulate the new file.
Additionally, virtual reality and PowerPoint presentations can be seen on the Internet as ActiveX documents. When these files are encountered, they are considered OLE objects by Internet
Explorer and launch their respective programs within Explorer's window, combining commands and interfaces in a way that most users find much simpler than Helper Applications or plug-in modules. For the future, Microsoft is working with the Internet
community so that OLE links will extend not only to the user's local hard drive or network, but across the Internet. Soon, when an ActiveX document file format transfers to Explorer that requires another program located on the Internet, it will transfer
along with the file and appear within the browser automatically. For the Internet user, nothing could be simpler.
To the programmer, the results from a little more work to enable ActiveX documents are well worth the effort. The program component of an ActiveX document is really just a Windows program with
OLE edit-in-place capability and a few additional OLE extensions. Although these modifications to existing programs aren't trivial, you get many extra features by embracing them.
First, your standalone program will automatically work within ActiveX document "containing" Web browsers, like Internet Explorer, whenever your data file format is opened and be available for in-place editing through the Internet. It will
also work within the Microsoft Office Binder and the operating system shell of future versions of Windows 95 and Windows NT. It will work as you always thought it would, as a standalone application if you like, and it all comes from one executable and one
set of source code, without the need to maintain multiple versions. For the programmer, nothing could be more flexible!
Who says only Web browsers can benefit from Internet-wide OLE-based technology? When you consider that much of the information retrieved from the Internet is being
created by Windows-based "business applications," why not have Web servers send out the information from the platform on which it was created? And then use OLE-based ActiveX technology to use existing Windows resources to add new Web serving
features? This is what ActiveX-enabled Web servers are all about, and the key to it is the ISAPI, or Internet Server Application Programming Interface, and the ISAPI filters that use it.
The ISAPI filter can be thought of as the next
generation of CGI scripts, but written for any brand of Windows-based Web server that follows the ISAPI specification. An ISAPI filter, unlike a CGI script, can analyze and respond to the information stream before it enters or after it leaves the
traditional control of a Web server, then send it on its path as if it had never been touched. In a sense, it tells the Web server: "If something like this happens, let me take care of it and get back to you." Contrast this to CGI scripts, which
only indirectly handle data from the connection, with the Web server acting as the middleman.
ISAPI filters are simply Dynamic Linked Libraries (DLLs) with an OLE link to the Web server, which allow them to communicate with the server and manipulate the data
stream in an unprecedented way. This OLE capability can also be used to call desktop applications and borrow some of their computing power to generate information, convert formats, and so on, to augment the filter's own computational ability. This
technology will also play a role in enabling the
ActiveX document OLE link across the Internet.
Now that you have some idea of what ActiveX is made of, component by component, the next few chapters will discuss these components in detail and in plain English, starting with ActiveX documents. Part III, "Developing ActiveX Controls" dives
deeper into these topics, discussing programming methods and tips.