forked from vsite-nwp/v05
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
54 lines (49 loc) · 1.03 KB
/
main.cpp
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
#include <windows.h>
#include <tchar.h>
#include <list>
#include <algorithm>
#include <iterator>
#include "nwpwin.h"
class MainWindow : public Window
{
std::list<POINT> draw_cords;
protected:
void OnPaint(HDC hdc)
{
if (draw_cords.empty())
return;
MoveToEx(hdc, draw_cords.front().x, draw_cords.front().y, 0);
for (std::list<POINT>::iterator it = draw_cords.begin(); it != draw_cords.end(); ++it)
LineTo(hdc, it->x, it->y);
}
void OnLButtonDown(POINT p)
{
draw_cords.push_back(p);
InvalidateRect(*this, 0, TRUE);
}
void OnKeyDown(int vk)
{
switch (vk) {
case VK_ESCAPE:
draw_cords.clear();
break;
case VK_BACK:
if (draw_cords.empty())
return;
draw_cords.pop_back();
break;
}
InvalidateRect(*this, 0, TRUE);
}
void OnDestroy()
{
::PostQuitMessage(0);
}
};
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
{
Application app;
MainWindow wnd;
wnd.Create(NULL, WS_OVERLAPPEDWINDOW | WS_VISIBLE, _T("NWP 5"));
return app.Run();
}