Page 113 - DCAP408_WEB_PROGRAMMING
P. 113

Unit 7: Character Sets, Fonts and the Keyboard




          When the window procedure obtains the WM_KEYDOWN message, it should inspect the virtual-  Notes
          key code that accompanies the message to find out how to process the keystroke. The virtual-
          key code is included in the wParamparameter of the message.
          The lParam parameter of a keystroke message includes additional data regarding the keystroke
          that produced the message. The following table displays the additional keystroke data that is
          needed by the lParam parameter.
                 Data                               Description
            Context code    The value is 1 if the ALT key was pressed or 0 if the pressed key was released.
            Previous key state   The value is 1 if the pressed key was  down before or 0 if the pressed key was
                            up  before.  The  value  is  1  for  WM_KEYDOWN  and  WM_SYSKEYDOWN
                            keystroke messages that were produced by automatic repeat functionality.
            Repeat count    States the number of times that the keystroke was repeated as a result of the
                            user holding down the key.
            Scan code       Provides the hardware-dependent key scan code.
            Transition state   The value is 1 if the key was released or if the key was pressed.

          Usually, an application processes only the keystrokes that are produced by noncharacter keys.


                 Example: The following code example displays the window procedure framework that
          a usual application uses to obtain and process keystroke messages.
          case  WM_KEYDOWN:
                      switch  (wParam)
                {
                  case VK_HOME:
                              //  Insert  code  here  to  process  the  HOME  key
                    // ...
                    break;


                  case VK_END:
                            //  Insert  code  here  to process  the  END  key
                    // ...
                    break;

                  case VK_INSERT:
                            //  Insert  code  here  to process  the  INS  key
                    // ...
                    break;


                  case VK_F2:
                          //  Insert code  here  to process  the F2  key
                    // ...
                    break;





                                           LOVELY PROFESSIONAL UNIVERSITY                                   107
   108   109   110   111   112   113   114   115   116   117   118