The following code fragment shows how to decode a WM_CHAR message containing a valid virtual-key code:

    USHORT fsKeyFlags;

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

    if (fsKeyFlags & KC_VIRTUALKEY) {

        /* Get the virtual key from mp2.       */
        switch (SHORT2FROMMP(mp2)) {
         case VK_TAB:
             .
             . /* Process the TAB key.         */
             .
             return TRUE;
         case VK_LEFT:
             .
             . /* Process the LEFT key.        */
             .
             return TRUE;
         case VK_UP:
             .
             . /* Process the UP key.          */
             .
             return TRUE;
         case VK_RIGHT:
             .
             . /* Process the RIGHT key.       */
             .
             return TRUE;
         case VK_DOWN:
             .
             . /* Process the DOWN key.        */
             .
             return TRUE;
           .
           . /* Etc...                         */
           .
           default:
               return FALSE;
           }
       }


[Back] [Next]