description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CComCompositeControl Class |
CComCompositeControl Class |
11/04/2016 |
|
|
1304b931-27e8-4fbc-be8e-bb226ad887fb |
This class provides the methods required to implement a composite control.
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>>
T
Your class, derived from CComObjectRoot or CComObjectRootEx, as well as from any other interfaces you want to support for your composite control.
Name | Description |
---|---|
CComCompositeControl::CComCompositeControl | The constructor. |
CComCompositeControl::~CComCompositeControl | The destructor. |
Name | Description |
---|---|
CComCompositeControl::AdviseSinkMap | Call this method to advise or unadvise all controls hosted by the composite control. |
CComCompositeControl::CalcExtent | Call this method to calculate the size in HIMETRIC units of the dialog resource used to host the composite control. |
CComCompositeControl::Create | This method is called to create the control window for the composite control. |
CComCompositeControl::CreateControlWindow | Call this method to create the control window and advise any hosted control. |
CComCompositeControl::SetBackgroundColorFromAmbient | Call this method to set the background color of the composite control using the container's background color. |
Name | Description |
---|---|
CComCompositeControl::m_hbrBackground | The background brush. |
CComCompositeControl::m_hWndFocus | 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:
[!code-cppNVC_ATL_COM#13]
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
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.
[!code-cppNVC_ATL_COM#14]
WinBase
CComCompositeControl
Header: atlctl.h
Call this method to advise or unadvise all controls hosted by the composite control.
HRESULT AdviseSinkMap(bool bAdvise);
bAdvise
True if all controls are to be advised; otherwise false.
Value | Description |
---|---|
S_OK |
All controls in the event sink map were connected or disconnected from their event source successfully. |
E_FAIL |
Not all controls in the event sink map could be connected or disconnected from their event source successfully. |
E_POINTER |
This error usually indicates a problem with an entry in the control's event sink map or a problem with a template argument used in an IDispEventImpl or IDispEventSimpleImpl base class. |
CONNECT_E_ADVISELIMIT |
The connection point has already reached its limit of connections and cannot accept any more. |
CONNECT_E_CANNOTCONNECT |
The sink does not support the interface required by this connection point. |
CONNECT_E_NOCONNECTION |
The cookie value does not represent a valid connection. This error usually indicates a problem with an entry in the control's event sink map or a problem with a template argument used in an IDispEventImpl or IDispEventSimpleImpl base class. |
The base implementation of this method searches through the entries in the event sink map. It then advises or unadvises the connection points to the COM objects described by the event sink map's sink entries. This member method also relies on the fact that the derived class inherits from one instance of IDispEventImpl
for every control in the sink map that is to be advised or unadvised.
Call this method to calculate the size in HIMETRIC units of the dialog resource used to host the composite control.
BOOL CalcExtent(SIZE& size);
size
A reference to a SIZE
structure to be filled by this method.
TRUE if the control is hosted by a dialog box; otherwise FALSE.
The size is returned in the size parameter.
This method is called to create the control window for the composite control.
HWND Create(
HWND hWndParent,
RECT& /* rcPos */,
LPARAM dwInitParam = NULL);
hWndParent
A handle to the parent window of the control.
rcPos
Reserved.
dwInitParam
Data to be passed to the control during control creation. The data passed as dwInitParam will show up as the LPARAM parameter of the WM_INITDIALOG message, which will be sent to the composite control when it gets created.
A handle to the newly created composite control dialog box.
This method is usually called during in-place activation of the control.
The constructor.
CComCompositeControl();
Initializes the CComCompositeControl::m_hbrBackground and CComCompositeControl::m_hWndFocus data members to NULL.
The destructor.
~CComCompositeControl();
Deletes the background object, if it exists.
Call this method to create the control window and advise any hosted controls.
virtual HWND CreateControlWindow(
HWND hWndParent,
RECT& rcPos);
hWndParent
A handle to the parent window of the control.
rcPos
The position rectangle of the composite control in client coordinates relative to hWndParent.
Returns a handle to the newly created composite control dialog box.
This method calls CComCompositeControl::Create and CComCompositeControl::AdviseSinkMap.
The background brush.
HBRUSH m_hbrBackground;
The handle of the window that currently has focus.
HWND m_hWndFocus;
Call this method to set the background color of the composite control using the container's background color.
HRESULT SetBackgroundColorFromAmbient();
Returns S_OK on success, or an error HRESULT on failure.
CComControl Class
Composite Control Fundamentals
Class Overview