【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:CPaint_5View.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
// CPaint_5View.cpp : implementation of the CCPaint_5View class
//
#include "stdafx.h"
#include "CPaint_5.h"
#include "CPaint_5Doc.h"
#include "CPaint_5View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCPaint_5View
IMPLEMENT_DYNCREATE(CCPaint_5View, CView)
BEGIN_MESSAGE_MAP(CCPaint_5View, CView)
//{{AFX_MSG_MAP(CCPaint_5View)
ON_COMMAND(IDM_COLOR, OnColor)
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_5View construction/destruction
CCPaint_5View::CCPaint_5View()
{
// TODO: add construction code here
m_point1=0;
m_point2=0;
color=RGB(255,0,0);
}
CCPaint_5View::~CCPaint_5View()
{
}
BOOL CCPaint_5View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_5View drawing
void CCPaint_5View::OnDraw(CDC* pDC)
{
CCPaint_5Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_5View printing
BOOL CCPaint_5View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCPaint_5View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCPaint_5View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCPaint_5View diagnostics
#ifdef _DEBUG
void CCPaint_5View::AssertValid() const
{
CView::AssertValid();
}
void CCPaint_5View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCPaint_5Doc* CCPaint_5View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCPaint_5Doc)));
return (CCPaint_5Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCPaint_5View message handlers
void CCPaint_5View::OnColor()
{
// TODO: Add your command handler code here
CColorDialog dlg;
if(IDOK==dlg.DoModal()) //创建颜色对话框
{
color=dlg.m_cc.rgbResult;
}
CClientDC dc(this);
CPen pen(PS_SOLID,10,color); //设置新画笔
dc.SelectObject(&pen);
dc.MoveTo(0,50);
dc.LineTo(200,20); //画曲线
}
void CCPaint_5View::OnPaint()
{
CPaintDC dc(this); // device context for painting
CPen pen(PS_SOLID,10,color);
dc.SelectObject(&pen);
dc.MoveTo(0,50);
dc.LineTo(200,20);
// TODO: Add your message handler code here
// Do not call CView::OnPaint() for painting messages
}
//DEL void CCPaint_5View::OnLButtonDown(UINT nFlags, CPoint point)
//DEL {
//DEL // TODO: Add your message handler code here and/or call default
//DEL m_point1=point;
//DEL CView::OnLButtonDown(nFlags, point);
//DEL }
//DEL void CCPaint_5View::OnLButtonUp(UINT nFlags, CPoint point)
//DEL {
//DEL // TODO: Add your message handler code here and/or call default
//DEL m_point2=point;
//DEL CClientDC dc(this);
//DEL dc.MoveTo(m_point1);
//DEL dc.LineTo(m_point2);
//DEL CView::OnLButtonUp(nFlags, point);
//DEL }
上一篇:
CPaint_5Doc.cpp
下一篇:
多年来只想说一句,我不怪你