zoukankan      html  css  js  c++  java
  • 组合键

    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);
    }

  • 相关阅读:
    UVA-11437 Triangle Fun
    UVA 10491
    CF 223C
    poj 3273
    由异常掉电问题---谈xfs文件系统
    好久没有写博客了,最近一段时间做一下总结吧!
    Json.Net
    div 旋转
    VirtualBox虚拟机网络设置
    windows 2003 安装 MVC 环境 404错误,无法找到该页
  • 原文地址:https://www.cnblogs.com/dengpeng1004/p/4986926.html
Copyright © 2011-2022 走看看