TranslateMessage

2.x

  BOOL TranslateMessage(lpmsg)    
  const MSG FAR* lpmsg; /* address of MSG structure */

The TranslateMessage function translates virtual-key messages into character messages, as follows:

WM_KEYDOWN/WM_KEYUP combinations produce a WM_CHAR or WM_DEADCHAR message.

WM_SYSKEYDOWN/WM_SYSKEYUP combinations produce a WM_SYSCHAR or WM_SYSDEADCHAR message.

The character messages are posted to the application's message queue, to be read the next time the application calls the GetMessage or PeekMessage function.

Parameters

lpmsg

Points to an MSG structure retrieved by a call to the GetMessage or PeekMessage function. The structure contains message information from the application's message queue. The MSG structure has the following form:

typedef struct tagMSG {     /* msg */
    HWND   hwnd;
    UINT   message;
    WPARAM wParam;
    LPARAM lParam;
    DWORD  time;
    POINT  pt;
} MSG;

For a full description of this structure, see the Microsoft Windows Programmer's Reference, Volume 3.

Return Value

The return value is nonzero if the message is WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN, or WM_SYSKEYUP, regardless of whether the key that was pressed or released generates a WM_CHAR message. Otherwise, the return value is zero.

Comments

The TranslateMessage function does not modify the message pointed to by the lpmsg parameter.

TranslateMessage produces WM_CHAR messages only for keys that 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 TranslateMessage if the TranslateAccelerator function returns nonzero.

See Also

GetMessage, PeekMessage, TranslateAccelerator