v
- VARIANT of type VT_DISPATCH that specifies the IDispatch interface of an object with a default method that is invoked when the event occurs.
Event handlers in this context are COM instances that implement IDispatch
- so you need to pass a pointer to an IDispatch
that your event handler object implements:
CComQIPtr<IDispatch> spDisp(spMyHandler); // something like that
someElement->put_onmousedown(CComVariant(spDisp));
Note: put_
instead of get_
- you want to register a handler.
On this, IDispatch::Invoke()
gets called with:
wFlags
containing DISPATCH_METHOD
("a method is getting invoked")
dispIdMember
being 0
/ DISPID_VALUE
("the default method")
Put together this should become something like:
HRESULT MyHandler::Invoke(DISPID dispIdMember, REFIID, LCID, WORD wFlags,
DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*)
{
// ...
if((wFlags & DISPATCH_METHOD) && (dispIdMember == DISPID_VALUE))
{
// ...
}
}