Article ID: 168777 - Last Review: November 21, 2006 - Revision: 3.2 PRB: MFC ActiveX Control in IE Doesn't Detect KeystrokesThis article was previously published under Q168777 SYMPTOMS
Accelerator keys, such as ARROW keys, are first received by the message
pump of the ActiveX control's container. Even if the control has the focus,
it does not receive messages for keystrokes that have special meaning to
control containers, such as ARROW and TAB keys. MFC ActiveX controls have a
chance to intercept these messages by overriding their PreTranslateMessage
function.
However, PreTranslateMessage is not always called for an MFC ActiveX control. CAUSE
PreTranslateMessage in an MFC ActiveX control is called by the
TranslateAccelerator method of the IOleInPlaceActiveObject interface of the
control. Internet Explorer only calls this method for the control that is
currently UI-Active. Only one control can be UI-Active at a time.
Internet Explorer does not automatically UI-Activate any controls when a page is first loaded. Internet Explorer waits until the user tabs to an ActiveX control on the page to UI-Activate it. Also, MFC ActiveX controls UI-Activate themselves when they are clicked with the mouse. In an MFC ActiveX control, this is done in COleControl::OnLButtonUp. If you have a child control inside your COleControl, mouse-click messages on the child control are not sent to the COleControl and MFC does not UI- Activate the ActiveX control, even though the child control has just been given the keyboard focus. Internet Explorer intercepts the keystrokes and does not give the control a chance to filter them in PreTranslateMessage. RESOLUTION
Here is a typical PreTranslateMessage. This code forwards ARROW, HOME, and
END keys back to the control so that they can be received using a
MESSAGE_MAP entry:
STATUS
This behavior is by design.
MORE INFORMATION
Calling OnActiveInPlace() in WM_CREATE causes an assert when the control is
hosted in Test Container. The assert is bogus and can be ignored.
APPLIES TO
| Article Translations
|

Back to the top
