在IHTMLElement事件处理程序中未获得事件参数 [英] Not getting event arguments in IHTMLElement event handler
问题描述
我添加了一个回调到IHTMLElement实例,但是当为事件调用IDispatch :: Invoke时,没有任何参数(即pDispParams-> cArgs和pDispParams-> cNamedArgs始终为0)。例如,我为onmouseup事件添加回调。从我可以告诉,这个事件的回调应该是接收一个MouseEvent对象。那是对的吗?如果是,我需要做什么来确保这种情况发生?
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?
这是在Windows XP SP2上使用IE 6 sp2(或更高版本)的MSHTML。
This is using the MSHTML for IE 6 sp2 (or better) on Windows XP SP2.
推荐答案
所有DOM事件(包括 onmouseup
)的事件参数存储在父窗口的事件
属性( IHTMLWindow2 :: event
)
Events arguments for all DOM events including onmouseup
are stored in the parent window's event
property (IHTMLWindow2::event
)
如果您尚未缓存父窗口, IHTMLElement
具有返回 IHTMLDocument
接口的文档
属性。从中可以查询具有 parentWindow
属性的 IHTMLDocument2
返回的 IHTMLWindow2
具有您正在查找的事件
属性。您应该可以从那里查询事件界面。
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.
这篇关于在IHTMLElement事件处理程序中未获得事件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!