【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,CDraw_3View.cpp,希望对大家有所帮助!
// CDraw_3View.cpp : implementation of the CCDraw_3View class
//
#include "stdafx.h"
#include "CDraw_3.h"
#include "CDraw_3Doc.h"
#include "CDraw_3View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCDraw_3View
IMPLEMENT_DYNCREATE(CCDraw_3View, CView)
BEGIN_MESSAGE_MAP(CCDraw_3View, CView)
//{{AFX_MSG_MAP(CCDraw_3View)
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_3View construction/destruction
CCDraw_3View::CCDraw_3View()
{
// TODO: add construction code here
}
CCDraw_3View::~CCDraw_3View()
{
}
BOOL CCDraw_3View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_3View drawing
void CCDraw_3View::OnDraw(CDC* pDC)
{
CCDraw_3Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_3View printing
BOOL CCDraw_3View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCDraw_3View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCDraw_3View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_3View diagnostics
#ifdef _DEBUG
void CCDraw_3View::AssertValid() const
{
CView::AssertValid();
}
void CCDraw_3View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCDraw_3Doc* CCDraw_3View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCDraw_3Doc)));
return (CCDraw_3Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCDraw_3View message handlers
void CCDraw_3View::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_3View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CClientDC dc(GetParent()); //获得框架类的指针
dc.MoveTo(m_point);
dc.LineTo(point);
CView::OnLButtonUp(nFlags, point);
}