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
| #include <windows.h>
//-----------------------------------------------------------------------------
void DrawCone(HWND handle, HDC hdc)
{
RECT rect;
LONG width;
GetClientRect(handle, &rect);
width = rect.right - rect.left;
MoveToEx(hdc, width / 2, rect.top, NULL);
LineTo(hdc, width / 2, rect.bottom - (width / 4));
LineTo(hdc, rect.right, rect.bottom - (width / 4));
LineTo(hdc, width / 2, rect.top);
LineTo(hdc, rect.left, rect.bottom - (width / 4));
Arc(hdc, rect.left, rect.bottom - (width / 2),
rect.right, rect.bottom, 0, 0, 0, 0);
}
//-----------------------------------------------------------------------------
LRESULT CALLBACK WindowProcedure(HWND handle,
UINT message,
WPARAM wParam,
LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch (message)
{
case WM_PAINT:
hdc = BeginPaint(handle, &ps);
DrawCone(handle, hdc);
ValidateRect(handle, NULL);
EndPaint(handle, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(handle, message, wParam, lParam);
}
return 0;
}
//-----------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND handle;
MSG messages;
WNDCLASSEX windowClass;
const char* szClassName = "Win-App";
windowClass.hInstance = hThisInstance;
windowClass.lpszClassName = szClassName;
windowClass.lpfnWndProc = WindowProcedure;
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.lpszMenuName = NULL;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
if (!RegisterClassEx(&windowClass))
{
return 0;
}
handle = CreateWindow(szClassName, "cone", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 300, 300,
NULL, NULL, hThisInstance, NULL);
ShowWindow(handle, nFunsterStil);
UpdateWindow(handle);
while (GetMessage(&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
} |