【VC开源代码栏目提醒】:网学会员VC开源代码为您提供CDraw_2View.cpp参考,解决您在CDraw_2View.cpp学习中工作中的难题,参考学习。
// CDraw_2View.cpp : implementation of the CCDraw_2View class
//
#include "stdafx.h"
#include "CDraw_2.h"
#include "CDraw_2Doc.h"
#include "CDraw_2View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCDraw_2View
IMPLEMENT_DYNCREATE(CCDraw_2View, CView)
BEGIN_MESSAGE_MAP(CCDraw_2View, CView)
//{{AFX_MSG_MAP(CCDraw_2View)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CCDraw_2View construction/destruction
CCDraw_2View::CCDraw_2View()
{
// TODO: add construction code here
}
CCDraw_2View::~CCDraw_2View()
{
}
BOOL CCDraw_2View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_2View drawing
void CCDraw_2View::OnDraw(CDC* pDC)
{
CCDraw_2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_2View printing
BOOL CCDraw_2View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCDraw_2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCDraw_2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_2View diagnostics
#ifdef _DEBUG
void CCDraw_2View::AssertValid() const
{
CView::AssertValid();
}
void CCDraw_2View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCDraw_2Doc* CCDraw_2View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCDraw_2Doc)));
return (CCDraw_2Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCDraw_2View message handlers
void CCDraw_2View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
m_point=point;
CView::OnLButtonDown(nFlags, point);
}
void CCDraw_2View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC *pdc=GetDC();
pdc->MoveTo(m_point);
pdc->LineTo(point); //划线
ReleaseDC(pdc); //释放句柄
CView::OnLButtonUp(nFlags, point);
}
上一篇:
CDraw_2Doc.cpp
下一篇:
如何当一个轻松的班主任