Page 115 - DCAP408_WEB_PROGRAMMING
P. 115

Unit 7: Character Sets, Fonts and the Keyboard




          7.4 WM_CHAR Message                                                                   Notes

          WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN
          message is converted by the Translate Message function.

          The WM_CHAR message includes the character code of the key that was pressed.
          #define WM_CHAR                 0x0102

          7.4.1 Parameters

          wParam: It is the character code of the key.
          lParam: The repeat count, scan code, extended-key flag, context code, previous key-state flag,
          and transition-state flag, as displayed in the following table.


            Bits                                 Meaning
            0-15    The repeat count for the existing message. The value is the number of times the keystroke
                    is auto repeated as a consequence of the user holding down the key. If the keystroke is
                    held  long  enough,  numerous  messages  are  sent.  However,  the  repeat  count  is  not
                    cumulative.
            16-23   The scan code. The value relies on the OEM.
            24      Signifies whether the key is an extended key, like the right-hand ALT and CTRL keys that
                    appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; or
                    else, it is 0.
            25-28   Reserved; do not use.
            29      The context code. The value is 1 if the ALT key is held down while the key is pressed; or
                    else, the value is 0.
            30      The previous key state. The value is 1 if the key is down before the message is sent, or it is
                    0 if the key is up.
            31      The transition state. The value is 1 if the key is being released, or it is 0 if the key is being
                    pressed.

          7.4.2 Return  Value

          An application should return zero if it processes this message.

          Remarks

          The WM_CHAR message utilizes Unicode Transformation Format (UTF)-16.
          Since there is not necessarily a one-to-one correspondence among keys pressed and character
          messages produced, the information in the high-order word of the lParam parameter is usually
          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 improved 101- and 102-key keyboards, extensive keys are the right ALT and the right CTRL
          keys on the chief 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 sustain the extended-key  bit in the
          lParam parameter.
          The WM_UNICHAR message is  the similar  as WM_CHAR, except it  utilizes UTF-32. It  is
          intended to send or post Unicode characters to ANSI windows, and it  can manage Unicode
          additional Plane characters.



                                           LOVELY PROFESSIONAL UNIVERSITY                                   109
   110   111   112   113   114   115   116   117   118   119   120