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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Implement events with COleDispatchDriver class ?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How to implement events with COleDispatchDriver class auto-created by Class Wizard ?

I wrote my server class in AT, it also supports some simple events. I used Class Wizard to import the server class into my client program. The wizard created two COleDispatchDriver class that represent my server class and my server's events class. In the events class appear some events' methods of the server. But how can I implement these events for handling my server ?

BTW, Do you know there is any "quick" (not programmatical) example for building client/server application in VC and ATL ?
 
I mean how to HANDLE events in COleDispatchDriver, hope for a simple solution just like "WithEvents" in VB...
 
The answer is...

COleDispatchDriver cannot handle events,
if you wish to use MFC to do this, then use CCmdTarget. But I think it's an old mechanism from OLE era. In COM/COM+ era, we should use ATL instead, so add following template class to your client class:

IDispEventImpl<...> (see MSDN for usage)

BEGIN_SINK_MAP
...
END_SINK_MAP

I'm sure it will work!
 
Thank you for your answer!

By the moment I simply write separate class, based on IDispatch and analyze parameters in my Invoke function.
This approach works (I found some examples with such approach).

But I'll study your method...

With best regards,
Zaki Maksyutov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top