I have an IConnectionPointContainer
and know the connection point whose events I want to sink. Now I need to write a class containing callback methods for these events.
So basically I am doing this:
OleCheck((ExtIntf as IConnectionPointContainer).FindConnectionPoint(IID_IEvents, cp));
OleCheck(cp.Advise(MySink {<--this one I need}, Cookie));
I need to provide MySink
and I know how to do it so that MyIntf.Invoke
gets called. But I don't want to map dispids to event methods by hand.
That means I don't want to do this in my Invoke
:
// Handle the event
case DispID of
102 : OnStatusTextChange(pdpParams^.rgvarg^[lpDispIds[0]].bstrval);
104 : OnDownloadComplete;
105 : OnCommandStateChange(pdpParams^.rgvarg^[lpDispIds[0]].lval,
pdpParams^.rgvarg^[lpDispIds[1]].vbool);
106 : OnDownloadBegin;
108 : OnProgressChange(pdpParams^.rgvarg^[lpDispIds[0]].lval,
pdpParams^.rgvarg^[lpDispIds[1]].lval);
112 : OnPropertyChange(pdpParams^.rgvarg^[lpDispIds[0]].bstrval);
{... doh}
For the connection point IID_IEvents
I have both the interface IEvents
and the dispinterface declaration (from Delphi type library import). Can't I just implement IEvents
somehow? I want a clean class containing methods each one being a callback for one of the events offered by the IID_IEvents
connection point.
I have great hope that somebody knows maybe
- a base class I 开发者_C百科can inherit from that takes the job of calling my event methods
- a Delphi wizard that creates the proper class for me
- the tree I need to make my magic wand of to eventually master COM
Any tips?
TechVanguards has a tool that generates the code for you: COM Sink Event Generator.
You can also see my question; where i moaned about having to write what you're faced with writing.
精彩评论