📄 ch9demo1view.cpp
字号:
// Ch9Demo1View.cpp : implementation of the CCh9Demo1View class
//
#include "stdafx.h"
#include "Ch9Demo1.h"
#include "Ch9Demo1Doc.h"
#include "Ch9Demo1View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo1View
IMPLEMENT_DYNCREATE(CCh9Demo1View, CView)
BEGIN_MESSAGE_MAP(CCh9Demo1View, CView)
//{{AFX_MSG_MAP(CCh9Demo1View)
ON_COMMAND(ID_CLIENTDC, OnClientdc)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo1View construction/destruction
CCh9Demo1View::CCh9Demo1View()
{
// TODO: add construction code here
}
CCh9Demo1View::~CCh9Demo1View()
{
}
BOOL CCh9Demo1View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo1View drawing
void CCh9Demo1View::OnDraw(CDC* pDC)
{
CCh9Demo1Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo1View printing
BOOL CCh9Demo1View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCh9Demo1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCh9Demo1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo1View diagnostics
#ifdef _DEBUG
void CCh9Demo1View::AssertValid() const
{
CView::AssertValid();
}
void CCh9Demo1View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCh9Demo1Doc* CCh9Demo1View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCh9Demo1Doc)));
return (CCh9Demo1Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCh9Demo1View message handlers
void CCh9Demo1View::OnClientdc()
{
// TODO: Add your command handler code here
CClientDC dc(this); //创建CClientDC类对象
CPen pen1; //自定义画笔
pen1.CreatePen(PS_SOLID,0,RGB(255,0,0));
CPen *poldPen = dc.SelectObject(&pen1); //选择新画笔,返回并保存原值
dc.SelectStockObject(GRAY_BRUSH); //选择库存灰色画刷
CRect rect1(0,0,120,90); //定义矩形
dc.Rectangle(&rect1); //画出矩形
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -