📄 chapter08view.cpp
字号:
// Chapter08View.cpp : implementation of the CChapter08View class
//
#include "stdafx.h"
#include "Chapter08.h"
#include "Chapter08Doc.h"
#include "Chapter08View.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChapter08View
IMPLEMENT_DYNCREATE(CChapter08View, CView)
BEGIN_MESSAGE_MAP(CChapter08View, CView)
//{{AFX_MSG_MAP(CChapter08View)
ON_WM_LBUTTONDOWN()
ON_WM_RBUTTONDOWN()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CChapter08View construction/destruction
CChapter08View::CChapter08View()
{
// TODO: add construction code here
}
CChapter08View::~CChapter08View()
{
}
BOOL CChapter08View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CChapter08View drawing
void CChapter08View::OnDraw(CDC* pDC)
{
CChapter08Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CChapter08View printing
BOOL CChapter08View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CChapter08View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CChapter08View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CChapter08View diagnostics
#ifdef _DEBUG
void CChapter08View::AssertValid() const
{
CView::AssertValid();
}
void CChapter08View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CChapter08Doc* CChapter08View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CChapter08Doc)));
return (CChapter08Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CChapter08View message handlers
void CChapter08View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMainFrame* pMainFrm=(CMainFrame*)AfxGetMainWnd();
CDC* pDc=GetDC();
//创建画笔C++对象
CPen* pPenBlue = new CPen;
//创建画笔
// pPenBlue->CreatePen(PS_SOLID,pMainFrm->m_thick,RGB(0,255,0));
pPenBlue->CreatePen(PS_SOLID,pMainFrm->m_thick,pMainFrm->m_color);
//选中当前画笔,并保存以前的画笔
CPen* pOldPen = pDc->SelectObject(pPenBlue);
//画圆
pDc->Ellipse(point.x,point.y,point.x+\
pMainFrm->m_long,point.y+pMainFrm->m_short);
//恢复旧画笔
pDc->SelectObject(pOldPen);
//删除新建的画笔对象
delete pPenBlue;
ReleaseDC(pDc);
CView::OnLButtonDown(nFlags, point);
}
void CChapter08View::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CMainFrame* pMainFrm=(CMainFrame*)AfxGetMainWnd();
//创建新字体
CFont* pNewFont=new CFont();
VERIFY(pNewFont->CreateFontIndirect(&pMainFrm->logft));
//获取设备上下文
CClientDC dc(this);
//将新字体选入设备上下文
CFont* pOldFont=dc.SelectObject(pNewFont);
//在鼠标点击附近显示文本
dc.TextOut(point.x+10,point.y+10,pMainFrm->m_strText);
//恢复原来的字体
dc.SelectObject(pOldFont);
//删除新字体
delete pNewFont;
CView::OnRButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -