• MFC 关于按键状态获取


    alt键会阻断消息? moousemove
    alt键无法判断,按下一次 并松开一次状态改变一次
    #define KeyState GetAsyncKeyState
    BOOL bCtrlDown = (KeyState(VK_CONTROL) & 0xff00) > 0 ? TRUE : FALSE;//81 80
    BOOL bShiftDown = (KeyState(VK_SHIFT) & 0xff00) > 0 ? TRUE : FALSE;//81 80
    BOOL bAltDown = (KeyState(VK_MENU) & 0xff00) > 0 ? TRUE : FALSE;//81 80

    CString str;
    CString csCtrl;
    CString csAlt;
    CString csShift;
    csCtrl = bCtrlDown == TRUE ? _T("TRUE") : _T("FALSE");
    csShift = bShift == TRUE ? _T("TRUE") : _T("FALSE");
    csAlt = bAlt == TRUE ? _T("TRUE") : _T("FALSE");
    CString cstr;
    cstr.Format(_T("Ctrl:%d,Shift:%d,Alt:%d"), bCtrlDown, bShiftDown, bAltDown);
    txt2.SetWindowText(cstr);
    keydown按键触发
    void CKeyDownTestDlg::OnKeyDown(WPARAM wparam)
    {
    bool bDownValue = true;
    if (wparam == VK_CONTROL || wparam == VK_LCONTROL)
    {
    bCtrl = bDownValue;
    }

    //这个响应不及时,需要WM_SYSKEYDOWN才能响应
    if (wparam == VK_MENU || wparam == VK_LMENU || wparam == VK_RMENU)
    {
    bAlt = bDownValue;
    }
    if (wparam == VK_SHIFT || wparam == VK_LSHIFT)
    {
    bShift = bDownValue;
    }
    Update();
    }

  • 相关阅读:
    分页
    【移动】
    iOS
    内存数据库
    HOJ——T 2275 Number sequence
    HOJ——T 1867 经理的烦恼
    HOJ——T 2430 Counting the algorithms
    洛谷—— P2047 社交网络
    HDU——T 1166 敌兵布阵
    前端学习之jquery
  • 原文地址:https://www.cnblogs.com/yang131/p/14029984.html
Copyright © 2020-2023  润新知