【VC开源代码栏目提醒】:网学会员,鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“CDraw_6View.cpp”一文,供大家参考学习!
// CDraw_6View.cpp : implementation of the CCDraw_6View class
//
#include "stdafx.h"
#include "CDraw_6.h"
#include "CDraw_6Doc.h"
#include "CDraw_6View.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCDraw_6View
IMPLEMENT_DYNCREATE(CCDraw_6View, CView)
BEGIN_MESSAGE_MAP(CCDraw_6View, CView)
//{{AFX_MSG_MAP(CCDraw_6View)
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_6View construction/destruction
CCDraw_6View::CCDraw_6View()
{
// TODO: add construction code here
}
CCDraw_6View::~CCDraw_6View()
{
}
BOOL CCDraw_6View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_6View drawing
void CCDraw_6View::OnDraw(CDC* pDC)
{
CCDraw_6Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_6View printing
BOOL CCDraw_6View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCDraw_6View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCDraw_6View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCDraw_6View diagnostics
#ifdef _DEBUG
void CCDraw_6View::AssertValid() const
{
CView::AssertValid();
}
void CCDraw_6View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCDraw_6Doc* CCDraw_6View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCDraw_6Doc)));
return (CCDraw_6Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCDraw_6View message handlers
void CCDraw_6View::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_6View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CPen pen(PS_SOLID,10,RGB(255,0,0));
CClientDC dc(this);
CPen *pOldPen=dc.SelectObject(&pen); //将新的画笔选到设备描述表中
dc.MoveTo(m_point);
dc.LineTo(point);
dc.SelectObject(pOldPen); //返回原值
CView::OnLButtonUp(nFlags, point);
}
上一篇:
CDraw_6Doc.cpp
下一篇:
如何当一个轻松的班主任