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

  • 相关阅读:
    Hostker云主机
    Orz 终于有了自己的博客地址
    BZOJ 1635: [Usaco2007 Jan]Tallest Cow 最高的牛
    BZOJ 1636: [Usaco2007 Jan]Balanced Lineup
    BZOJ 2252: [2010Beijing wc]矩阵距离
    BZOJ 2253: [2010 Beijing wc]纸箱堆叠
    BZOJ 无数据题集合
    BZOJ 1087: [SCOI2005]互不侵犯King
    BZOJ 3236: [Ahoi2013]作业
    POJ2352:Stars
  • 原文地址:https://www.cnblogs.com/dengpeng1004/p/4986926.html
Copyright © 2011-2022 走看看