ActiveX Controls Architecture
As noted above, ActiveX controls technology builds on a foundation of many
lower-level objects and interfaces in OLE. The exact interfaces available on a
control vary with its capabilities. This section takes a closer look at the
capabilities a control might provide.
Controls are used to provide the building blocks for creating user interfaces
in applications. For example, a button that initiates some action in the
container application when it is clicked is a simple control. The following
aspects are involved in providing these user interface building blocks:
-
A control can be embedded within its container client to support some user
interface activity within the client. Thus, a control needs to provide a
visual representation of itself when it is embedded within the container and
needs to provide a way to save its state, for example, its property values and
its position within its container. The client must support being a container
with objects embedded in it.
-
By activating the control using a keyboard or mouse, the end user initiates
some action in the client application. Thus, a control must respond to
keyboard activity and must be able to communicate with its client so it can
notify its container of its activities and trigger events in the client.
-
The client also typically provides a programming language through which the
end user can initiate actions provided by the control’s properties and
methods. Thus, a control must support automation and some set of design-time
versus run-time features as well.
As a result of its role in providing user interface building blocks, a control
typically supports features in the following areas using OLE technologies as
indicated:
-
Properties and methods
-
Like any OLE object, a control can provide much of its functionality through a
set of incoming interfaces with properties and methods. The container can
supply additional ambient properties, and it can support extending the control’s
properties through aggregation. These features rest on OLE automation,
property pages, connectable objects, and ActiveX control technologies.
-
Events
-
In addition to providing properties and methods, an ActiveX control can also
provide outgoing interfaces to notify its client of events. The client must
support handling of these events. These features use OLE automation and
connectable objects.
-
Visual representation
-
A control can support positioning and displaying itself within its container.
The container positions the control and determines its size. These features
use compound document technology, including OLE drag and drop technology.
-
Keyboard handling
-
A control can respond to keyboard accelerators so the end-user can initiate
actions performed by the control. The container manages keyboard activity for
all its embedded controls. These features use control and compound document
technologies.
-
Persistence
-
A control can save its state. The client manages the persistence of its
embedded controls. These features use structured storage and object
persistence technologies.
-
Registration and licensing
-
A control typically supports self-registration and creates a set of registry
entries when it is instantiated. A control can also be licensed to prevent
unauthorized use.
Most of these features involve both the control and its client container.
The following sections describe design considerations in each of these areas
and describe how the OLE technologies mentioned previously are used in
controls to support these areas of features.