This documentation is archived and is not being maintained.

CComCompositeControl Class

This class provides the methods required to implement a composite control.

Important note Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

template < 
class T  
class CComCompositeControl : 
public CComControl< T, CAxDialogImpl< T > >


Your class, derived from CComObjectRoot or CComObjectRootEx, as well as from any other interfaces you want to support for your composite control.




Call this method to advise or unadvise all controls hosted by the composite control.


Call this method to calculate the size in HIMETRIC units of the dialog resource used to host the composite control.


This method is called to create the control window for the composite control.


Call this method to create the control window and advise any hosted control.


Call this method to set the background color of the composite control using the container's background color.




The background brush.


The handle of the window that currently has focus.

Classes derived from class CComCompositeControl inherit the functionality of an ActiveX composite control. ActiveX controls derived from CComCompositeControl are hosted by a standard dialog box. These types of controls are called composite controls because they are able to host other controls (native Windows controls and ActiveX controls).

CComCompositeControl identifies the dialog resource to use in creating the composite control by looking for an enumerated data member in the child class. The member IDD of this child class is set to the resource ID of the dialog resource that will be used as the control's window. The following is an example of the data member that the class derived from CComCompositeControl should contain to identify the dialog resource to be used for the control's window:

Note Note

Composite controls are always windowed controls, although they can contain windowless controls.

A control implemented by a CComCompositeControl-derived class has default tabbing behavior built in. When the control receives focus by being tabbed to in a containing application, successively pressing the TAB key will cause the focus to be cycled through all of the composite control's contained controls, then out of the composite control and on to the next item in the tab order of the container. The tab order of the hosted controls is determined by the dialog resource and determines the order in which tabbing will occur.

Note Note

In order for accelerators to work properly with a CComCompositeControl, it is necessary to load an accelerator table as the control is created, pass the handle and number of accelerators back into IOleControlImpl::GetControlInfo, and finally destroy the table when the control is released.

// Example for overriding IOleControlImpl::GetControlInfo()
// This example uses the accelerator table from the project resources
// with the identifier IDR_ACCELTABLE
// Define GetControlInfo() in the header of your composite 
// control class as follows:

    // Load the accelerator table from the resource
    pCI->hAccel = LoadAccelerators(_AtlBaseModule.GetResourceInstance(), 

    if (pCI->hAccel == NULL)
        return E_FAIL;

    // Get the number of accelerators in the table
    pCI->cAccel = (USHORT)CopyAcceleratorTable(pCI->hAccel, NULL, 0);
    // The following is optional if you want your control
    // to process the return and/or escape keys
    pCI->dwFlags = 0;

    return S_OK;

Header: atlctl.h