📄 keyboardtest.cpp
字号:
// KeyBoardTest.cpp : implementation file
//
#include "stdafx.h"
#include "SBC2442.h"
#include "KeyBoardTest.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CKeyBoardTest dialog
CKeyBoardTest::CKeyBoardTest(CWnd* pParent /*=NULL*/)
: CDialog(CKeyBoardTest::IDD, pParent)
{
//{{AFX_DATA_INIT(CKeyBoardTest)
m_keydown = _T("");
//}}AFX_DATA_INIT
}
void CKeyBoardTest::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CKeyBoardTest)
DDX_Text(pDX, IDC_KEY, m_keydown);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CKeyBoardTest, CDialog)
//{{AFX_MSG_MAP(CKeyBoardTest)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CKeyBoardTest::PreTranslateMessage(MSG* pMsg)
{
CString str;
if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
{
switch(pMsg->wParam)
{
case VK_F7 :
str.Format(_T("VK_F7 "));
break;
case VK_NUMPAD8 :
str.Format(_T("VK_NUMPAD8 "));
break;
case VK_ESCAPE :
str.Format(_T("VK_ESCAPE "));
break;
case VK_RIGHT :
str.Format(_T("VK_RIGHT "));
break;
case VK_UP :
str.Format(_T("VK_UP "));
break;
case VK_F4 :
str.Format(_T("VK_F4 "));
break;
///////////////////
case VK_RETURN :
str.Format(_T("VK_RETURN "));
break;
case VK_NUMPAD9 :
str.Format(_T("VK_NUMPAD9 "));
break;
case VK_F5 :
str.Format(_T("VK_F5 "));
break;
case VK_BACK :
str.Format(_T("VK_BACK "));
break;
case VK_NUMPAD3 :
str.Format(_T("VK_NUMPAD3 "));
break;
case VK_F2 :
str.Format(_T("VK_F2 "));
break;
////////////////////
case VK_F10 :
str.Format(_T("VK_F10 "));
break;
case VK_DOWN :
str.Format(_T("VK_DOWN "));
break;
case VK_NUMPAD4 :
str.Format(_T("VK_NUMPAD4 "));
break;
case VK_LEFT :
str.Format(_T("VK_LEFT "));
break;
case VK_NUMPAD2 :
str.Format(_T("VK_NUMPAD2 "));
break;
case VK_F3 :
str.Format(_T("VK_F3 "));
break;
///////////////////
case VK_NUMPAD0 :
str.Format(_T("VK_NUMPAD0 "));
break;
case VK_NUMPAD7 :
str.Format(_T("VK_NUMPAD7 "));
break;
case VK_NUMPAD5 :
str.Format(_T("VK_NUMPAD5 "));
break;
case VK_NUMPAD6 :
str.Format(_T("VK_NUMPAD6 "));
break;
case VK_NUMPAD1 :
str.Format(_T("VK_NUMPAD1 "));
break;
case VK_F1 :
str.Format(_T("VK_F1 "));
break;
/////////////////
case VK_F6 :
str.Format(_T("VK_F6 "));
break;
default :
str.Format(_T("%c "),pMsg->wParam);
}
if(pMsg->wParam!=VK_F18)
{
switch(pMsg->message)
{
case WM_KEYDOWN:
str+=" KEY_DOWN";
break;
case WM_KEYUP:
str+=" KEY_UP";
break;
case WM_CHAR:
str+=" KEY_CHAR";
break;
case WM_DEADCHAR:
str+=" WM_SYSCHAR";
break;
case WM_SYSDEADCHAR:
str+=" WM_SYSDEADCHAR";
break;
case WM_SYSKEYDOWN:
str+=" WM_SYSKEYDOWN";
break;
case WM_SYSKEYUP:
str+=" WM_SYSKEYUP";
break;
default:
str+=" unkown";
break;
}
/* if(GetKeyState(VK_LMENU))
str+=" LA";
else if(GetKeyState(VK_RMENU))
str+=" RA";
else if(GetKeyState(VK_LCONTROL))
str+=" LC";
else if(GetKeyState(VK_RCONTROL))
str+=" RC";
else if(GetKeyState(VK_LSHIFT))
str+=" LS";
else if(GetKeyState(VK_LMENU))
str+=" RS";
*/
str+="\r\n";
m_keydown=str+m_keydown;
UpdateData(false);
}
}
else if(pMsg->message == WM_KILLFOCUS){
AfxMessageBox(L"ERROR");
}
return CDialog::PreTranslateMessage(pMsg);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -