📄 ex5_2view.cpp
字号:
// Ex5_2View.cpp : implementation of the CEx5_2View class
//
#include "stdafx.h"
#include "Ex5_2.h"
#include "Ex5_2Doc.h"
#include "Ex5_2View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx5_2View
IMPLEMENT_DYNCREATE(CEx5_2View, CView)
BEGIN_MESSAGE_MAP(CEx5_2View, CView)
//{{AFX_MSG_MAP(CEx5_2View)
ON_WM_LBUTTONDBLCLK()
ON_WM_RBUTTONDBLCLK()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx5_2View construction/destruction
CEx5_2View::CEx5_2View()
{
// TODO: add construction code here
m_flag=0;
}
CEx5_2View::~CEx5_2View()
{
}
BOOL CEx5_2View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx5_2View drawing
void CEx5_2View::OnDraw(CDC* pDC)
{
CEx5_2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CRect rect;
this->GetClientRect(rect); //获得当前客户区
if(m_flag)
{
//在客户区的右下角输出文本串
pDC->TextOut(rect.Width()-200 ,rect.Height()-20,"双击鼠标右键,清除同心圆");
// 设置客户区中心位置为原点
pDC->SetViewportOrg(rect.Width()/2,rect.Height()/2);
//输出同心圆
pDC->Ellipse(-120,-120,120,120);
pDC->Ellipse(-80,-80,80,80);
pDC->Ellipse(-40,-40,40,40);
}
else
pDC->TextOut(0,rect.Height()-20,"双击鼠标左键,显示同心圆");
}
/////////////////////////////////////////////////////////////////////////////
// CEx5_2View diagnostics
#ifdef _DEBUG
void CEx5_2View::AssertValid() const
{
CView::AssertValid();
}
void CEx5_2View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEx5_2Doc* CEx5_2View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx5_2Doc)));
return (CEx5_2Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx5_2View message handlers
void CEx5_2View::OnLButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_flag=1;
this->Invalidate(true);
CView::OnLButtonDblClk(nFlags, point);
}
void CEx5_2View::OnRButtonDblClk(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_flag=0;
this->Invalidate(true);
CView::OnRButtonDblClk(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -