IHTMLEventObj::put_keyCode fails in IE9 RC - by Insitefullyyours

Status : 

  Not Reproducible<br /><br />
		The product team could not reproduce this item with the description and steps provided.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

ID 648678 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/1/2011 2:40:18 PM
Duplicates 651437 Access Restriction Public



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);               if (( lKeyCode == 0x4C) || (lKeyCode == 0x6C))             {                 pHtmlEvent->put_keyCode(m_lastKeyCode);             }         }     } }
Sign in to post a comment.
Posted by Insitefullyyours on 11/7/2011 at 7:53 AM
This error was fixed in Microsoft Update MS11-081 ( http://support.microsoft.com/kb/2586448 ) October 2011
Posted by Insitefullyyours on 4/29/2011 at 3:27 PM
IE9 RC and IE9 RTM have this bug. Microsoft IE team has reproduced and ack'd that there was a regression problem between final Beta and RC where this issue was introduced. We do not have a resolution from Microsoft yet.
Posted by Microsoft on 4/28/2011 at 11:11 AM
Thank you for your feedback.

Internet Explorer 9 rtm was just released shortly after your feedback was filed. Please verify if the problem still exists, and send us additional comments so that we can investigate further if necessary.

Best regards,

The Internet Explorer Team