【VC开源代码栏目提醒】:网学会员在VC开源代码频道为大家收集整理了ex6View.cpp提供大家参考,希望对大家有所帮助!
// ex6View.cpp : implementation of the CEx6View class
//
#include "stdafx.h"
#include "ex6.h"
#include "ex6Doc.h"
#include "ex6View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEx6View
IMPLEMENT_DYNCREATE(CEx6View, CView)
BEGIN_MESSAGE_MAP(CEx6View, CView)
//{{AFX_MSG_MAP(CEx6View)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CEx6View construction/destruction
CEx6View::CEx6View()
{
// TODO: add construction code here
}
CEx6View::~CEx6View()
{
}
BOOL CEx6View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CEx6View drawing
void CEx6View::OnDraw(CDC* pDC)
{
CEx6Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPen NewPen; //新的画笔对象
CPen * pOldPen; //保存原先的画笔对象
//初始化实线,2个像素宽,红色画笔
NewPen.CreatePen(PS_SOLID,2,RGB(255,0,0));
//将画笔选入设备文本
pOldPen = pDC->SelectObject(&NewPen);
//创建画刷
CBrush brush(RGB(128,128,128));
//将画刷选入设备文本
CBrush *pOldBrush=pDC->SelectObject(&brush);
//绘图
pDC->MoveTo(5,5);
pDC->LineTo(25,25);
pDC->Rectangle(CRect(5,55,50,85));
pDC->Arc(CRect(5,115,50,145),CPoint(250,55),CPoint(305,55));
pDC->Ellipse(CRect(250,5,305,25));
pDC->Pie(CRect(250,55,305,85),CPoint(250,55),CPoint(305,55));
pDC->Chord(CRect(250,115,305,145),CPoint(250,115),CPoint(305,145));
CPoint pt[7] ;//多边形连接的点
pt[0].x = 0 ; pt[0].y = 250 ;
pt[1].x = 50 ; pt[1].y = 175 ;
pt[2].x = 100 ; pt[2].y = 175 ;
pt[3].x = 150 ; pt[3].y = 250 ;
pt[4].x = 200 ; pt[4].y = 325 ;
pt[5].x = 250 ; pt[5].y = 325 ;
pt[6].x = 300 ; pt[6].y = 250 ;
//绘制多边形
pDC->Polygon(pt,7);
pOldPen=pDC->SelectObject(pOldPen);
pOldBrush=pDC->SelectObject(pOldBrush);
pOldPen->DeleteObject();
pOldBrush->DeleteObject();
}
/////////////////////////////////////////////////////////////////////////////
// CEx6View printing
BOOL CEx6View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CEx6View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CEx6View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CEx6View diagnostics
#ifdef _DEBUG
void CEx6View::AssertValid() const
{
CView::AssertValid();
}
void CEx6View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CEx6Doc* CEx6View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx6Doc)));
return (CEx6Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CEx6View message handlers
上一篇:
ex6Doc.cpp
下一篇:
4种小菜缓解孕妈咪不适