Export (0) Print
Expand All

TranslateAccelerator (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This function processes accelerator keys for menu commands. TranslateAccelerator translates a WM_KEYDOWN or WM_SYSKEYDOWN message to a WM_COMMAND message and then sends the WM_COMMAND message directly to the appropriate window procedure. TranslateAccelerator does not return until the window procedure has processed the message.

int TranslateAccelerator(
  HWND hWnd, 
  HACCEL hAccTable, 
  LPMSG lpMsg 
); 

Parameters

hWnd
Handle to the window whose messages are to be translated.
hAccTable
Handle to an accelerator table. The accelerator table must have been loaded by a call to the LoadAccelerators function or created by a call to the CreateAcceleratorTable function.
lpMsg
Long pointer to an MSG structure that contains message information retrieved from the calling thread's message queue by using the GetMessage or PeekMessage function.

Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

Remarks

All accelerator key messages are translated into WM_COMMAND messages; Windows CE does not support the WM_SYSCOMMAND message.

To differentiate the message that this function sends from messages sent by menus or controls, the high-order word of the wParam parameter of the WM_COMMAND or WM_SYSCOMMAND message contains the value 1.

Accelerator key combinations used to select items from the window menu are translated into WM_SYSCOMMAND messages; all other accelerator key combinations are translated into WM_COMMAND messages.

When TranslateAccelerator returns a nonzero value and the message is translated, the application should not use the TranslateMessage function to process the message again.

An accelerator need not correspond to a menu command.

If the accelerator command corresponds to a menu item, the application is sent a WM_INITMENUPOPUP message, as if the user were trying to display the menu. However, these messages are not sent if any of the following conditions exist:

  • The window is disabled.
  • The menu item is disabled.
  • The accelerator key combination does not correspond to an item on the window menu and the window is minimized.
  • A mouse capture is in effect. For information about mouse capture, see the SetCapture function.

If the specified window is the active window and no window has the keyboard focus (which is generally the case if the window is minimized), TranslateAccelerator translates WM_SYSKEYUP and WM_SYSKEYDOWN messages instead of WM_KEYUP and WM_KEYDOWN messages.

If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, TranslateAccelerator does not send a WM_COMMAND message. However, if an accelerator keystroke occurs that does not match any of the items in the window's menu or in the window menu, the function sends a WM_COMMAND message, even if the window is minimized.

Requirements

OS Versions: Windows CE 1.0 and later.
Header: Winuser.h.
Link Library: Accel.lib.

See Also

CreateAcceleratorTable | GetMessage | LoadAccelerators | MSG | PeekMessage | SetCapture | TranslateMessage | WM_COMMAND | WM_INITMENUPOPUP | WM_KEYDOWN | WM_SYSKEYDOWN | Keyboard Functions


Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft