【VC开源代码栏目提醒】:网学会员鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“CBrush_5View.cpp”一文,供大家参考学习
// CBrush_5View.cpp : implementation of the CCBrush_5View class
//
#include "stdafx.h"
#include "CBrush_5.h"
#include "CBrush_5Doc.h"
#include "CBrush_5View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCBrush_5View
IMPLEMENT_DYNCREATE(CCBrush_5View, CView)
BEGIN_MESSAGE_MAP(CCBrush_5View, CView)
//{{AFX_MSG_MAP(CCBrush_5View)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCBrush_5View construction/destruction
CCBrush_5View::CCBrush_5View()
{
// TODO: add construction code here
m_point=0;
m_decide=FALSE;
m_pOld=0;
}
CCBrush_5View::~CCBrush_5View()
{
}
BOOL CCBrush_5View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCBrush_5View drawing
void CCBrush_5View::OnDraw(CDC* pDC)
{
CCBrush_5Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCBrush_5View printing
BOOL CCBrush_5View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCBrush_5View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCBrush_5View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCBrush_5View diagnostics
#ifdef _DEBUG
void CCBrush_5View::AssertValid() const
{
CView::AssertValid();
}
void CCBrush_5View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCBrush_5Doc* CCBrush_5View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCBrush_5Doc)));
return (CCBrush_5Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCBrush_5View message handlers
void CCBrush_5View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_point=m_pOld=point;//m_pOld放置上一个点的位置
m_decide=TRUE;
CView::OnLButtonDown(nFlags, point);
}
void CCBrush_5View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_decide=FALSE;
CView::OnLButtonUp(nFlags, point);
}
void CCBrush_5View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(this);
CPen pen(PS_SOLID,1,RGB(255,0,0)); //添加一个红色的画笔
CPen* pOldPen=dc.SelectObject(&pen);
if(m_decide==TRUE)
{
dc.MoveTo(m_point);
dc.LineTo(m_pOld);
dc.MoveTo(m_pOld);
dc.LineTo(point);
m_pOld=point;
}
dc.SelectObject(pOldPen); //换上原画笔
CView::OnMouseMove(nFlags, point);
}
上一篇:
CBrush_5Doc.cpp
下一篇:
试析影响公路路面平整度的因素及应采取的施工措施