How do I set up an Event handler in C++ for VB COM object???
Posted on 2002-04-03
I am using a VB com object which has an Event triggered...
I would like to use the see behavior in C++ as in VB but I do not know how to
set up the event handler in C++ for my COM object!
In VB I just do a dim WithEvents and I get to set up a event function...
But in C++ how do I do the equivalent???
Here is my code:
SparkyObject::_SparkyCOMPtr aPtr= NULL;
HRESULT hr= aPtr.CreateInstance(__uuidof(SparkyObject::SparkyCOM));
//SparkyObject::__SparkyCOMPtr aPtrCallback= NULL;
DATE d= (DATE)t;
In the .tlh file (from the #import statement) I see that I have this:
a _SparkyCOM ptr which I use and a __SparkyCOM which seems to be handling
the event... But how do I use it?
The __SparkyCOM object is defined thus in the .tlh file:
__SparkyCOM : IDispatch
// Wrapper methods for error-handling
HRESULT FileProcessing (
BSTR * strProcess,
BSTR * strProcessInfo,
VARIANT_BOOL * btnCancel );
The "FileProcessing" is the event I'd like to trap in C++.
How Do I set up my event handler (say a static function with the same prototype)
in my code so that my com object (aPtr) "knows" to use it???
Thanks for any informations.