【VC开源代码栏目提醒】:网学会员--在 VC开源代码编辑为广大网友搜集整理了:tuyaView.cpp绩等信息,祝愿广大网友取得需要的信息,参考学习。
// tuyaView.cpp : CtuyaView 类的实现
//
#include "stdafx.h"
#include "tuya.h"
#include "tuyaDoc.h"
#include "tuyaView.h"
#include ".\tuyaview.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CtuyaView
IMPLEMENT_DYNCREATE(CtuyaView, CView)
BEGIN_MESSAGE_MAP(CtuyaView, 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()
// CtuyaView 构造/析构
CtuyaView::CtuyaView()
{
// TODO: 在此处添加构造代码
flag=false;
}
CtuyaView::~CtuyaView()
{
}
BOOL CtuyaView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CView::PreCreateWindow(cs);
}
// CtuyaView 绘制
void CtuyaView::OnDraw(CDC* /*pDC*/)
{
CtuyaDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: 在此处为本机数据添加绘制代码
}
// CtuyaView 打印
BOOL CtuyaView::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void CtuyaView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印前添加额外的初始化
}
void CtuyaView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印后添加清除过程
}
// CtuyaView 诊断
#ifdef _DEBUG
void CtuyaView::AssertValid() const
{
CView::AssertValid();
}
void CtuyaView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CtuyaDoc* CtuyaView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CtuyaDoc)));
return (CtuyaDoc*)m_pDocument;
}
#endif //_DEBUG
// CtuyaView 消息处理
程序 void CtuyaView::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
flag=true;
start=point;
CView::OnLButtonDown(nFlags, point);
}
void CtuyaView::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
flag=false;
CView::OnLButtonUp(nFlags, point);
}
void CtuyaView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
CDC* pDC=GetDC();
using namespace Gdiplus;
Graphics graphics(pDC->m_hDC);
Pen pen(Color(255,0,0,0),1);
if(flag)
{
end=point;
graphics.DrawLine(&pen,start.x,start.y,end.x,end.y);
start=end;
}
CView::OnMouseMove(nFlags, point);
}