object. And that object of course _does_not_ implement the
event interface - that's _your_ job. I suggest you read up
Kraig Brockschmidt, MS Press. Right now you seem to be
by the source object...
On Aug 21, 6:40 pm, "Alexander Nickolov" <agnicko...@mvps.org> wrote:
Why on earth would you want to expose your event sink as a
publicly creatable COM object? These are by definition
internal private objects of the client. And as you have discovered
already, the ATL helper class for event dispinterfaces enforces
that by constructing a completely separate COM object in the
base template instantiation of IDispEvent[Simple]Impl. What
you need to do is create your event sink C++ object internally.
A member of another class, created on the heap via new, or
in some extreme cases even created on the stack, are all viable
possibilities... Make sure you get its lifetime correct though!
In most cases you'd want it as a member of the class that wants
to receive the events as it will unsubscribe before it's destroyed.
Thanks for your reply. Sorry i did not make myself clear. I am doing
what you suggest. I have a sort of example for accessing COM events.
What I am after is probably very basic. When i call my internal event
sink from my main client class i use as u said,
m_RTDUpdateNotify = new CInstrNotifySink(this);
Now in the constructor for CInstrNotifySink() i create a com object
and query this object to get the pointer to the event interface so i
can use DispEventAdvise on it:
HRESULT hr = S_OK;
CComQIPtr<IDispatch, &__uuidof(IDispatch)> ptr;
hr = ptr.CoCreateInstance (L"Ecco.Prices"); //create instance of
My problem is how to get hold of this event interface pointer
(AppOld::IRTDUpdateEventPtr m_pInstrNotifyObj). I can't use the method
above because in my new server's components the event interface is not
associated with an OLE/COM object. Or not associated in a way that i
am used to. If I look in the OLE/COM Object viewer i can see all the
objects associated with the server i am trying to connect to. Then
when i look in the ITypeLib viewer I can see the IRTDUpdateEvent
interface. However, when i expand the objects that are there, this
interface is not part of any of these objects. Is there a sort of base
pointer I can do a QueryInterface on, that will give me
m_pInstrNotifyObj? I'm afraid it's the same old story with the
distributor's support - they only help with c# and visual basic:o(