Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Handling COM events

Status
Not open for further replies.

SebastianStricker

Programmer
Aug 28, 2003
10
0
0
DE
I have a question to the COM/ATL experts: how can I handle events fired by an application I created via a smart pointer ("CreateInstance")?

I know that in the namespace of the imported DLL from the program (which I created with "CreateInstance") there is an abstract base class for event handling (lets say "_IEvent").

I tried to create my own event handling class derived from IDispatchImpl<_IEvent,...> and CComObjectRoot. Then I overrided the event-handling functions existing in the abstract _IEvent class in my new event handling class. Furthermore I created a COM_MAP with two entries for &quot;IDispatch&quot; and &quot;_IEvent&quot; in the header.

Then I call AtlAdvise with the both IUnknown pointers to the object and my class. As IID I used the GUID of the abstract _IEvent class (don't know if this is right??)

There seems to be a valid connection, but nothing happens if the created instance fires COM events? I think it is possible that there is no connection between the messages and the functions.

Any ideas?

THX Sebastian
 
you should use at least IAdviseSink.
CComPtr<IOleObject> xxx;
yourObject->QueryInterface(&xxx);
IAdviseSink* yy = new ...;
DWORD connection;
xxx->advise(yy, &connection);
......
...
xxx->Unadvise(&connection);//after finished working


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top