📄 mouseview.cpp
字号:
// mouseView.cpp : implementation of the CMouseView class
//
#include "stdafx.h"
#include "mouse.h"
#include "mouseDoc.h"
#include "mouseView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMouseView
IMPLEMENT_DYNCREATE(CMouseView, CView)
BEGIN_MESSAGE_MAP(CMouseView, CView)
//{{AFX_MSG_MAP(CMouseView)
ON_WM_LBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMouseView construction/destruction
CMouseView::CMouseView():m_rect(0,0,200,200)
{
// TODO: add construction code here
}
CMouseView::~CMouseView()
{
}
BOOL CMouseView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMouseView drawing
void CMouseView::OnDraw(CDC* pDC)
{
CMouseDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->Rectangle(m_rect);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMouseView printing
BOOL CMouseView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMouseView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMouseView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMouseView diagnostics
#ifdef _DEBUG
void CMouseView::AssertValid() const
{
CView::AssertValid();
}
void CMouseView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMouseDoc* CMouseView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMouseDoc)));
return (CMouseDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMouseView message handlers
void CMouseView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here
// and/or call default
CDC * pDC = this->GetDC();
if(m_rect.PtInRect(point))
{
pDC->Ellipse(point.x-5,point.y-5,point.x+5,point.y+5);
MessageBox("In the box");
}
else
{
pDC->Ellipse(point.x-5,point.y-5,point.x+5,point.y+5);
MessageBox("Out of the box");
}
CView::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -