Re: Default Implementation for IUnknown
No, your class does not implement IUnknown. CComObject<>
works by deriving from your class and providing implementation
for the 3 IUnknown methods thus populating the vtables of all
COM interfaces implemented by your class. The rest of your
speculations are meaningless in this new light.
Microsoft MVP [VC], MCSD
MVP VC FAQ: http://vcfaq.mvps.org
"Stefan Weber" <email@example.com> wrote in message
I second Igor's suggestion about IDispEvent[Simple]Impl.
As already mentioned in the answer to Igor's suggestion: Does this
also work in the situation when the event handler is registered with
the IHTMLElement2::attachEvent event method?
Just to answer your question, you need to wrap your object
in CComObject<> or one of its siblings to get an IUnkown
CComObject<DOMEventHandler>* pObj = NULL;
HRESULT hr = CComObject<DOMEventHandler>::CreateInstance(&pObj);
// Use it here
Hmm, I kind of have a hard time to understand this... the idea of this
class seems to wrap a object, such that it can be accessed like any
other COM object?
Now, I assume IUnknown is already implemented by DOMEventHandler. In
this case, do I need to create the instance with CreateInstance
method? I mean, as long as I do the reference counting properly, it
doesn't really matter if I access it via a COM interface pointer or
via the C++ vtbl, right? Or would this be bad practice?
By the way, I think this class has to be declared as aggregatable:
first, it is created within an other COM object and second, it is
registered as an event handler (i.e. aggregated somewhere in the DOM).
Is this correct?