📄 displayprintcharkeyview.cpp
字号:
// DisplayPrintCharKeyView.cpp : implementation of the CDisplayPrintCharKeyView class
//
#include "stdafx.h"
#include "DisplayPrintCharKey.h"
#include "DisplayPrintCharKeyDoc.h"
#include "DisplayPrintCharKeyView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDisplayPrintCharKeyView
IMPLEMENT_DYNCREATE(CDisplayPrintCharKeyView, CScrollView)
BEGIN_MESSAGE_MAP(CDisplayPrintCharKeyView, CScrollView)
//{{AFX_MSG_MAP(CDisplayPrintCharKeyView)
ON_WM_CHAR()
ON_WM_KEYDOWN()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CScrollView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDisplayPrintCharKeyView construction/destruction
CDisplayPrintCharKeyView::CDisplayPrintCharKeyView()
{
// TODO: add construction code here
}
CDisplayPrintCharKeyView::~CDisplayPrintCharKeyView()
{
}
BOOL CDisplayPrintCharKeyView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CDisplayPrintCharKeyView drawing
void CDisplayPrintCharKeyView::OnDraw(CDC* pDC)
{
CDisplayPrintCharKeyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
pDC->TextOut(0,0,pDoc->m_str);
}
void CDisplayPrintCharKeyView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// TODO: calculate the total size of this view
//sizeTotal.cx = sizeTotal.cy = 100;
CDisplayPrintCharKeyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
sizeTotal.cx = pDoc->GetDocSize().cx;
sizeTotal.cy = pDoc->GetDocSize().cy;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CDisplayPrintCharKeyView printing
BOOL CDisplayPrintCharKeyView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CDisplayPrintCharKeyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CDisplayPrintCharKeyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CDisplayPrintCharKeyView diagnostics
#ifdef _DEBUG
void CDisplayPrintCharKeyView::AssertValid() const
{
CScrollView::AssertValid();
}
void CDisplayPrintCharKeyView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CDisplayPrintCharKeyDoc* CDisplayPrintCharKeyView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDisplayPrintCharKeyDoc)));
return (CDisplayPrintCharKeyDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CDisplayPrintCharKeyView message handlers
void CDisplayPrintCharKeyView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CDisplayPrintCharKeyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDoc->m_str += nChar;
Invalidate();
pDoc->UpdateAllViews(this,NULL,NULL);
pDoc->SetModifiedFlag();
CScrollView::OnChar(nChar, nRepCnt, nFlags);
}
void CDisplayPrintCharKeyView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CDisplayPrintCharKeyDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (nChar == VK_UP)
{
pDoc->m_str += "上方向键";
}
if (nChar == VK_DOWN)
{
pDoc->m_str += "下方向键";
}
if (nChar == VK_LEFT)
{
pDoc->m_str += "左方向键";
}
if (nChar == VK_RIGHT)
{
pDoc->m_str += "右方向键";
}
if (nChar == VK_BACK)
{
pDoc->m_str += "退格键";
}
if (nChar == VK_TAB)
{
pDoc->m_str += "TAB键";
}
if (nChar == VK_RETURN)
{
pDoc->m_str += "回车键";
}
if (nChar == VK_SHIFT)
{
pDoc->m_str += "SHIFT键";
}
if (nChar == VK_CONTROL)
{
pDoc->m_str += "CONTROL键";
}
if (nChar == VK_MENU)
{
pDoc->m_str += "ALT 键";
}
if (nChar == VK_SPACE)
{
pDoc->m_str += "空格键";
}
if (nChar == VK_LWIN)
{
pDoc->m_str += "左Windows键";
}
if (nChar == VK_RWIN)
{
pDoc->m_str += "右Windows键";
}
if (nChar == VK_F1)
{
pDoc->m_str += "F1 键";
}
if (nChar == VK_F2)
{
pDoc->m_str += "F2 键";
}
if (nChar == VK_F3)
{
pDoc->m_str += "F3 键";
}
if (nChar == VK_F4)
{
pDoc->m_str += "F4 键";
}
if (nChar == VK_F5)
{
pDoc->m_str += "F5 键";
}
if (nChar == VK_F6)
{
pDoc->m_str += "F6 键";
}
if (nChar == VK_F7)
{
pDoc->m_str += "F7 键";
}
if (nChar == VK_F8)
{
pDoc->m_str += "F8 键";
}
if (nChar == VK_F9)
{
pDoc->m_str += "F9 键";
}
if (nChar == VK_F10)
{
pDoc->m_str += "F10 键";
}
if (nChar == VK_F11)
{
pDoc->m_str += "F11 键";
}
if (nChar == VK_F12)
{
pDoc->m_str += "F12 键";
}
if (nChar == VK_ESCAPE)
{
pDoc->m_str += "ESC 键";
}
if (nChar == VK_CAPITAL)
{
pDoc->m_str += "CapsLock 键";
}
Invalidate();
pDoc->UpdateAllViews(this,NULL,NULL);
pDoc->SetModifiedFlag();
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -