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

Raising COM events from C++?

Status
Not open for further replies.

thesleepylizard

Programmer
Mar 18, 2002
41
AU
In VB6 it's really easy to write COM objects, and to raise events:



Code:
Public Event SomethingImportantOccured (Data as string)
.
.
.
RaiseEvent SomethingImportantOccured ("Bingo!")
.
.
.
Private Sub ImportantObject_SomethingImportantOccured(Data as string)
    '
End Sub

In C++, I want to do write a COM object in a COM library, and do exactly the same thing. But, I'm not sure how to declare, raise, and handle COM events in C++.

Any ideas? Or, can anyone point me in the right direction/documentation?

Thanks for your time,
-sleepy
 
Thos are called connection points and are actually a separate interface of the COM object.
Greetings,
Rick
 
LazyMe

I can create them easily enough and handle them from within VB...

where I get stuck is with trying to handle them in C++, can you offer any good resources to get me going?

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
It depends on how you're writing your COM server (raw C++, ATL, MFC). There is a really good book about writing COM servers in C++. It's called "Developer's Workshop to COM and ATL 3.0", by Andrew Troelsen. As the title suggests it's about writing them in ATL, but it starts out with a quite thorough explanation about how to do it in raw C++.
Greetings,
Rick
 
LazyMe
>I can create them easily enough and handle them from within VB...

should read

I can create them easily enough in C++ using ATL and handle them from within VB...

after reading the post it was spectatularily unclear what I meant...


I use ATL for writing C++ com objects...
I have the Wrox books by Grimes etc, but they don't go into sinking events!

I'll look up that book, Is there any web resource (kinda short on £££ now) Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
I don't know about any web resource, but you might want to search the web and the MSDN about "IDispEventImpl", which is a client template to sink the events and "IProvideClassInfo2Impl" which needs to be implemented on the server for that to work.
Greetings,
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top