Skip to content

Latest commit

 

History

History
148 lines (112 loc) · 8.26 KB

nf-winuser-translateacceleratorw.md

File metadata and controls

148 lines (112 loc) · 8.26 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winuser.TranslateAcceleratorW
TranslateAcceleratorW function (winuser.h)
Processes accelerator keys for menu commands. (Unicode)
TranslateAccelerator
TranslateAccelerator function [Menus and Other Resources]
TranslateAcceleratorW
_win32_TranslateAccelerator
_win32_translateaccelerator_cpp
menurc.translateaccelerator
winui._win32_translateaccelerator
winuser/TranslateAccelerator
winuser/TranslateAcceleratorW
menurc\translateaccelerator.htm
menurc
VS|winui|~\winui\windowsuserinterface\userinput\keyboardaccelerators\keyboardacceleratorreference\keyboardacceleratorfunctions\translateaccelerator.htm
12/05/2018
TranslateAccelerator, TranslateAccelerator function [Menus and Other Resources], TranslateAcceleratorA, TranslateAcceleratorW, _win32_TranslateAccelerator, _win32_translateaccelerator_cpp, menurc.translateaccelerator, winui._win32_translateaccelerator, winuser/TranslateAccelerator, winuser/TranslateAcceleratorA, winuser/TranslateAcceleratorW
winuser.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
TranslateAcceleratorW (Unicode) and TranslateAcceleratorA (ANSI)
User32.lib
User32.dll
Windows
19H1
TranslateAcceleratorW
winuser/TranslateAcceleratorW
c++
APIRef
kbSyntax
DllExport
User32.dll
Ext-MS-Win-NTUser-Keyboard-l1-1-0.dll
Ext-MS-Win-NTUser-Keyboard-l1-1-1.dll
api-ms-win-ntuser-ie-keyboard-l1-1-0.dll
ie_stubs.dll
ext-ms-win-ntuser-keyboard-l1-1-2.dll
Ext-MS-Win-NTUser-Keyboard-L1-2-0.dll
Ext-MS-Win-NTUser-Keyboard-L1-2-1.dll
Ext-MS-Win-NTUser-Keyboard-L1-3-0.dll
TranslateAccelerator
TranslateAcceleratorA
TranslateAcceleratorW

TranslateAcceleratorW function

-description

Processes accelerator keys for menu commands. The function translates a WM_KEYDOWN or WM_SYSKEYDOWN message to a WM_COMMAND or WM_SYSCOMMAND message (if there is an entry for the key in the specified accelerator table) and then sends the WM_COMMAND or WM_SYSCOMMAND message directly to the specified window procedure. TranslateAccelerator does not return until the window procedure has processed the message.

-parameters

-param hWnd [in]

Type: HWND

A handle to the window whose messages are to be translated.

-param hAccTable [in]

Type: HACCEL

A handle to the 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.

-param lpMsg [in]

Type: LPMSG

A pointer to an MSG structure that contains message information retrieved from the calling thread's message queue using the GetMessage or PeekMessage function.

-returns

Type: int

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

-remarks

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 WM_INITMENU and WM_INITMENUPOPUP messages, 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 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.

Examples

For an example, see Creating Accelerators for Font Attributes.

Note

The winuser.h header defines TranslateAccelerator as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

-see-also