ActiveX Controls Overview

Nancy Cluts
Developer Technology Engineer
Microsoft Corporation

Last updated: June 24, 1997

What is an "ActiveX control"?

ActiveX™ controls, formerly known as OLE controls or OCX controls, are components (or objects) you can insert into a Web page or other application to reuse packaged functionality someone else programmed. For example, the ActiveX controls that are included with Microsoft® Internet Explorer version 3.x allow you to enhance your Web pages with sophisticated formatting features and animation.

A key advantage of ActiveX controls over Java™ applets and Netscape plug-ins is that ActiveX controls can also be used in applications written in many programming languages, including all of the Microsoft programming and database languages.

There are literally hundreds of ActiveX controls 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.

You can add ActiveX controls to your Web pages by using the standard HTML <OBJECT> tag. The <OBJECT> tag includes a set of parameters that you use to specify which data the control should use and to control the appearance and behavior of the control.

Microsoft Internet Explorer version 3.x comes with a set of ActiveX controls that it uses. With some of these controls, you can:

The ActiveX controls that are provided with Internet Explorer 3.x are installed automatically when the user installs Internet Explorer 3.x. Once installed, ActiveX controls run automatically when a Web page containing them is displayed—users do not need to download any additional files.

If you're a Web author, you can take advantage of the ready-to-use ActiveX controls listed below. If you're a programmer, you can write your own controls using Visual C++® and one of the ActiveX control frameworks: the Microsoft Foundation Class Library (MFC), the ActiveX Template Library (ATL), or the BaseCtl framework.

Microsoft ActiveX controls

Along with Internet Explorer version 3.x, Microsoft has provided controls such as Chart, Label, Preloader, and Timer. You can easily add these controls to your Web pages with the <OBJECT> tag. See the Microsoft ActiveX Controls programming reference page at http://www.microsoft.com/workshop/prog/controls/ctrlref.htm for detailed descriptions and full syntax for these controls.

How to start writing ActiveX controls

ActiveX controls are OLE controls that have been extended for the Internet environment. The specs in the Microsoft ActiveX SDK (available in the MSDN Library) provide background information on ActiveX controls and some preliminary information on writing controls. If you are developing ActiveX controls for Internet Explorer 3.x, use the ActiveX SDK; if, however, you are developing ActiveX controls for Internet Explorer 4.0, you should use the Internet Client SDK (INet SDK). The INet SDK is backward-compatible with the ActiveX SDK, and contains information and tools for applications and controls targeted to Internet Explorer 4.0.

There are three basic ways to write ActiveX controls today:

If you are already a proficient C/C++ OLE developer, the easiest method is probably to use the OLE control development facilities built into Visual C++ and MFC. This technology allows you to create control executables that are pretty small (so they download faster); however, it requires the correct MFC dynamic-link library (DLL) to be installed on the user’s system. This DLL is quite large—nearly a megabyte. But even so, it needs to be installed only once on each user’s system and shouldn’t take more than 10 minutes or so to download, even at 14.4 Kbps. The good news is that this DLL most likely already resides on your computer (or your user’s computer) and will not need to be downloaded.

The Microsoft Internet Explorer developers included a sample called BaseCtl in the ActiveX SDK. This sample comprises the FrameWrk, ToDoSvr, and WebImage examples. Writing your controls in this style gives you the smallest possible controls; however, it also requires intimate knowledge of OLE Component Object Model (COM) and ActiveX control architecture—so it’s not for the faint-of-heart.

Finally, the Visual C++ team has created the ActiveX Template Library (ATL), which includes the library plus the Beeper and Labrador samples (go to http://www.microsoft.com/visualc/prodinfo/default.htm). This is a library of C++ templates that allows you to create very fast and small controls—in fact, you can even avoid linking in the C run-time library. The templates also do some of the grunge work of OLE for you, but they still require a pretty intimate knowledge of COM and ActiveX control architecture—so they’re for those who aren’t timid, but would like to have some of the tedious OLE work done for them.

Here are some good technical articles and samples that can help you through the process of learning about ActiveX controls:

Did you find this article useful? Gripes? Compliments? Suggestions for other articles? Drop me a line at nancycl@microsoft.com and let me know.