Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make an ATL COM class derived from a base class?
    primarykey
    data
    text
    <p>The "ATL simple object" wizard doesn't provide a way to specify that a new class is derived from an existing coclass and its interface. In Visual Studio 2008, how do I make a new ATL COM class derived from an existing one (i.e. <code>Base</code> implements <code>IBase</code>, and I want to make a new <code>Derived</code> class derived from <code>Base</code> that implements <code>IDerived</code>, where <code>IDerived</code> is derived from <code>IBase</code>.)</p> <p>Update: it sounds simple, but a wizard-generated ATL class has up to six base classes, a COM map and a connection point map. Which of these base classes and maps should be repeated in the derived class? If maps are repeated in the derived class should they contain the contents of the base class map or just the additional items? Does the order of base classes matter? What about <code>FinalConstruct()</code> and <code>FinalRelease()</code>? Should <code>DECLARE_PROTECT_FINAL_CONSTRUCT</code> and <code>DECLARE_REGISTRY_RESOURCEID</code> be repeated in the derived class?</p> <p>Here's a sample base class that is empty except for all the boilerplate. Now what should the derived class look like?</p> <pre><code>class ATL_NO_VTABLE CBase : public CComObjectRootEx&lt;CComSingleThreadModel&gt;, public CComCoClass&lt;CBase, &amp;CLSID_Base&gt;, public ISupportErrorInfo, public IConnectionPointContainerImpl&lt;CBase&gt;, public CProxy_IBaseEvents&lt;CBase&gt;, public IDispatchImpl&lt;IBase, &amp;IID_IBase, &amp;LIBID_ExampleLib, /*wMajor =*/ 1, /*wMinor =*/ 0&gt; { public: CBase() { } DECLARE_REGISTRY_RESOURCEID(IDR_Base) BEGIN_COM_MAP(CBase) COM_INTERFACE_ENTRY(IBase) COM_INTERFACE_ENTRY(IDispatch) COM_INTERFACE_ENTRY(ISupportErrorInfo) COM_INTERFACE_ENTRY(IConnectionPointContainer) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(CBase) CONNECTION_POINT_ENTRY(__uuidof(_IBaseEvents)) END_CONNECTION_POINT_MAP() // ISupportsErrorInfo STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); DECLARE_PROTECT_FINAL_CONSTRUCT() HRESULT FinalConstruct() { return S_OK; } void FinalRelease() { } }; OBJECT_ENTRY_AUTO(__uuidof(Base), CBase) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload