Ctrl+Z 在VC中如何表示?

解决方案 »

  1.   

    BOOL CXXWnd::PreTranslateMessage(MSG* pMsg)
    {
        if( pMsg->message == WM_KEYDOWN )
        {
    BYTE keybytes[256];
            memset(keybytes, 0, 256);
    GetKeyboardState(keybytes);
            if ( (pMsg->wParam == _T('Z') || pMsg->wParam == _T('z'))
              && (keybytes[VK_CONTROL] & 0x80) )
            {
                 // to do, ctrl + 'z' or ctrl + 'Z'
            }
        }
        return CWnd::PreTranslateMessage(pMsg);
    }
      

  2.   

    BOOL CXXWnd::PreTranslateMessage(MSG* pMsg) 

        if( pMsg->message == WM_KEYDOWN ) 
        { 
    BYTE keybytes[256]; 
            memset(keybytes, 0, 256); 
    GetKeyboardState(keybytes); 
            if ( (pMsg->wParam == _T('Z') || pMsg->wParam == _T('z')) 
              && (keybytes[VK_CONTROL] & 0x80) ) 
            { 
                // to do, ctrl + 'z' or ctrl + 'Z' 
            } 
        } 
        return CWnd::PreTranslateMessage(pMsg); 
    }
      

  3.   

    BOOL CXXWnd::PreTranslateMessage(MSG* pMsg) 

        if( pMsg->message == WM_KEYDOWN ) 
        { 
            if (GetKeyState()& 0x8000)  // 按下ctrl键
           {
               if ( pMsg->wParam == _T('Z')  ) 
               { 
                  // to do, ctrl + 'z' or ctrl + 'Z' 
               } 
            }
        } 
        return CWnd::PreTranslateMessage(pMsg); 
      

  4.   

    不好意思 函数GetKeyState(VK_CONTROL);少了里边的参数VK_CONTROL