www.pudn.com > 自由画直线.rar > exam010View.cpp
// exam010View.cpp : Cexam010View 类的实现
//
#include "stdafx.h"
#include "exam010.h"
#include "exam010Doc.h"
#include "exam010View.h"
#include ".\exam010view.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Cexam010View
IMPLEMENT_DYNCREATE(Cexam010View, CView)
BEGIN_MESSAGE_MAP(Cexam010View, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
// Cexam010View 构造/析构
Cexam010View::Cexam010View()
: m_prpoint(0)
, flags(false)
{
// TODO: 在此处添加构造代码
}
Cexam010View::~Cexam010View()
{
}
BOOL Cexam010View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CView::PreCreateWindow(cs);
}
// Cexam010View 绘制
void Cexam010View::OnDraw(CDC* /*pDC*/)
{
Cexam010Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: 在此处为本机数据添加绘制代码
}
// Cexam010View 打印
BOOL Cexam010View::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void Cexam010View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印前添加额外的初始化
}
void Cexam010View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印后添加清除过程
}
// Cexam010View 诊断
#ifdef _DEBUG
void Cexam010View::AssertValid() const
{
CView::AssertValid();
}
void Cexam010View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
Cexam010Doc* Cexam010View::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cexam010Doc)));
return (Cexam010Doc*)m_pDocument;
}
#endif //_DEBUG
// Cexam010View 消息处理程序
void Cexam010View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
SetCapture( );
m_prpoint=point;
CDC* pDC=GetDC( );
pDC->MoveTo(m_prpoint);
flags=true;
ReleaseDC(pDC);
CView::OnLButtonDown(nFlags, point);
}
void Cexam010View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CDC* pDC=GetDC( );
pDC->MoveTo(m_prpoint);
pDC->LineTo(point);
m_prpoint=point;
ReleaseDC(pDC);
flags=false;
ReleaseCapture( );
CView::OnLButtonUp(nFlags, point);
}
void Cexam010View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if(flags)
{CDC* pDC=GetDC( );
pDC->MoveTo(m_prpoint);
pDC->LineTo(point);
m_prpoint=point;
ReleaseDC(pDC);
}
CView::OnMouseMove(nFlags, point);
}