Microsoft ActiveX Controls Overview Nancy Cluts Developer Technology Engineer Microsoft Corporation Updated: October 23, 1998 What Is an "ActiveX Control"? Microsoft® 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.0 or higher 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 Micros oft 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.0 or higher) comes with a set of ActiveX controls that it uses. With some of these controls, you can: Simplify and automate your authoring tasks (for ex ample, display "NEW!" images for new items on your site with a date specification; after that date, the images will automatically become invisible). Display data in ways other than text and tables (for example, charts or text displayed at different angles). Add functionality to your pages (for example, timers, animation, and background downloading). The ActiveX controls that are provided with Internet Explorer are installed automatically when the user installs Internet Explorer 3.0 or higher. 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 written by some third-party companies. These controls can be found on MSDN's third-party software page at http://msdnisv.microsoft.com/developer/thirdparty/default.asp. If you're a programmer, you can write your own controls using Visual C++® and one of the ActiveX control frameworks: the Microsoft Foundation C lass Library (MFC), the ActiveX Template Library (ATL), or the BaseC tl framework. How to Start Writing ActiveX Controls ActiveX controls are OLE controls that have been extended for the Internet environment. See the table of contents listing (click the Show TOC button above) to find all of the information you need to create ActiveX controls. 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 BaseC tl in the Workshop. 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. 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 (from the Workshop) that can help you through the process of learning about ActiveX controls: ActiveX Tutorial Samples A Web-based tutorial that covers the foundations of ActiveX technology with complete code samples. The tutorial consists of over 20 lessons and includes a download file that contains the complete set of code samples. Creating ActiveX Components in C++ This article walks you through the basic steps of creating a simple ActiveX control, and explains how you can embed this control in a Visual Basic application or use the control directly from Internet Explorer 3.0 or higher. The ABCs of MFC ActiveX Controls This technical article takes an in-depth, step-by-step look at building ActiveX controls, using the StopLite control as an example. Signing and Marking ActiveX Controls This article covers the whys and hows of signing ActiveX controls and marking them safe for initializing and safe for scripting.