【VC开源代码栏目提醒】:网学会员为需要VC开源代码的朋友们搜集整理了CPaint_4View.cpp相关资料,希望对各位网友有所帮助!
// CPaint_4View.cpp : implementation of the CCPaint_4View class
//
#include "stdafx.h"
#include "CPaint_4.h"
#include"setting.h"
#include "CPaint_4Doc.h"
#include "CPaint_4View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCPaint_4View
IMPLEMENT_DYNCREATE(CCPaint_4View, CView)
BEGIN_MESSAGE_MAP(CCPaint_4View, CView)
//{{AFX_MSG_MAP(CCPaint_4View)
ON_COMMAND(IDM_SETTING, OnSetting)
ON_WM_PAINT()
//}}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_4View construction/destruction
CCPaint_4View::CCPaint_4View()
{
// TODO: add construction code here
m_linewidth=1;
m_style=0;
}
CCPaint_4View::~CCPaint_4View()
{
}
BOOL CCPaint_4View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_4View drawing
void CCPaint_4View::OnDraw(CDC* pDC)
{
CCPaint_4Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_4View printing
BOOL CCPaint_4View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCPaint_4View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCPaint_4View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_4View diagnostics
#ifdef _DEBUG
void CCPaint_4View::AssertValid() const
{
CView::AssertValid();
}
void CCPaint_4View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCPaint_4Doc* CCPaint_4View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCPaint_4Doc)));
return (CCPaint_4Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCPaint_4View message handlers
//DEL void CCPaint_4View::OnSetting()
//DEL {
//DEL // TODO: Add your command handler code here
//DEL
//DEL }
void CCPaint_4View::OnSetting()
{
// TODO: Add your command handler code here
CSetting dlg;
if(IDOK==dlg.DoModal()) //创建对话框
{
m_linewidth=dlg.m_LineWidth;
m_style=dlg.m_linestyle;
}
CClientDC dc(this);
CPen pen(m_style,m_linewidth,RGB(255,0,0));
dc.SelectObject(&pen); //将画笔选经设备环境中
CPoint point1(0,10);
CPoint point2(100,200);
dc.Ellipse(CRect(point1,point2)); //画一个椭圆
}
void CCPaint_4View::OnPaint()
{
CPaintDC dc(this); // device context for painting
CPen pen(m_style,m_linewidth,RGB(255,0,0));
dc.SelectObject(&pen);
CPoint point1(0,10);
CPoint point2(100,200);
dc.Ellipse(CRect(point1,point2));
// TODO: Add your message handler code here
// Do not call CView::OnPaint() for painting messages
}