windows_programming_notes.nbk: Home | Index | Next Page: WM_CHARTOITEM | Previous Page: WM_CHANGECBCHAIN


 WM_CHAR

The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed.

A window receives this message through its WindowProc function.

    LRESULT CALLBACK WindowProc(
      HWND hwnd,       // handle to window
      UINT uMsg,       // WM_CHAR
      WPARAM wParam,   // character code (TCHAR)
      LPARAM lParam    // key data
    );

Parameters

Return Values

An application should return zero if it processes this message.

Remarks

Because there is not necessarily a one-to-one correspondence between keys pressed and character messages generated, the information in the high-order word of the lParam parameter is generally not useful to applications. The information in the high-order word applies only to the most recent WM_KEYDOWN message that precedes the posting of the WM_CHAR message.

For enhanced 101- and 102-key keyboards, extended keys are the right ALT and the right CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Some other keyboards may support the extended-key bit in the lParam parameter.

Whistler: The WM_UNICHAR message is the same as WM_CHAR, except it is designed to send or post Unicode characters to ANSI windows.

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: WM_CHARTOITEM | Previous Page: WM_CHANGECBCHAIN


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time