PRB: MFC ActiveX Control Ignores ARROW Keys on VB ContainerLast reviewed: February 4, 1998Article ID: Q180402 |
The information in this article applies to:
SYMPTOMSAn MFC ActiveX Control that contains a subclassed Edit control does not respond to the ARROW keys. More specifically, when a Visual Basic form contains the MFC ActiveX Control and the control has focus, the ARROW keys are not recognized.
CAUSEThis behavior is the result of ARROW keys being accelerator keys. Accelerator keys are handled in the main message loop of the containing application before the window procedure of the control is called. As a result, the MFC ActiveX control is not aware that the ARROW keys have been pressed. Other accelerator keys include the TAB, END, and HOME keys.
RESOLUTIONThe problem can be resolved by adding the following code to your MFC ActiveX Control. This code forwards the Accelerator Key messages onto your MFC ActiveX Control:
// Trap keys and forward on to the control. BOOL CMyEditCtrl::PreTranslateMessage(MSG* pMsg) { switch (pMsg->message) { case WM_KEYDOWN: case WM_KEYUP: switch (pMsg->wParam) { case VK_UP: case VK_DOWN: case VK_LEFT: case VK_RIGHT: case VK_HOME: case VK_END: SendMessage (pMsg->message, pMsg->wParam, pMsg->lParam); // Windowless controls won't be able to call SendMessage. // Instead, just respond to the message here. return TRUE; } break; } return COleControl::PreTranslateMessage(pMsg); } STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
REFERENCESFor additional information, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q168777 TITLE : PRB: MFC ActiveX Control in IE Doesn't Detect Keystrokes Keywords : vb5all VBKBAX Version : WINDOWS:5.0,97; WINNT:5.0 Platform : WINDOWS winnt Issue type : kbprb |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |