Microsoft KB Archive/132450

{|
 * width="100%"|

How to Send Any Arrow Key Related Messages to .OCX File
'Article ID: Q132450

Creation Date: 11-JUL-1995

Revision Date: 12-OCT-1995' The information in this article applies to:


 * Microsoft OLE Control Developer's Kit (CDK) for Windows and Windows NT, versions 1.0 and 1.1

SUMMARY

To send any arrow key related messages to your control, you must override the PreTranslateMessage for your .OCX file.

MORE INFORMATION

You need to override the PreTranslateMessage member function, forward key presses that you want to trap to the control, and return TRUE. You should call COleControl::PreTranslateMessage for all keys that you do not process, and return the value from COleControl::PreTranslateMessage.

The following code shows how to implement PreTranslateMessage in your XXXXXCTL.CPP file:

BOOL CXxxxCtrl::PreTranslateMessage(LPMSG lpMsg) {

switch (lpMsg->message) {  case WM_KEYDOWN: case WM_KEYUP: switch (lpMsg->wParam) {        case VK_UP: case VK_DOWN: case VK_LEFT: case VK_RIGHT: SendMessage(lpMsg->message,lpMsg->wParam,lpMsg->lParam); return TRUE; }     break; }

return COleControl::PreTranslateMessage(lpMsg); } You also need to include the following declaration in your control class declaration in XXXXCTL.H along with the other virual function declarations:

virtual BOOL PreTranslateMessage(LPMSG lpMsg);
 * }

-

"THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED 'AS IS' WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY." '' ©1997 Microsoft Corporation. All rights reserved. Legal Notices.

''

Additional reference words: 2.00 1.00 1.10

KBCategory: kbtool kbprg kbcode

KBSubcategory: CDKIss