home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / i_o / gkeystat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  790 b   |  33 lines

  1. /*
  2.  *
  3.  *  GetKeyState
  4.  *  
  5.  *  This program demonstrates the use of the function GetKeyState
  6.  *  This function retrieves the state of the virtual key specified by the
  7.  *  parameter.
  8.  *  
  9.  */
  10.  
  11. #include <windows.h>
  12.  
  13. int PASCAL WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow )
  14. HANDLE hInstance, hPrevInstance;
  15. LPSTR  lpszCmdLine;
  16. int    cmdShow;
  17. {
  18.   static char szFuncName[] = "GetKeyState";
  19.   int nState;
  20.   
  21.   MessageBox (NULL, (LPSTR)"Getting the key state of F1", (LPSTR)szFuncName,
  22.      MB_OK);
  23.  
  24.   nState = GetKeyState ( VK_F1 );
  25.  
  26.   if ( ( nState & 0x8000 ) != 0x8000 )
  27.      MessageBox (NULL, (LPSTR)"The key F1 is up", (LPSTR)szFuncName, MB_OK);
  28.   else
  29.      MessageBox (NULL, (LPSTR)"The key F1 is down", (LPSTR)szFuncName, MB_OK);
  30.  
  31.   return 0;
  32. }
  33.