Fix some modules
[reactos.git] / rostests / tests / button2 / buttontst2.c
1 #include <windows.h>
2 #include <stdio.h>
3
4 HFONT tf;
5 LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
6
7 int WINAPI
8 WinMain(HINSTANCE hInstance,
9 HINSTANCE hPrevInstance,
10 LPSTR lpszCmdLine,
11 int nCmdShow)
12 {
13 WNDCLASS wc;
14 MSG msg;
15 HWND hWnd;
16 HWND hbtn[26];
17
18 wc.lpszClassName = "ButtonTest";
19 wc.lpfnWndProc = MainWndProc;
20 wc.style = CS_VREDRAW | CS_HREDRAW;
21 wc.hInstance = hInstance;
22 wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
23 wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
24 wc.hbrBackground = (HBRUSH)GetStockObject(GRAY_BRUSH);
25 wc.lpszMenuName = NULL;
26 wc.cbClsExtra = 0;
27 wc.cbWndExtra = 0;
28 if (RegisterClass(&wc) == 0)
29 {
30 fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
31 GetLastError());
32 return(1);
33 }
34
35 hWnd = CreateWindow("ButtonTest",
36 "Button Test",
37 WS_OVERLAPPEDWINDOW,
38 0,
39 0,
40 CW_USEDEFAULT,
41 CW_USEDEFAULT,
42 NULL,
43 NULL,
44 hInstance,
45 NULL);
46 if (hWnd == NULL)
47 {
48 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
49 GetLastError());
50 return(1);
51 }
52
53 tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
54 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
55 DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
56
57 ShowWindow(hWnd, nCmdShow);
58
59 hbtn[0] = CreateWindow(
60 "BUTTON","BS_DEFPUSHBUTTON",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
61 10, 10, 200, 40, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
62
63 hbtn[1] = CreateWindow(
64 "BUTTON","BS_3STATE",WS_VISIBLE | WS_CHILD | BS_3STATE,
65 10, 60, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
66
67 hbtn[2] = CreateWindow(
68 "BUTTON","BS_AUTO3STATE",WS_VISIBLE | WS_CHILD | BS_AUTO3STATE,
69 10, 90, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
70
71 hbtn[3] = CreateWindow(
72 "BUTTON","BS_AUTOCHECKBOX",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX,
73 10, 120, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
74
75 hbtn[4] = CreateWindow(
76 "BUTTON","BS_AUTORADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
77 10, 150, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
78
79 hbtn[5] = CreateWindow(
80 "BUTTON","BS_CHECKBOX",WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
81 10, 180, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
82
83 hbtn[6] = CreateWindow(
84 "BUTTON","BS_GROUPBOX",WS_VISIBLE | WS_CHILD | BS_GROUPBOX,
85 10, 210, 200, 80, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
86
87 hbtn[7] = CreateWindow(
88 "BUTTON","BS_PUSHBUTTON",WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
89 20, 230, 180, 30, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
90
91 hbtn[8] = CreateWindow(
92 "BUTTON","BS_RADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_RADIOBUTTON,
93 10, 300, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
94
95 hbtn[9] = CreateWindow(
96 "BUTTON","BS_AUTORADIOBUTTON",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON,
97 220, 160, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
98
99 hbtn[10] = CreateWindow(
100 "BUTTON","BS_DEFPUSHBUTTON|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_BOTTOM,
101 220, 10, 250, 40, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
102
103 hbtn[11] = CreateWindow(
104 "BUTTON","BS_DEFPUSHBUTTON|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_LEFT,
105 480, 10, 250, 40, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
106
107 hbtn[12] = CreateWindow(
108 "BUTTON","BS_DEFPUSHBUTTON|BS_RIGHT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON | BS_RIGHT |BS_MULTILINE,
109 740, 10, 150, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
110
111 hbtn[13] = CreateWindow(
112 "BUTTON","BS_AUTORADIOBUTTON|BS_TOP",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_TOP,
113 220, 60, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
114
115 // Other Combinations
116
117 hbtn[14] = CreateWindow(
118 "BUTTON","BS_AUTORADIOBUTTON|BS_BOTTOM|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_BOTTOM | BS_MULTILINE,
119 480, 60, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
120
121 hbtn[15] = CreateWindow(
122 "BUTTON","BS_AUTORADIOBUTTON|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_LEFT,
123 740, 80, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
124
125 hbtn[16] = CreateWindow(
126 "BUTTON","BS_AUTORADIOBUTTON|BS_RIGHT|BS_TOP",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_RIGHT | BS_TOP,
127 220, 130, 200, 20, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
128
129 hbtn[17] = CreateWindow(
130 "BUTTON","BS_AUTORADIOBUTTON|BS_TOP|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTORADIOBUTTON | BS_TOP| BS_MULTILINE,
131 480, 130, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
132
133 hbtn[18] = CreateWindow(
134 "BUTTON","BS_AUTOCHECKBOX|BS_BOTTOM|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_BOTTOM | BS_MULTILINE,
135 740, 130, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
136
137 hbtn[19] = CreateWindow(
138 "BUTTON","BS_AUTOCHECKBOX|BS_TOP|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE,
139 480, 190, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
140
141 hbtn[20] = CreateWindow(
142 "BUTTON","BS_AUTOCHECKBOX|BS_LEFT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_LEFT | BS_MULTILINE,
143 220, 230, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
144
145 hbtn[21] = CreateWindow(
146 "BUTTON","BS_AUTOCHECKBOX|BS_RIGHT|BS_MULTILINE",WS_VISIBLE | WS_CHILD | BS_AUTOCHECKBOX | BS_RIGHT | BS_MULTILINE,
147 480, 240, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
148
149 hbtn[22] = CreateWindow(
150 "BUTTON","BS_GROUPBOX|BS_TOP",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_TOP,
151 10, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
152
153 hbtn[23] = CreateWindow(
154 "BUTTON","BS_GROUPBOX|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_BOTTOM,
155 10, 410, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
156
157 hbtn[24] = CreateWindow(
158 "BUTTON","BS_GROUPBOXBOX|BS_LEFT",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_LEFT,
159 520, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
160
161 hbtn[25] = CreateWindow(
162 "BUTTON","BS_GROUPBOX|BS_RIGHT|BS_BOTTOM",WS_VISIBLE | WS_CHILD | BS_GROUPBOX | BS_BOTTOM | BS_RIGHT,
163 300, 340, 200, 60, hWnd, NULL, (HINSTANCE) GetWindowLongPtr(hWnd, GWL_HINSTANCE),NULL);
164
165 while(GetMessage(&msg, NULL, 0, 0))
166 {
167 TranslateMessage(&msg);
168 DispatchMessage(&msg);
169 }
170
171 DeleteObject(tf);
172
173 return msg.wParam;
174 }
175
176 LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
177 {
178 PAINTSTRUCT ps;
179 HDC hDC;
180
181 switch(msg)
182 {
183 case WM_PAINT:
184 hDC = BeginPaint(hWnd, &ps);
185 SelectObject(hDC, tf);
186 EndPaint(hWnd, &ps);
187 break;
188
189 case WM_DESTROY:
190 PostQuitMessage(0);
191 break;
192
193 case WM_COMMAND:
194 switch(HIWORD(wParam))
195 {
196 case BN_CLICKED:
197 printf("BUTTON CLICKED !\n");
198 break;
199 case BN_DBLCLK:
200 printf("BUTTON DOUBLE-CLICKED !\n");
201 break;
202 case BN_PUSHED:
203 printf("BUTTON PUSHED !\n");
204 break;
205 case BN_PAINT:
206 printf("BUTTON PAINTED !\n");
207 break;
208 case BN_UNPUSHED:
209 printf("BUTTON UNPUSHED !\n");
210 break;
211
212 }
213 break;
214
215 default:
216 return DefWindowProc(hWnd, msg, wParam, lParam);
217 }
218 return 0;
219 }