Re: Dynamic Event Handlers
See IConnectionPoint::Advise, Unadvise. Ask target for IConnectionPointContainer, find your event, and then Advise. Don't forget to Undavise.
Sincerely, Mihai
Re: Dynamic Event Handlers
Hi Mihai :
I was actually referring to runtime synthesis of a vtable so that I could create a sink implementation on the fly.
Let's say I discover (at runtime) that CLSID_XX has an event interface IID_ISomething & it is defined as follows :
interface ISomething : IDispatch
{
HRESULT OnSomething();
}
However, I've no way of having a pre-defined ISomething implementation. I could ofcourse have a generic IDispatch implementation. However, for the connection point to work, this implementation must succeed when IID_ISomething is queried for .
IConnectionPoint::Advise() queries for the interface it represents. But then I am breaking the contract that ISomething promised namely that of supporting OnSomething() as a valid vtable entry. Ofcourse, if the server never calls through the vtable and always uses IDispatch::Invoke() instead, everything is kosher.
I know VB does that. The question is how ?
Regards,
Amitava