The information in this article applies to:
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.
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.
RESOLUTIONHere 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:
If you have a child control within your ActiveX control, you need to
UI-Activate the whole control whenever that child control is activated. For
example, if you have an edit control inside your ActiveX control, add a
handler as follows:
Because Internet Explorer may not immediately UI-Activate a control, even
if that is the only control on the page, it may be desirable to
automatically request a UI-Activation when the control is created. This can
be done during the COleControl::OnCreate (WM_CREATE) handler. Windowless
controls do not get WM_CREATE or any windows messages; therefore, this code
won't work in a windowless control. Also note that this does not guarantee
that a control will remain UI-Activated. If there are other controls on a
page that request UI-Activation in a similar manner, only one will
eventually be UI-Activated and receive keystroke messages as described. And
if the user TABs away from an ActiveX Control, Internet Explorer will
automatically UI-deactivate the control.
STATUSThis behavior is by design. MORE INFORMATIONCalling OnActiveInPlace() in WM_CREATE causes an assert when the control is hosted in Test Container. The assert is bogus and can be ignored.
Keywords : kbcode kbole kbMFC kbVC400 kbVC410 kbVC420 kbVC500 AXSDKControls |
Last Reviewed: July 27, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |