| title | CComContainedObject Class | Microsoft Docs | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ms.custom | ||||||||||||||
| ms.date | 11/04/2016 | |||||||||||||
| ms.reviewer | ||||||||||||||
| ms.suite | ||||||||||||||
| ms.technology |
|
|||||||||||||
| ms.tgt_pltfrm | ||||||||||||||
| ms.topic | reference | |||||||||||||
| f1_keywords |
|
|||||||||||||
| dev_langs |
|
|||||||||||||
| helpviewer_keywords |
|
|||||||||||||
| ms.assetid | e8616b41-c200-47b8-bf2c-fb9f713ebdad | |||||||||||||
| caps.latest.revision | 20 | |||||||||||||
| author | mikeblome | |||||||||||||
| ms.author | mblome | |||||||||||||
| manager | ghogen | |||||||||||||
| translation.priority.ht |
|
This class implements IUnknown by delegating to the owner object's IUnknown.
Important
This class and its members cannot be used in applications that execute in the Windows Runtime.
template<class Base>
class CComContainedObject : public Base
Base
Your class, derived from CComObjectRoot or CComObjectRootEx.
| Name | Description |
|---|---|
| CComContainedObject::CComContainedObject | The constructor. Initializes the member pointer to the owner object's IUnknown. |
| CComContainedObject::~CComContainedObject | The destructor. |
| Name | Description |
|---|---|
| CComContainedObject::AddRef | Increments the reference count on the owner object. |
| CComContainedObject::GetControllingUnknown | Retrieves the owner object's IUnknown. |
| CComContainedObject::QueryInterface | Retrieves a pointer to the interface requested on the owner object. |
| CComContainedObject::Release | Decrements the reference count on the owner object. |
ATL uses CComContainedObject in classes CComAggObject, CComPolyObject, and CComCachedTearOffObject. CComContainedObject implements IUnknown by delegating to the owner object's IUnknown. (The owner is either the outer object of an aggregation, or the object for which a tear-off interface is being created.) CComContainedObject calls CComObjectRootEx's OuterQueryInterface, OuterAddRef, and OuterRelease, all inherited through Base.
Base
CComContainedObject
Header: atlcom.h
Increments the reference count on the owner object.
STDMETHOD_(ULONG, AddRef)();
A value that may be useful for diagnostics or testing.
The constructor.
CComContainedObject(void* pv);
pv
[in] The owner object's IUnknown.
Sets the m_pOuterUnknown member pointer (inherited through the Base class) to pv.
The destructor.
~CComContainedObject();
Frees all allocated resources.
Returns the m_pOuterUnknown member pointer (inherited through the Base class) that holds the owner object's IUnknown.
IUnknown* GetControllingUnknown();
The owner object's IUnknown.
This method may be virtual if Base has declared the DECLARE_GET_CONTROLLING_UNKNOWN macro.
Retrieves a pointer to the interface requested on the owner object.
STDMETHOD(QueryInterface)(REFIID iid, void** ppvObject);
template <class Q>
HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp);
iid
[in] The identifier of the interface being requested.
ppvObject
[out] A pointer to the interface pointer identified by iid. If the object does not support this interface, ppvObject is set to NULL.
pp
[out] A pointer to the interface pointer identified by type Q. If the object does not support this interface, pp is set to NULL.
A standard HRESULT value.
Decrements the reference count on the owner object.
STDMETHOD_(ULONG, Release)();
In debug builds, Release returns a value that may be useful for diagnostics or testing. In non-debug builds, Release always returns 0.