Not getting event arguments in IHTMLElement event handler

孤者浪人 提交于 2019-12-07 10:57:09

问题


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.


回答1:


Events arguments for all DOM events including onmouseup are stored in the parent window's event property (IHTMLWindow2::event)

If you don't already have the parent window cached, IHTMLElement has a document property which returns an IHTMLDocument interface. From that you can query for IHTMLDocument2 which has a parentWindow property. The IHTMLWindow2 that is returned has the event property you're looking for. You should be able to query for the event interface from there.



来源:https://stackoverflow.com/questions/110015/not-getting-event-arguments-in-ihtmlelement-event-handler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!