BOOL TranslateMessage(lpMsg)
This function translates virtual-key messages into character messages, as follows:
WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or a WM_DEADCHAR message.
WM_SYSKEYDOWN/WM_SYSKEYUP combinations produce a WM_SYSCHAR or a WM_SYSDEADCHAR message.
The character messages are posted to the application queue, to be read the next time the application calls the GetMessage or PeekMessage function.
Parameter | Type/Description |
lpMsg | LPMSG Points to an MSG data structure retrieved through the GetMessage or PeekMessage function. The structure contains message information from the Windows application queue. |
The return value specifies the outcome of the function. It is nonzero if the message is translated (that is, character messages are posted to the application queue). Otherwise, it is zero.
The TranslateMessage function does not modify the message given by the lpMsg parameter.
TranslateMessage produces WM_CHAR messages only for keys which are mapped to ASCII characters by the keyboard driver.
An application should not call TranslateMessage if the application processes virtual-key messages for some other purpose. For instance, an application should not call the TranslateMessage function if the TranslateAccelerator function returns nonzero.