• 组合键


    BOOL CtestDlg::PreTranslateMessage(MSG* pMsg)
    {
    // TODO: 在此添加专用代码和/或调用基类
    if(pMsg->message==WM_SYSKEYDOWN)//Alt+?系列热键
    {
    char keyMap[50]="";
    BOOL bAlt=::GetKeyState(VK_MENU)&0x8000;
    if(bAlt)
    {
    if(pMsg->wParam==VK_F4)//屏蔽Alt+F4
    return true;
    else if(((pMsg->wParam>=0x30)&&(pMsg->wParam<=0x39))||((pMsg->wParam>=0x41)&&(pMsg->wParam<=0x5a)))//Alt+?热键(?在0-9,A-Z)
    {
    sprintf(keyMap,"Alt+%c",pMsg->wParam);
    GetDlgItem(IDC_EDIT)->SetWindowTextA(keyMap);
    }
    else
    GetDlgItem(IDC_EDIT)->SetWindowTextA("无");
    }
    else
    GetDlgItem(IDC_EDIT)->SetWindowTextA("无");
    }
    else if(pMsg->message==WM_KEYDOWN)
    {
    BOOL bCtrl=::GetKeyState(VK_CONTROL)&0x8000;
    BOOL bShift=::GetKeyState(VK_SHIFT)&0x8000;
    BOOL bAlt=::GetKeyState(VK_MENU)&0x8000;
    BOOL bHotKey=bCtrl|bShift|bAlt;//判断是否有热键按下
    char keyMap[50]="";
    if(pMsg->wParam==VK_RETURN)//屏蔽回车
    return true;
    else if(pMsg->wParam==VK_ESCAPE)//屏蔽ESC
    return true;
    else if(bHotKey)
    {
    if(((pMsg->wParam>=0x30)&&(pMsg->wParam<=0x39))||((pMsg->wParam>=0x41)&&(pMsg->wParam<=0x5a)))
    {
    if(bCtrl)
    sprintf(keyMap,"%sCtrl+",keyMap);
    if(bShift)
    sprintf(keyMap,"%sShift+",keyMap);
    if(bAlt)
    sprintf(keyMap,"%sAlt+",keyMap);
    sprintf(keyMap,"%s%c",keyMap,pMsg->wParam);
    GetDlgItem(IDC_EDIT)->SetWindowTextA(keyMap);
    }
    else
    GetDlgItem(IDC_EDIT)->SetWindowTextA("无");
    }
    else
    GetDlgItem(IDC_EDIT)->SetWindowTextA("无");
    }

    return CDialog::PreTranslateMessage(pMsg);
    }

  • 相关阅读:
    Python文件操作
    Python操作MySQL数据库
    Can't connect to MySQL server (10065)
    CentOS安装Navicat
    机器学习中Batch Size、Iteration和Epoch的概念
    Python禁用GC优化性能
    TensorFlow迭代速度变慢的问题
    Linear SVM和LR的区别和联系
    拉格朗日乘子法和KKT条件
    Python机器学习(1):KMeans聚类
  • 原文地址:https://www.cnblogs.com/dengpeng1004/p/4986926.html
Copyright © 2020-2023  润新知