The term ActiveX describes a set of services provided as part of the Windows
operating system. The services provided with ActiveX are based on a set of services provided
with the Component Object Model (COM), summarized as follows:
- Object Management
- Object Persistence
- Structured Storage
- Data Transfer
- Naming and Binding Services
COM provides Object Management a services by using reference counting. With
reference counting, COM enables developers to control when object references and their objects
are released from memory. In Visual Basic, the management of object references is provided
by the Visual Basic runtime engine. In addition COM provides Object Persistence services that
allow objects to be stored in a file. This is particularly important when you wish to extract
an applicationspecific object from a document file.
When objects are stored in files, they are stored using the Structured Storage
services provided in COM. With Structured Storage, you can store data in a hierarchical format
within a file very much as files are stored in directories and sub-directories. Structured
Storage allows applications to read and save items to files without restructuring the layout
of the file.
COM provides Data Transfer a services that enable you to transfer and share
data between applications. With Naming and Binding services (Monikers), applications can create,
store, and manage objects that provide complex operations such as asynchronous downloading
of files. These services are usually not directly accessed by the Visual Basic developer; however
you will use these services via the objects and functions that Visual Basic provides.
ActiveX is a Microsoft standard based on COM. In earlier versions of VB and
in other documentation before 1996, Microsoft referred to the object linking and embedding
(OLE) standard. The ActiveX standard has replaced the OLE standard. ActiveX enables the programmer
to visually link or embed objects in a program just as OLE 1.0 did.
ActiveX also gives the programmer all the possibilities provided by OLE 2.0 for
application automation, and ActiveX reaches beyond OLE to provide a general standard for
component development and manipulation under Windows and across the Internet. Some older
features of ActiveX, such as the OLE container control, actually still use the term OLE in
their names.
COM provides the core services upon which ActiveX technology is based. The
ActiveX technology provides the following services:
- Active Documents
- ActiveX Controls
- ActiveX Servers
- ActiveX Automation
ActiveX Documents enable developers to create applications that can host documents
in their native format inside other ActiveX Documents. Chapter 14, "Creating an Active
Document," provides more detail on ActiveX Documents.
Developers use ActiveX Controls to extend and enhance the services that an application
provides. If you need word processing capabilities in your application, for example, you can purchase
an ActiveX Control that provides the desired functionality. In addition, you can write your
own controls that encapsulate whatever functions you need. Chapter
13, "Creating ActiveX Controls," provides more detail on ActiveX Controls. ActiveX Servers are applications in the form
of EXE or DLL files that expose a COM-compliant object model for use by programmers creating
other applications. Chapter 12, "Creating a COM Component that Implements
Business Rules or Logic," discusses how to create ActiveX Servers.
As a programmer, one of the most exciting things you can do with existing COM
components is automation—the ability to declare an object within your application that
uses the functionality of a different application (a COM component). This chapter focuses on how
to use automation within your VB application to exploit the functionality of COM components.
A programmer might write a component specifically to be used in other applications
(an ActiveX library or ActiveX control), but many standalone component applications can also expose
objects.
Some examples of important standalone applications that also provide COM components
would be the current versions of Microsoft Internet Explorer, Microsoft Excel, Microsoft Access, and
Microsoft Word for Windows. In fact, every component of Microsoft's Office 97 Suite and later
Office Suites is supposed to be a COM component.
A COM component contains an object structure that is visible to client applications.
Objects belonging to the component but available outside the component are known as exposed objects.
In order for an object to be an exposed object, it must be listed in the Windows Registry.
Exposed objects have their own methods and properties that a COM client, such
as a VB application, can manipulate with standard object syntax.