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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
#define HANDLE_NUM (sizeof Controls / sizeof Controls[0])
#include <windows.h>
#include <tchar.h>
struct
{
int iStyle;
TCHAR *szTextName;
TCHAR *szTextDesc;
int x;
int y;
int width;
int height;
}
Controls[] =
{
BS_PUSHBUTTON | WS_TABSTOP,
TEXT ("button"), TEXT ("Start"), 505,310,75,25,
BS_PUSHBUTTON | WS_TABSTOP,
TEXT ("button"), TEXT ("Quit"), 505,340,75,25,
BS_AUTOCHECKBOX | WS_TABSTOP,
TEXT ("button"), TEXT ("Start with default"), 10,340,240,25,
BS_PUSHBUTTON | WS_TABSTOP,
TEXT ("button"), TEXT ("Graphic Settings"), 10,310,160,25,
SS_CENTER,
TEXT ("static"), TEXT ("Select modification"), 260,315,160,25,
CBS_DROPDOWNLIST | WS_TABSTOP,
TEXT ("combobox"), TEXT ("Selection"), 260,335,160,25,
ES_LEFT | ES_MULTILINE | WS_BORDER,
TEXT ("edit"), TEXT ("Info"), 10,10,160,290,
};
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
static const TCHAR szAppName[] = TEXT ("Test");
static const TCHAR szAppDesc[] = TEXT ("Test");
int APIENTRY _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
const int Width = 600;
const int Height = 400;
//Initialisieren des WNDCLASS-Objekts
WNDCLASSEX wndclassex;
//Einstellen des WNDCLASS-Objekts
wndclassex.cbSize = sizeof(WNDCLASSEX);
wndclassex.style = CS_HREDRAW | CS_VREDRAW;
wndclassex.lpfnWndProc = (WNDPROC)WndProc;
wndclassex.cbClsExtra = 0;
wndclassex.cbWndExtra = 0;
wndclassex.hInstance = hInstance;
wndclassex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclassex.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclassex.hbrBackground = (HBRUSH)(5);
wndclassex.lpszMenuName = NULL;
wndclassex.lpszClassName = szAppName;
wndclassex.hIconSm = 0;
//Registrieren der Klasse
RegisterClassEx(&wndclassex);
//Erstellen des Fensters aus der obigen Klassendefinition
hWnd = CreateWindow( szAppName,
szAppDesc,
WS_OVERLAPPED,
0,
0,
Width,
Height,
NULL,
NULL,
hInstance,
NULL);
//Falls Windows-Handle nicht erstellt wurde
if (!hWnd) return 1;
//Anzeigen des Fensters
ShowWindow(hWnd, SW_SHOWNORMAL);
//Zeichnen des Fensters
UpdateWindow(hWnd);
MSG msg = {0};
while (WM_QUIT != msg.message)
{
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HWND hChild[HANDLE_NUM];
switch (message)
{
case WM_CREATE:
for (int i = 0 ; i < HANDLE_NUM ; i++)
{
hChild[i] = CreateWindow( Controls[i].szTextName,
Controls[i].szTextDesc,
WS_CHILD | WS_VISIBLE | Controls[i].iStyle,
Controls[i].x,
Controls[i].y,
Controls[i].width,
Controls[i].height,
hWnd,
(HMENU) i,
((LPCREATESTRUCT) lParam)->hInstance,
NULL);
// Set change font message to all child windows
SendMessage( hChild[i],
WM_SETFONT,
(WPARAM)GetStockObject (10),
MAKELPARAM(FALSE, 0));
}
break;
case WM_COMMAND:
switch((WORD)wParam)
{
case 1:
PostQuitMessage(0);
break;
}
break;
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
|