IHTMLEventObj::put_keyCode 在 IE9 RC 中失败

发布于 2024-10-19 11:41:37 字数 2414 浏览 2 评论 0原文

我有一个 3 年前创建的 IE BHO,它使用 IHTMLEventObj::put_keyCode 函数。此功能已在 IE6、IE7 和 IE8 中按照文档工作。然而,当使用 IE9 RC 进行测试时,它不再按照文档的方式工作。以同样的方式调用该函数,结果为 S_OK,但该键未显示在输入字段中。即使是我的 Invoke() 函数,也在 DISPID_HTMLELMENTEVENTS2_ONKEYPRESS 中进行调用。

我发现有人有类似的问题: http ://social.msdn.microsoft.com/Forums/is/ieextensiondevelopment/thread/abcbaffd-ed8a-45b8-840b-8ad8d7d10081,但是由于某种原因我无法查看该问题。我可以使用谷歌缓存查看它: http:// /webcache.googleusercontent.com/search?q=cache:3OkEceoi6jwJ:social.msdn.microsoft.com/Forums/is/ieextensiondevelopment/thread/abcbaffd-ed8a-45b8-840b-8ad8d7d10081+put_keyCode+IE9&cd=1&hl =pt-BR&ct=clnk&gl=br&source=www.google.com.br

任何帮助将不胜感激,这是一个需要尽快解决的关键问题。

提前致谢。

更新: 这是一些代码,但想强调的是,该代码在 IE6、IE7 和 IE8 中完美运行。在IE9中,它返回S_OK,但键没有改变。

BOOL CToolBandObj::InvokeElementOnKeyPress (    DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
                                            DISPPARAMS* pDispParams, VARIANT* pvarResult,
                                            EXCEPINFO*  pExcepInfo,  UINT* puArgErr)
{

    CComPtr<IDispatch> spEventObj;
    spEventObj = pDispParams->rgvarg[0].pdispVal;
    CComPtr<IHTMLEventObj> pHtmlEvent; 
    HRESULT hr = spEventObj->QueryInterface(IID_IHTMLEventObj,(LPVOID*)&pHtmlEvent);

    if (SUCCEEDED(hr) && pHtmlEvent)
    {
        CComPtr<IHTMLElement>spElement;
        hr = pHtmlEvent->get_srcElement(&spElement);

        _bstr_t bstrTag;
        spElement->get_tagName(&bstrTag.GetBSTR());

        if (SUCCEEDED(hr) && spElement)
        {
            LONG lKeyCode = 0;
            pHtmlEvent->get_keyCode(&lKeyCode);


            pHtmlEvent->put_keyCode(lKeyCode);
            pvarResult->vt = VT_BOOL;
            pvarResult->boolVal = VARIANT_TRUE;
            return TRUE;
        }
    }
}

更新 2

我们已提交 MSDN 案例,他们已经发现了该问题,最后我们收到他们的消息,他们将解决该问题。

I have an IE BHO created over 3 years ago that uses IHTMLEventObj::put_keyCode function. This function has worked as documented in IE6, IE7 and IE8. However, when testing with IE9 RC it no longer works as documented. The function is called the same way and the result is S_OK, but the key does not show up in the input field. The call is being made in the DISPID_HTMLELEMENTEVENTS2_ONKEYPRESS even of my Invoke() function.

I found someone with a similar problem: http://social.msdn.microsoft.com/Forums/is/ieextensiondevelopment/thread/abcbaffd-ed8a-45b8-840b-8ad8d7d10081, however for some reason I am not able to view the issue. I was able to view it using google cache: http://webcache.googleusercontent.com/search?q=cache:3OkEceoi6jwJ:social.msdn.microsoft.com/Forums/is/ieextensiondevelopment/thread/abcbaffd-ed8a-45b8-840b-8ad8d7d10081+put_keyCode+IE9&cd=1&hl=pt-BR&ct=clnk&gl=br&source=www.google.com.br.

Any help would be greatly appreciated this is a critical issue that needs to be addressed asap.

Thanks in advance.

UPDATE:
Here is some code, but wanted to stress, that this code works perfectly in IE6, IE7 and IE8. In IE9, it returns S_OK, but the key is not changed.

BOOL CToolBandObj::InvokeElementOnKeyPress (    DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags,
                                            DISPPARAMS* pDispParams, VARIANT* pvarResult,
                                            EXCEPINFO*  pExcepInfo,  UINT* puArgErr)
{

    CComPtr<IDispatch> spEventObj;
    spEventObj = pDispParams->rgvarg[0].pdispVal;
    CComPtr<IHTMLEventObj> pHtmlEvent; 
    HRESULT hr = spEventObj->QueryInterface(IID_IHTMLEventObj,(LPVOID*)&pHtmlEvent);

    if (SUCCEEDED(hr) && pHtmlEvent)
    {
        CComPtr<IHTMLElement>spElement;
        hr = pHtmlEvent->get_srcElement(&spElement);

        _bstr_t bstrTag;
        spElement->get_tagName(&bstrTag.GetBSTR());

        if (SUCCEEDED(hr) && spElement)
        {
            LONG lKeyCode = 0;
            pHtmlEvent->get_keyCode(&lKeyCode);


            pHtmlEvent->put_keyCode(lKeyCode);
            pvarResult->vt = VT_BOOL;
            pvarResult->boolVal = VARIANT_TRUE;
            return TRUE;
        }
    }
}

UPDATE 2

We have filed a MSDN Case, they have found the issue, and last we heard from them were going to fix it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唔猫 2024-10-26 11:41:37

终于在开案几周后,发布了修复程序: IHTMLEventObj::put_keyCode 函数在 Internet 中不起作用Explorer 9 标准模式

谢谢微软!

Finally after opening a case and many weeks, a fix was released: The IHTMLEventObj::put_keyCode function does not work in Internet Explorer 9 Standards mode.

Thank you Microsoft!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文