请问如何在vc中判断同时按下多个键(如ctrl+A)?

解决方案 »

  1.   

    BOOL GetKeyboardState(
      PBYTE lpKeyState   // array of status data
    );
      

  2.   

    响应ON_WM_CHAR ON_WM_KEYDOWN ON_WM_KEYUP都行,主要是判断他们响应函数的第三个参数:nFlags
    定义如下:
    Value   Description 
    0–7    Scan code (OEM-dependent value). 
    8       Extended key, such as a function key or a key on the numeric keypad (1 if it is an extended key). 
    9–10   Not used. 
    11–12  Used internally by Windows. 
    13      Context code (1 if the ALT key is held down while the key is pressed; otherwise 0). 
    14      Previous key state (1 if the key is down before the call, 0 if the key is up). 
    15      Transition state (1 if the key is being released, 0 if the key is being pressed). 
    判断ALT键只是判断一下13位是否为高位就行了,至于其他键只能结合GetKeyboardState()使用了。