afx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags );
nChar
Contains the value of the key.
nRepCnt
Contains the repeat count.
nFlags
Contains the scan code, key-transition code, previous key state, and context code, as shown in the following list:
Value | Description |
0–7 | Scan code (OEM-dependent value). |
8 | Extended key, such as a function key or a key on the numeric keypad (1 if it is an extended key). |
11–12 | Used internally by Windows. |
13 | Context code (1 if the ALT key is held down while the key is pressed, 0 otherwise). |
14 | Previous key state (1 if the key is down before the call, 0 if the key is up). |
15 | Transition state (1 if the key is being released, 0 if the key is being pressed). |
Called before the OnKeyUp member function and after the OnKeyDown member function are called. OnChar contains the value of the keyboard key being pressed or released.
Since there is not necessarily a one-to-one correspondence between keys pressed and OnChar calls generated, the information in nFlags is generally not useful to applications. The information in nFlags applies only to the most recent call to the OnKeyUp member function or the OnKeyDown member function that precedes the call to OnChar.
For IBM Enhanced 101- and 102-key keyboards, enhanced keys are the right ALT and the right CONTROL 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 slash (/) and ENTER keys in the numeric keypad. Some other keyboards may support the extended-key bit in nFlags.
This message-handler member function calls the Default member function. Override this member function in your derived class to handle the WM_CHAR message.
CWnd::Default, WM_CHAR, WM_KEYDOWN, WM_KEYUP