📄 ex3_3view.cpp
字号:
// Ex3_3View.cpp : implementation of the CEx3_3View class
//
#include "stdafx.h"
#include "Ex3_3.h"
#include "Ex3_3Doc.h"
#include "Ex3_3View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx3_3View
IMPLEMENT_DYNCREATE(CEx3_3View, CView)
BEGIN_MESSAGE_MAP(CEx3_3View, CView)
//{{AFX_MSG_MAP(CEx3_3View)
ON_WM_RBUTTONDOWN()
ON_WM_KEYDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CEx3_3View construction/destruction
CEx3_3View::CEx3_3View()
{
// TODO: add construction code here
}
CEx3_3View::~CEx3_3View()
{
}
BOOL CEx3_3View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_3View drawing
void CEx3_3View::OnDraw(CDC* pDC)
{
CEx3_3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CString stuinfo;
stuinfo.Format("%d::%s",pDoc->recno,pDoc->stuname);
pDC->TextOut(250,200,stuinfo);
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_3View printing
BOOL CEx3_3View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx3_3View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx3_3View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEx3_3View diagnostics
#ifdef _DEBUG
void CEx3_3View::AssertValid() const
{
CView::AssertValid();
}
void CEx3_3View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEx3_3Doc* CEx3_3View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx3_3Doc)));
return (CEx3_3Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx3_3View message handlers
void CEx3_3View::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//定义客户区设备上下文对象,并用this指针将该对象指向view
CClientDC dc(this);
dc.TextOut( point.x,point.y,"right click"); //point 给出了鼠标的位置[point.x,point.y]
CView::OnRButtonDown(nFlags, point);
}
void CEx3_3View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CEx3_3Doc* pDoc = GetDocument();
if (nChar==VK_UP)//VK_UP是上箭头键的虚拟码
{
pDoc->recno++;//学号增1
Invalidate();//更新视图
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -