📄 key_testview.cpp
字号:
// Key_testView.cpp : implementation of the CKey_testView class
//
#include "stdafx.h"
#include "Key_test.h"
#include "Key_testDoc.h"
#include "Key_testView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CKey_testView
IMPLEMENT_DYNCREATE(CKey_testView, CView)
BEGIN_MESSAGE_MAP(CKey_testView, CView)
//{{AFX_MSG_MAP(CKey_testView)
ON_WM_CHAR()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CKey_testView construction/destruction
CKey_testView::CKey_testView()
{
// TODO: add construction code here
}
CKey_testView::~CKey_testView()
{
}
BOOL CKey_testView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CKey_testView drawing
void CKey_testView::OnDraw(CDC* pDC)
{
CKey_testDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CRect rect;
GetClientRect(&rect);
rect.top=rect.top+(rect.bottom-rect.top)*1/3;
rect.left=rect.left+(rect.right-rect.left)*1/3;
rect.bottom=rect.bottom*2/3;
rect.right=rect.right*2/3;
switch(m_nSharp)
{
case 1:
pDC->Ellipse(rect); break;
case 2:
pDC->Rectangle(rect);break;
}// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CKey_testView printing
BOOL CKey_testView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CKey_testView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CKey_testView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CKey_testView diagnostics
#ifdef _DEBUG
void CKey_testView::AssertValid() const
{
CView::AssertValid();
}
void CKey_testView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CKey_testDoc* CKey_testView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CKey_testDoc)));
return (CKey_testDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CKey_testView message handlers
void CKey_testView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
int nOldSharp=m_nSharp;
switch(nChar)
{
case 'c':
case'C':
m_nSharp=1;break;
case's':
case'S':
m_nSharp=2;break;
}
if(m_nSharp!=nOldSharp) Invalidate();// TODO: Add your message handler code here and/or call default
CView::OnChar(nChar, nRepCnt, nFlags);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -