📄 ch5demo2view.cpp
字号:
// Ch5Demo2View.cpp : implementation of the CCh5Demo2View class
//
#include "stdafx.h"
#include "Ch5Demo2.h"
#include "Ch5Demo2Doc.h"
#include "Ch5Demo2View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCh5Demo2View
IMPLEMENT_DYNCREATE(CCh5Demo2View, CView)
BEGIN_MESSAGE_MAP(CCh5Demo2View, CView)
//{{AFX_MSG_MAP(CCh5Demo2View)
ON_WM_KEYDOWN()
ON_WM_KEYUP()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCh5Demo2View construction/destruction
CCh5Demo2View::CCh5Demo2View()
{
// TODO: add construction code here
b_Ctrldown=false;//初始化
b_F8down=false;//初始化
}
CCh5Demo2View::~CCh5Demo2View()
{
}
BOOL CCh5Demo2View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCh5Demo2View drawing
void CCh5Demo2View::OnDraw(CDC* pDC)
{
CCh5Demo2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCh5Demo2View printing
BOOL CCh5Demo2View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCh5Demo2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCh5Demo2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCh5Demo2View diagnostics
#ifdef _DEBUG
void CCh5Demo2View::AssertValid() const
{
CView::AssertValid();
}
void CCh5Demo2View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCh5Demo2Doc* CCh5Demo2View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCh5Demo2Doc)));
return (CCh5Demo2Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCh5Demo2View message handlers
void CCh5Demo2View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(nChar==VK_CONTROL)//如果按下了“Ctrl”键
{
b_Ctrldown=true;
}
if(nChar==VK_F8)//如果按下了“F8”键
{
b_F8down=true;
}
if(b_Ctrldown&&b_F8down)//同时按下了“Ctrl”键和“F8”键
{
b_Ctrldown=false;
b_F8down=false;
AfxMessageBox("同时按下了Ctrl键和F8键");//弹出提示框
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CCh5Demo2View::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(nChar==VK_CONTROL)//如果释放了“Ctrl”键
{
b_Ctrldown=false;
}
if(nChar==VK_F8)//如果释放了“F8”键
{
b_F8down=false;
}
CView::OnKeyUp(nChar, nRepCnt, nFlags);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -