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
|
// Fenster.cpp
#include <Windows.h>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParm, LPARAM lParm)
{
HDC hdc;
RECT rect;
const char sztext[] = "Ich bin da!";
switch (msg)
{
case WM_MOVE:
{
hdc = GetDC(hwnd);
GetClientRect(hwnd, &rect);
TextOut(hdc, rect.right / 2 - 85, rect.bottom / 2 - 10, sztext, strlen(sztext));
ReleaseDC(hwnd, hdc);
return(0);
} break;
case WM_DESTROY:
{
PostQuitMessage(0);
return(0);
}break;
default:
break;
}
return(DefWindowProc(hwnd, msg, wParm, lParm));
}
int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
const char szClassName[] = "S";
wc.cbSize = sizeof (WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if (!RegisterClassEx (&wc))
{
return 0;
}
if (!(hwnd = CreateWindowEx(NULL,szClassName, "Fenster", WS_OVERLAPPEDWINDOW | WS_VISIBLE,300,300,400,300,NULL,NULL,hinstance,NULL)))
{
return (0);
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while (GetMessage(&Msg,NULL,0,0)==TRUE)
{
if (Msg.message == WM_QUIT)
{
break;
}
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return (0);
}
|