-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathp41_test.d
66 lines (53 loc) · 1.22 KB
/
p41_test.d
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
import dgl.frame;
import win32.windows;
class TestFrame : TopFrame
{
override LRESULT platformWndProc(DefProc defProc, uint msg, WPARAM wp, LPARAM lp)
{
switch(msg)
{
case WM_PAINT:
onPaint();
break;
case WM_SIZE:
InvalidateRect(platformHandle, null, TRUE);
break;
default:
break;
}
return super.platformWndProc(defProc, msg, wp, lp);
}
void onPaint()
{
PAINTSTRUCT ps;
auto hdc = BeginPaint(platformHandle, &ps);
scope(exit) EndPaint(platformHandle, &ps);
Rect rc;
GetClientRect(platformHandle, rc.ptr);
auto center = centerPoint(rc);
immutable sizeCircle = 60;
auto offset = Size(sizeCircle/2, sizeCircle/2);
auto size = Size(sizeCircle, sizeCircle);
auto rectCircle = Rect(center - offset, size);
auto hBrush = CreateSolidBrush(RGB(0, 0, 0));
scope(exit) DeleteObject(hBrush);
auto hOrgBrush = SelectObject(hdc, hBrush);
scope(exit) SelectObject(hdc, hOrgBrush);
Ellipse(hdc, rectCircle.left, rectCircle.top, rectCircle.right, rectCircle.bottom);
}
Point centerPoint(ref Rect r)
{
return Point(
r.width / 2 + r.left,
r.height / 2 + r.top);
}
}
void main()
{
auto f = new TestFrame();
f.show();
MsgLoop.run(&onIdle);
}
void onIdle()
{
}