-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawLineView.cpp
More file actions
147 lines (108 loc) · 3.05 KB
/
DrawLineView.cpp
File metadata and controls
147 lines (108 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
// DrawLineView.cpp: CDrawLineView 类的实现
//
#include "stdafx.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义,并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "DrawLine.h"
#endif
#include "DrawLineDoc.h"
#include "DrawLineView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CDrawLineView
IMPLEMENT_DYNCREATE(CDrawLineView, CView)
BEGIN_MESSAGE_MAP(CDrawLineView, 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_RBUTTONDOWN()
ON_WM_RBUTTONUP()
END_MESSAGE_MAP()
// CDrawLineView 构造/析构
CDrawLineView::CDrawLineView() noexcept
{
// TODO: 在此处添加构造代码
}
CDrawLineView::~CDrawLineView()
{
}
BOOL CDrawLineView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改
// CREATESTRUCT cs 来修改窗口类或样式
return CView::PreCreateWindow(cs);
}
// CDrawLineView 绘图
void CDrawLineView::OnDraw(CDC* /*pDC*/)
{
CDrawLineDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: 在此处为本机数据添加绘制代码
}
// CDrawLineView 打印
BOOL CDrawLineView::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void CDrawLineView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加额外的打印前进行的初始化过程
}
void CDrawLineView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 添加打印后进行的清理过程
}
// CDrawLineView 诊断
#ifdef _DEBUG
void CDrawLineView::AssertValid() const
{
CView::AssertValid();
}
void CDrawLineView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CDrawLineDoc* CDrawLineView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDrawLineDoc)));
return (CDrawLineDoc*)m_pDocument;
}
#endif //_DEBUG
// CDrawLineView 消息处理程序
void CDrawLineView::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (this->flag == false)
{
this->flag = true;
this->start = point;
}
CView::OnRButtonDown(nFlags, point);
}
void CDrawLineView::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (this->flag == true)
{
CDC *pdc = this->GetDC();
this->flag = false;
this->end = point;
this->dda.SetDc(pdc);
this->dda.Moveline(this->start,this->end);
this->ptp.SetDc(pdc);
this->ptp.Moveline(*new CPoint(this->start.x+20, this->start.y), *new CPoint(this->end.x+ 20, this->end.y));
this->Bresen.SetDc(pdc);
this->Bresen.Moveline(*new CPoint(this->start.x + 40, this->start.y ), *new CPoint(this->end.x + 40, this->end.y));
this->Midpoi.SetDc(pdc);
this->Midpoi.Moveline(*new CPoint(this->start.x + 60, this->start.y ), *new CPoint(this->end.x + 60, this->end.y ));
ReleaseDC(pdc);
}
CView::OnRButtonUp(nFlags, point);
}