How Controls Are
Contained
To contain a COM control, a
container must do two things:
-
Provide a window to
act as the parent for the child COM control. The parent
window can be used by a single child COM control or can be shared
by many.
-
Implement a set of
COM interfaces that the control uses to communicate with the
container. The container must provide at least one object
per control, called the site, to implement these interfaces.
However, the interfaces can be spread between up to two other
container-provided objects, called the document and the frame.
The window that the container provides can be a
parent window of the control or, in the case of a windowless
control, can be shared by the control. The control uses the window
in its interaction with the user. The interfaces that the container
implements are used for integration with the control and mirror
those that the control implements. Figure 12.1 shows the major interfaces that the
container implements and how they are mirrored by those that the
control implements.
As mentioned in Chapter 11, "ActiveX Controls," full coverage
of the interaction between controls and containers is beyond the
scope of this book. Refer to the sources listed in Chapter 11 for more
information. However, this chapter presents those
things you need to know to host controls both in standalone
applications and inside COM servers. Your
hosting options include windows, dialogs, and composite controls.
Before diving into the details of dialogs or controls hosting other
controls, let's start with the basics by examining control
containment in a simple frame window.
|