📄 exampl~2.cpp
字号:
#include "stdafx.h"
#include "Example.h"
#include "ExampleDoc.h"
#include "ExampleView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CExampleView
IMPLEMENT_DYNCREATE(CExampleView, CView)
BEGIN_MESSAGE_MAP(CExampleView, CView)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
// CExampleView 构造/销毁
CExampleView::CExampleView()
{
// TODO: 在此处添加构造代码
m_tracker.m_rect.SetRect(0, 0, 30, 30);
m_tracker.m_nStyle=CRectTracker::resizeInside | CRectTracker::dottedLine;
}
CExampleView::~CExampleView()
{
}
// CExampleView 绘制
void CExampleView::OnDraw(CDC* pDC)
{
CExampleDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: 在此处为本机数据添加绘制代码
CBrush brush (RGB (0, 0, 255));
CBrush* pOldBrush=pDC->SelectObject(&brush);
CRect rcEllipse;
m_tracker.GetTrueRect(rcEllipse);
pDC->Ellipse(rcEllipse);
m_tracker.Draw(pDC);
pDC->SelectObject(pOldBrush);
}
#ifdef _DEBUG
CExampleDoc* CExampleView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExampleDoc)));
return (CExampleDoc*)m_pDocument;
}
#endif //_DEBUG
// CExampleView 消息处理程序
void CExampleView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CExampleDoc* pDoc=GetDocument();
ASSERT_VALID(pDoc);
BOOL bResult=m_tracker.HitTest(point)!= CRectTracker::hitNothing;
if (bResult)
{
m_tracker.Track (this,point,true);
pDoc->SetModifiedFlag();
pDoc->UpdateAllViews(NULL);
}
else
m_tracker.TrackRubberBand(this,point,true);
CView::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -