How Controls Are Contained


To contain a COM control,[1] a container must do two things:

[1] This chapter doesn't distinguish between OLE controls and ActiveX controls.

  1. 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.

  2. 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.

Figure 12.1. Container and control interfaces


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.[2] 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.

[2] You might also want to refer to the MSDN article "Notes on Implementing an OLE Control Container" for control containerspecific information at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaxctrl/html/msdn_contcntr.asp (http://tinysells.com/60).




ATL Internals. Working with ATL 8
ATL Internals: Working with ATL 8 (2nd Edition)
ISBN: 0321159624
EAN: 2147483647
Year: 2004
Pages: 172

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net