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
|
#include <Windows.h>
LRESULT CALLBACK WindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpcmdline, int ncmdshow)
{
WNDCLASSEX windowclass;
HWND hWnd;
MSG message;
const char szClassName[] = "Fenster";
windowclass.cbSize = sizeof (WNDCLASSEX);
windowclass.style = CS_HREDRAW | CS_VREDRAW;
windowclass.lpfnWndProc = WindowProc;
windowclass.cbClsExtra = 0;
windowclass.cbWndExtra = 0;
windowclass.hInstance = hInst;
windowclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
windowclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
windowclass.hCursor = LoadCursor (NULL, IDC_ARROW);
windowclass.hbrBackground = (HBRUSH) COLOR_BACKGROUND+1;
windowclass.lpszMenuName = NULL;
windowclass.lpszClassName = szClassName;
if (!RegisterClassEx (&windowclass))
return 0;
hWnd = CreateWindowEx (NULL,szClassName, "Mein erstes Fenster :)", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 300, 250, NULL, NULL, hInst, NULL);
if (hWnd == NULL)
return 0;
while (GetMessage (&message, NULL, 0, 0))
{
TranslateMessage (&message);
DispatchMessage (&message);
}
return (int) (message.wParam);
}
LRESULT CALLBACK WindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DESTROY:
{
PostQuitMessage (0);
return 0;
}
case WM_KEYDOWN:
{
switch (wParam)
{
case VK_ESCAPE:
{
PostQuitMessage (0);
return 0;
}
}
} break;
}
return (DefWindowProc (hWnd, message, wParam, lParam));
}
|