【VC开源代码栏目提醒】:以下是网学会员为您推荐的VC开源代码-CPaint_7View.cpp,希望本篇文章对您学习有所帮助。
// CPaint_7View.cpp : implementation of the CCPaint_7View class
//
#include "stdafx.h"
#include "CPaint_7.h"
#include "Setting.h"
#include "CPaint_7Doc.h"
#include "CPaint_7View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCPaint_7View
IMPLEMENT_DYNCREATE(CCPaint_7View, CView)
BEGIN_MESSAGE_MAP(CCPaint_7View, CView)
//{{AFX_MSG_MAP(CCPaint_7View)
ON_COMMAND(IDM_SETTING, OnSetting)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCPaint_7View construction/destruction
CCPaint_7View::CCPaint_7View()
{
// TODO: add construction code here
LineWidth=10;
LineStyle=PS_SOLID;
}
CCPaint_7View::~CCPaint_7View()
{
}
BOOL CCPaint_7View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_7View drawing
void CCPaint_7View::OnDraw(CDC* pDC)
{
CCPaint_7Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_7View printing
BOOL CCPaint_7View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCPaint_7View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCPaint_7View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_7View diagnostics
#ifdef _DEBUG
void CCPaint_7View::AssertValid() const
{
CView::AssertValid();
}
void CCPaint_7View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCPaint_7Doc* CCPaint_7View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCPaint_7Doc)));
return (CCPaint_7Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCPaint_7View message handlers
void CCPaint_7View::OnSetting()
{
// TODO: Add your command handler code here
CSetting dlg;
if(IDOK==dlg.DoModal()) //创建对话框
{
LineWidth=dlg.m_LineWidth;
LineStyle=dlg.m_LineStyle;
}
CClientDC dc(this);
CPen pen(LineStyle,LineWidth,RGB(255,0,0));
dc.SelectObject(&pen); //将画笔选经设备环境中
CPoint point1(0,10);
CPoint point2(100,200);
dc.Ellipse(CRect(point1,point2)); //画一个椭圆
}