📄 conedit.cpp
字号:
// ConEdit.cpp : implementation file
//
#include "stdafx.h"
#include "ConEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CConEdit
CConEdit::CConEdit()
{
}
CConEdit::~CConEdit()
{
}
BEGIN_MESSAGE_MAP(CConEdit, CEdit)
//{{AFX_MSG_MAP(CConEdit)
ON_WM_KEYDOWN()
ON_WM_CHAR()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConEdit message handlers
char temp[8];
void CConEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
sprintf(temp,"%c",nChar);
switch(nChar)
{
case VK_ESCAPE:
strcpy(temp,"ESC");
break;
case VK_RETURN:
strcpy(temp,"ENTER");
break;
case VK_TAB:
strcpy(temp,"TAB");
break;
case VK_CAPITAL:
strcpy(temp,"CAPS");
break;
case VK_SHIFT:
strcpy(temp,"SHITF");
break;
case VK_CONTROL:
strcpy(temp,"CTRL");
break;
case VK_BACK:
strcpy(temp,"BACKSPACE");
break;
case VK_PRIOR:
strcpy(temp,"PAGE UP");
break;
case VK_END:
strcpy(temp,"END");
break;
case VK_PAUSE:
strcpy(temp,"PAUSE");
break;
case VK_NEXT:
strcpy(temp,"PGAE DONW");
break;
case VK_HOME:
strcpy(temp,"HOME");
break;
case VK_DELETE:
strcpy(temp,"DELETE");
break;
case VK_INSERT:
strcpy(temp,"INSERT");
break;
case VK_SPACE:
strcpy(temp,"SPACE");
break;
case VK_NUMLOCK:
strcpy(temp,"NUMLOCK");
break;
case VK_SCROLL:
strcpy(temp,"SCROLL");
break;
case VK_NUMPAD0:
strcpy(temp,"NUMPAD0");
break;
case VK_NUMPAD1:
strcpy(temp,"NUMPAD1");
break;
case VK_NUMPAD2:
strcpy(temp,"NUMPAD2");
break;
case VK_NUMPAD3:
strcpy(temp,"NUMPAD3");
break;
case VK_NUMPAD4:
strcpy(temp,"NUMPAD4");
break;
case VK_NUMPAD5:
strcpy(temp,"NUMPAD5");
break;
case VK_NUMPAD6:
strcpy(temp,"NUMPAD6");
break;
case VK_NUMPAD7:
strcpy(temp,"NUMPAD7");
break;
case VK_NUMPAD8:
strcpy(temp,"NUMPAD8");
break;
case VK_NUMPAD9:
strcpy(temp,"NUMPAD9");
break;
case VK_ADD:
strcpy(temp,"NUMPAD+");
break;
case VK_SEPARATOR:
strcpy(temp,"SEPARATOR");
break;
case VK_SUBTRACT:
strcpy(temp,"NUMPAD-");
break;
case VK_DECIMAL:
strcpy(temp,"NUMPAD.");
break;
case VK_DIVIDE:
strcpy(temp,"NUMPAD/");
break;
case VK_MULTIPLY:
strcpy(temp,"NUMPAD*");
break;
case VK_APPS:
strcpy(temp,"APPS");
break;
case VK_UP:
strcpy(temp,"UP");
break;
case VK_DOWN:
strcpy(temp,"DOWN");
break;
case VK_LEFT:
strcpy(temp,"LEFT");
break;
case VK_RIGHT:
strcpy(temp,"RIGHT");
break;
case VK_F1:
strcpy(temp,"F1");
break;
case VK_F2:
strcpy(temp,"F2");
break;
case VK_F3:
strcpy(temp,"F3");
break;
case VK_F4:
strcpy(temp,"F4");
break;
case VK_F5:
strcpy(temp,"F5");
break;
case VK_F6:
strcpy(temp,"F6");
break;
case VK_F7:
strcpy(temp,"F7");
break;
case VK_F8:
strcpy(temp,"F8");
break;
case VK_F9:
strcpy(temp,"F9");
break;
case VK_F10:
strcpy(temp,"F10");
break;
case VK_F11:
strcpy(temp,"F11");
break;
case VK_F12:
strcpy(temp,"F12");
break;
case 0xc0:
strcpy(temp,"~");
break;
case 189:
strcpy(temp,"-");
break;
case 187:
strcpy(temp,"+");
break;
case 220:
strcpy(temp,"/");
break;
case 188:
strcpy(temp,"<");
break;
case 190:
strcpy(temp,">");
break;
case 191:
strcpy(temp,"?");
break;
default:
break;
}
this->SetWindowText(temp);
m_key=nChar;
CEdit::OnKeyDown(nChar,nRepCnt,nFlags);
}
void CConEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
}
BOOL CConEdit::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->hwnd==m_hWnd && pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN )
{
m_key=VK_RETURN;
this->SetWindowText("ENTER");
}
if(pMsg->wParam==VK_ESCAPE)
{
m_key=VK_ESCAPE;
this->SetWindowText("ESC");
}
}
return CEdit::PreTranslateMessage(pMsg);
}
void CConEdit::OnPaint()
{
OnKeyDown(m_key,NULL,NULL);
// Do not call CEdit::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -