All WM_CHAR messages generated by keyboard input events have valid scan codes. WM_CHAR messages posted by other applications might or might not have valid scan codes. The following code fragment shows how to extract a scan code from a WM_CHAR message:

    USHORT fsKeyFlags;
    UCHAR  uchScanCode;

    case WM_CHAR:
    fsKeyFlags = (USHORT) SHORT1FROMMP(mp1);

    if (fsKeyFlags & KC_SCANCODE) {

        /* Get the scan code from mp1.   */
        uchScanCode = CHAR4FROMMP(mp1);
        .
        . /* Process the scan code.      */
        .

        return (MRESULT) TRUE;
       }


[Back] [Next]