The following code fragment shows how to respond to a character message:
USHORT fsKeyFlags;
UCHAR uchChr1;
case WM_CHAR:
fsKeyFlags = (USHORT) SHORT1FROMMP(mp1);
if (fsKeyFlags & KC_CHAR) {
/* Get the character code from mp2. */
uchChr1 = (UCHAR) CHAR1FROMMP(mp2);
.
. /* Process the character. */
.
return TRUE;
}
If the KC_CHAR flag is not set, the mp2 parameter from CHAR1FROMMP still might contain useful information. If either the Alt key or the Ctrl key, or both, are down, the KC_CHAR bit is not set when the user presses another key. For example, if the user presses the a key when the Alt key is down, the low word of mp2 contains the ASCII value for "a" (0x0061), the KC_ALT flag is set, and the KC_CHAR flag is clear. If the translation does not generate any valid characters, the char field is set to 0.