-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpractice5View.cpp
More file actions
158 lines (123 loc) · 3.59 KB
/
Copy pathpractice5View.cpp
File metadata and controls
158 lines (123 loc) · 3.59 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
148
149
150
151
152
153
154
155
156
157
158
// practice5View.cpp: Cpractice5View 클래스의 구현
//
#include "pch.h"
#include "framework.h"
// SHARED_HANDLERS는 미리 보기, 축소판 그림 및 검색 필터 처리기를 구현하는 ATL 프로젝트에서 정의할 수 있으며
// 해당 프로젝트와 문서 코드를 공유하도록 해 줍니다.
#ifndef SHARED_HANDLERS
#include "practice5.h"
#endif
#include "practice5Doc.h"
#include "practice5View.h"
#include "CinputDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Cpractice5View
IMPLEMENT_DYNCREATE(Cpractice5View, CView)
BEGIN_MESSAGE_MAP(Cpractice5View, 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()
END_MESSAGE_MAP()
// Cpractice5View 생성/소멸
Cpractice5View::Cpractice5View() noexcept
{
// TODO: 여기에 생성 코드를 추가합니다.
}
Cpractice5View::~Cpractice5View()
{
}
BOOL Cpractice5View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: CREATESTRUCT cs를 수정하여 여기에서
// Window 클래스 또는 스타일을 수정합니다.
return CView::PreCreateWindow(cs);
}
// Cpractice5View 그리기
void Cpractice5View::OnDraw(CDC* pDC)
{
Cpractice5Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: 여기에 원시 데이터에 대한 그리기 코드를 추가합니다.
// 1. m_nDocColor 값에 따라 텍스트 색상 설정
COLORREF color;
switch (pDoc->m_nDocColor)
{
case 0: // BLACK
color = RGB(0, 0, 0);
break;
case 1: // RED
color = RGB(255, 0, 0);
break;
case 2: // GREEN
color = RGB(0, 255, 0);
break;
case 3: // BLUE
color = RGB(0, 0, 255);
break;
default:
color = RGB(0, 0, 0);
break;
}
pDC->SetTextColor(color);
// 2. 도큐먼트의 멤버 변수를 사용해 문자열 출력
pDC->TextOut(pDoc->m_nDocX, pDoc->m_nDocY, pDoc->m_strDocText);
}
// Cpractice5View 인쇄
BOOL Cpractice5View::OnPreparePrinting(CPrintInfo* pInfo)
{
// 기본적인 준비
return DoPreparePrinting(pInfo);
}
void Cpractice5View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 인쇄하기 전에 추가 초기화 작업을 추가합니다.
}
void Cpractice5View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 인쇄 후 정리 작업을 추가합니다.
}
// Cpractice5View 진단
#ifdef _DEBUG
void Cpractice5View::AssertValid() const
{
CView::AssertValid();
}
void Cpractice5View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
Cpractice5Doc* Cpractice5View::GetDocument() const // 디버그되지 않은 버전은 인라인으로 지정됩니다.
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cpractice5Doc)));
return (Cpractice5Doc*)m_pDocument;
}
#endif //_DEBUG
// Cpractice5View 메시지 처리기
void Cpractice5View::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
CView::OnRButtonDown(nFlags, point);
// 1. CInputDlg 객체 생성
CinputDlg dlg;
// 2. DoModal() 함수를 이용해 대화상자 출력 및 IDOK 반환 확인
if (dlg.DoModal() == IDOK)
{
// 3. 도큐먼트 클래스의 인스턴스를 얻어옴
Cpractice5Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// 4. 대화상자에서 입력한 값(dlg.m_nX 등)을
// 도큐먼트 클래스의 멤버 변수(pDoc->m_nDocX 등)에 치환(저장)
pDoc->m_nDocX = dlg.m_nX;
pDoc->m_nDocY = dlg.m_nY;
pDoc->m_strDocText = dlg.m_strText;
// 5. 화면 갱신 (OnDraw() 함수 호출)
Invalidate();
}
}