Chapter 1

Introducing ActiveX Controls


CONTENTS

A lot of people are wandering around mumbling something like "ActiveX; what is ActiveX?" Nobody knows for sure. You can check day to day with Microsoft to see what the latest definition of ActiveX is, but you'll soon tire of doing so.

ActiveX is a big umbrella that Microsoft uses to encompass all of its Internet-related technology. It's not a product. It includes technologies that programmers can use to build Internet-enabled applications, products that end-users can use to access the Internet, and technologies that content developers can use to build terrific Web sites.

One of the most exciting ActiveX technologies is ActiveX controls. These controls let you add diverse functionality to your Web site by inserting a control right in the Web page. You can insert a control that pops open a menu, for example, or you can insert a control that performs a query on a database and displays the result. There are thousands of controls available; you need only find one to fit your needs.

TIP
ActiveX is another example of a buzzword gone awry. Microsoft serfs do not pronounce the X in ActiveX. It's silent. Instead of saying active-x-controls, for example, say active-controls.

The Evolution of ActiveX Controls

In the November 1, 1996, edition of Windows Magazine, Fred Langa traced the lineage of ActiveX controls back to the early days of cut-and-paste. Do you remember how cool that seemed back then? Cut-and-paste was touted as one of the major benefits of Windows because you could now share data between different applications.

OLE

Next comes OLE (object linking and embedding). This technology allows objects to be inserted into containers. In layperson terms, OLE allows a document from one application to be embedded within a document in another application. When you insert an Excel spreadsheet into a Word document, you are using OLE. You are also using OLE when you insert a picture into a Word document.

The first step was OLE 1.0. OLE 1.0 only provided the ability to share documents, not the ability to actually work with a document that's embedded within another. OLE 2.0 came along and allowed users to work on a document while embedded within another. For example, if you embed a spreadsheet in a Word document, as shown in Figure 1.1, you can work with that spreadsheet within the Word document. Thus, you can even use Excel's toolbars and menus while working with the spreadsheet in the Word document.

Figure 1.1 : Choose Insert, Object from Word's main menu to see the types of objects you can insert into a Word document.

Following OLE 2.0 is OLE 2.5, or Distributed OLE. Distributed OLE lets you work with documents and links across a network. Thus, you don't have to worry about the location of documents on a network (even the Internet), as they all appear to be local.

ActiveX Controls

Now Microsoft has breathed new life into OLE and called it ActiveX controls. In reality, both OLE and ActiveX controls are based upon COM (Component Object Model). OLE is still alive and kicking. You use it all the time in the applications you know and love. ActiveX controls, on the other hand, are a trimmer version of OLE that's built for distribution on the Internet and is optimized for size and speed. You can insert an ActiveX control into any ActiveX container, such as Internet Explorer, Microsoft Office 97, and even the Windows desktop (with the help of Internet Explorer 4.0).

NOTE
On the Internet, the availability of technology across all platforms is a key to that technology's success. As a Web developer, it doesn't make sense for you to rely on technology that is only available for the Mac, does it? Likewise, Microsoft knows that if UNIX and Mac users do not have support for VBScript and ActiveX objects, no one will develop Web pages with it because they can't reach the largest possible audience. all those UNIX and Mac users will be left out in the cold. Thus, Microsoft intends to make ActiveX available across all of the popular platforms you find on the Internet.

What ActiveX Controls Mean to You

If ActiveX is a technological umbrella, then ActiveX controls represent the umbrella's handle. They are the basic building blocks of ActiveX.

As you read, ActiveX controls are based upon COM (Component Object Model). They are a refinement of what you know as OLE custom controls. Any program that is a container for ActiveX controls can host them. Thus, you can stick ActiveX controls in a Web page since Internet Explorer is a container. You can also stick ActiveX controls in a Visual Basic application since Visual Basic forms are containers.

Currently, there are already more than a thousand ActiveX controls available because ActiveX is based upon a technology-OLE-that's been around for quite a while. Whereas it'll take time to build strong developer support for Java or Netscape plug-ins, ActiveX controls have immediate developer support from millions of programmers all over the world. Microsoft has been working with this technology for years using a different name.

ON THE WEB
You can get a good idea as to what types of ActiveX controls are available by opening http://www.microsoft.com/activex/gallery in your browser.

Working with Data

Remember what Web pages were like a few years back? They were static. The Web browser displayed what it was given: a fancy text file that contained information (HTML) about how the browser should display it. Once the browser had displayed the Web page, nothing changed. It just sat there. Great for reading the Unabomber's Manifesto, but not very useful or productive.

ActiveX controls let the content developer build Web pages that actually work with data they're given. The Web page is not static. It changes depending on the data the controls are working with and input from the user. That's starting to sound like what a program does, work with input and provide output. In fact, you can actually distribute programs, as ActiveX controls, via the Web page.

Here are a few examples of the types of things an ActiveX control can do with data:

Integrating with Windows

Since ActiveX controls are fully conversant in COM, they can work closely with the other COM objects on the user's computer. For example, an ActiveX control can manipulate a document in Microsoft Word or it can work with the user's Windows 95 desktop (a container).

CAUTION
ActiveX controls are not limited as Java applets. they have full access to your computer, including your file system, when they run. Make sure you install only those controls that come from vendors you trust. For more information, take a look at Chapter 5 "understanding Authentication and Security."

Provide Building Blocks

You should think of ActiveX controls as building blocks that you can assemble from a bunch of small building blocks into a much larger structure. You can combine a variety of ActiveX controls to build a solution that you distribute on the Web page. Here are some ideas of the types of things you can build with ActiveX controls:

ActiveX versus Everything Else

From time to time, you may have heard a bit of confusion about what ActiveX is and is not. I've heard questions such as, "why do I need ActiveX when I can use Java? What's so great about ActiveX controls when compared to Netscape plug-ins?" The sections that follow will answer many of these questions for you.

ActiveX and Forms

ActiveX controls do not supplant forms. Forms have their lot in life. They collect basic data from the user, as text boxes, check boxes, lists, and so on, and submit that information to the server. Scripts on the server do as they see fit with the information. The script can add the information to a database, for example, or verify a user's logon to a Web site. ActiveX controls let you collect information from the user, but they do much more than forms, as shown in the following list:

Even though ActiveX controls are not really related to forms, you can still submit the contents of a control with a form. You learn how to do this in chapter 2, "Inserting ActiveX Controls on the Web Page."

ActiveX and Plug-ins

Are ActiveX controls comparable to Netscape plug-ins? Yes and no. You can use both ActiveX controls and plug-ins to enhance the content of a Web page. For example, you can use an ActiveX control to display a video just as well as you can use a plug-in. Here are some of the biggest differences between ActiveX controls and plug-ins:

ActiveX and Java

Microsoft contends that ActiveX and Java are not competing technologies-they're complimentary. You don't have any reason to disbelieve them, either. Here are some of the bigger differences between ActiveX controls and Java applets:

Other ActiveX Technologies

ActiveX controls are not the only thing Microsoft has stuffed under the ActiveX umbrella. In reality, ActiveX is a magic buzzword that encompasses a lot of different products and technologies. The sections that follow describe the products that are add-ons for Internet Explorer and the ActiveX technologies which Microsoft has produced.

NOTE
Microsoft has transferred "stewardship" for ActiveX to an independent group called the ActiveX Working Group. You can get more information at http://www.activex.org.

ActiveX Products

There is more to Internet Explorer than just a Web browser. It also has add-on products that let you conference, exchange e-mail messages, chat on IRC, and more. Here are some of the products that are available:

Internet ExplorerInternet Explorer is the actual browser. Internet Explorer has support for all of the latest HTML tags, scripting, Netscape plug-ins, and much more.
NetMeetingNetMeeting, shown in Figure 1.3, is Microsoft's answer to online conferencing. This program lets you share programs and files; chat with audio or the keyboard; use a virtual white-board; and much more.
Internet Mail & NewsInternet Mail is a much simpler mail client than Exchange. It'll provide most of your needs. Internet News is a great newsreader that competes well with most of the newsreaders on the market.
Comic ChatComic Chat is a unique IRC client. Instead of seeing line after line of text, you see a comic strip with characters that represent each person in the chat room as seen in Figure 1.4.

Figure 1.3 : Microsoft Netmeeting enables a productive conference with associates all over the world.

Figure 1.4 : Comic Chat uses a comic strip metaphor to make IRC a bit more interesting than it already is (wink).


ActiveX Technologies

ActiveX contains a number of technologies for both programmers and content devel-opers (Web authors). Programmers can take advantage of the technology, such as the CryptoAPI to add encryption capabilities to their Internet programs. Content developers can take advantage of ActiveX scripting to build dynamic Web pages. The following sections give you a brief look at the types of technologies that ActiveX encompasses.

ActiveX Controls  ActiveX controls, which you have learned about in this chapter, let content developers build and distribute dynamic applications on the Web page. The controls themselves are part of this technology. The tools that Microsoft provides for programmers to build ActiveX controls are also a part of it.

ActiveX Documents  ActiveX documents allow a user to view documents other than HTML files over the Internet. For example, a user can view a Word document or Excel spreadsheet over the Internet. Microsoft provides technology to programmers so that they can make their application's documents distributable in this manner. Figure 1.5 shows you an example of a Word document in the Web browser.

Figure 1.5 : You can use all of Microsoft Word's features when you're editing a document within Internet Explorer 3.0.

ActiveX Scripting  ActiveX Scripting includes Microsoft's VBScript and JScript (Microsoft's version of JavaScript). These scripting languages allow a Web developer to glue together the controls and forms on a Web page so that each individual object becomes a bit player in a bigger solution.

Microsoft also provides technology under this umbrella that allows programmers to build ActiveX Scripting into their own applications or to add new scripting languages to the browser. Watch out-you may see a FortranScript one day.

Java Virtual Machine  The Java Virtual Machine (JVM) allows an ActiveX-enabled browser to run Java applications over the Internet. Microsoft also provides a tool called Visual J++, shown in Figure 1.6, that programmers and content developers can use to build Java applets.

Figure 1.6 : Visual J++ uses the Visual Developer Studio similar to Microsoft's other Visual developer products.

ActiveX Server Framework  The ActiveX Server Framework provides technology for security, cryptography, and database access on the server. Also, the server is extensible through ISAPI (Information Server Application Programmer Interface).

Using ActiveX Controls

This chapter presented you with a lot of background information about ActiveX controls. The following chapter, "Inserting ActiveX Controls on the Web Page," shows you how to put these controls in your Web page. Once you are familiar with how to put a control on your Web page, you can browse Parts II and III of this book to learn about some of the controls available for your use. And don't forget all the controls included on this book's CD-ROM.