I've added a callback to an IHTMLElement instance but when the IDispatch::Invoke is called for the event, there are never any arguments (i.e. the pDispParams->cArgs and pDispParams->cNamedArgs are always 0). For example, I add a callback for an onmouseup event. From what I can tell, a callback for this event is supposed to receive a MouseEvent object. Is that correct? If so, what do I need to do to ensure this happens?
This is using the MSHTML for IE 6 sp2 (or better) on Windows XP SP2.
Events arguments for all DOM events including
onmouseup
are stored in the parent window'sevent
property (IHTMLWindow2::event
)If you don't already have the parent window cached,
IHTMLElement
has adocument
property which returns anIHTMLDocument
interface. From that you can query forIHTMLDocument2
which has aparentWindow
property. TheIHTMLWindow2
that is returned has theevent
property you're looking for. You should be able to query for the event interface from there.