Fix signed/unsigned comparison warnings.
[wine.git] / dlls / user / tests / win.c
blobd6866bc4046043e080ea9fa24ec8eb71c9f6a77a
1 /*
2 * Unit tests for window handling
4 * Copyright 2002 Bill Medland
5 * Copyright 2002 Alexandre Julliard
6 * Copyright 2003 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /* To get ICON_SMALL2 with the MSVC headers */
24 #define _WIN32_WINNT 0x0501
26 #include <assert.h>
27 #include <stdlib.h>
28 #include <stdarg.h>
29 #include <stdio.h>
31 #include "windef.h"
32 #include "winbase.h"
33 #include "wingdi.h"
34 #include "winuser.h"
36 #include "wine/test.h"
38 #ifndef SPI_GETDESKWALLPAPER
39 #define SPI_GETDESKWALLPAPER 0x0073
40 #endif
42 #define LONG_PTR INT_PTR
43 #define ULONG_PTR UINT_PTR
45 static HWND (WINAPI *pGetAncestor)(HWND,UINT);
46 static BOOL (WINAPI *pGetWindowInfo)(HWND,WINDOWINFO*);
48 static HWND hwndMessage;
49 static HWND hwndMain, hwndMain2;
50 static HHOOK hhook;
52 /* check the values returned by the various parent/owner functions on a given window */
53 static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
54 HWND gw_owner, HWND ga_root, HWND ga_root_owner )
56 HWND res;
58 if (pGetAncestor)
60 res = pGetAncestor( hwnd, GA_PARENT );
61 ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p\n", res, ga_parent );
63 res = (HWND)GetWindowLongA( hwnd, GWL_HWNDPARENT );
64 ok( res == gwl_parent, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res, gwl_parent );
65 res = GetParent( hwnd );
66 ok( res == get_parent, "Wrong result for GetParent %p expected %p\n", res, get_parent );
67 res = GetWindow( hwnd, GW_OWNER );
68 ok( res == gw_owner, "Wrong result for GW_OWNER %p expected %p\n", res, gw_owner );
69 if (pGetAncestor)
71 res = pGetAncestor( hwnd, GA_ROOT );
72 ok( res == ga_root, "Wrong result for GA_ROOT %p expected %p\n", res, ga_root );
73 res = pGetAncestor( hwnd, GA_ROOTOWNER );
74 ok( res == ga_root_owner, "Wrong result for GA_ROOTOWNER %p expected %p\n", res, ga_root_owner );
79 static HWND create_tool_window( LONG style, HWND parent )
81 HWND ret = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style,
82 0, 0, 100, 100, parent, 0, 0, NULL );
83 ok( ret != 0, "Creation failed\n" );
84 return ret;
87 /* test parent and owner values for various combinations */
88 static void test_parent_owner(void)
90 LONG style;
91 HWND test, owner, ret;
92 HWND desktop = GetDesktopWindow();
93 HWND child = create_tool_window( WS_CHILD, hwndMain );
95 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain, hwndMain2, desktop, child );
97 /* child without parent, should fail */
98 test = CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
99 WS_CHILD, 0, 0, 100, 100, 0, 0, 0, NULL );
100 ok( !test, "WS_CHILD without parent created\n" );
102 /* desktop window */
103 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
104 style = GetWindowLongA( desktop, GWL_STYLE );
105 ok( !SetWindowLongA( desktop, GWL_STYLE, WS_POPUP ), "Set GWL_STYLE on desktop succeeded\n" );
106 ok( !SetWindowLongA( desktop, GWL_STYLE, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
107 ok( GetWindowLongA( desktop, GWL_STYLE ) == style, "Desktop style changed\n" );
109 /* normal child window */
110 test = create_tool_window( WS_CHILD, hwndMain );
111 trace( "created child %p\n", test );
112 check_parents( test, hwndMain, hwndMain, hwndMain, 0, hwndMain, hwndMain );
113 SetWindowLongA( test, GWL_STYLE, 0 );
114 check_parents( test, hwndMain, hwndMain, 0, 0, hwndMain, test );
115 SetWindowLongA( test, GWL_STYLE, WS_POPUP );
116 check_parents( test, hwndMain, hwndMain, 0, 0, hwndMain, test );
117 SetWindowLongA( test, GWL_STYLE, WS_POPUP|WS_CHILD );
118 check_parents( test, hwndMain, hwndMain, 0, 0, hwndMain, test );
119 SetWindowLongA( test, GWL_STYLE, WS_CHILD );
120 DestroyWindow( test );
122 /* normal child window with WS_MAXIMIZE */
123 test = create_tool_window( WS_CHILD | WS_MAXIMIZE, hwndMain );
124 DestroyWindow( test );
126 /* normal child window with WS_THICKFRAME */
127 test = create_tool_window( WS_CHILD | WS_THICKFRAME, hwndMain );
128 DestroyWindow( test );
130 /* popup window with WS_THICKFRAME */
131 test = create_tool_window( WS_POPUP | WS_THICKFRAME, hwndMain );
132 DestroyWindow( test );
134 /* child of desktop */
135 test = create_tool_window( WS_CHILD, desktop );
136 trace( "created child of desktop %p\n", test );
137 check_parents( test, desktop, 0, desktop, 0, test, desktop );
138 SetWindowLongA( test, GWL_STYLE, WS_POPUP );
139 check_parents( test, desktop, 0, 0, 0, test, test );
140 SetWindowLongA( test, GWL_STYLE, 0 );
141 check_parents( test, desktop, 0, 0, 0, test, test );
142 DestroyWindow( test );
144 /* child of desktop with WS_MAXIMIZE */
145 test = create_tool_window( WS_CHILD | WS_MAXIMIZE, desktop );
146 DestroyWindow( test );
148 /* child of desktop with WS_MINIMIZE */
149 test = create_tool_window( WS_CHILD | WS_MINIMIZE, desktop );
150 DestroyWindow( test );
152 /* child of child */
153 test = create_tool_window( WS_CHILD, child );
154 trace( "created child of child %p\n", test );
155 check_parents( test, child, child, child, 0, hwndMain, hwndMain );
156 SetWindowLongA( test, GWL_STYLE, 0 );
157 check_parents( test, child, child, 0, 0, hwndMain, test );
158 SetWindowLongA( test, GWL_STYLE, WS_POPUP );
159 check_parents( test, child, child, 0, 0, hwndMain, test );
160 DestroyWindow( test );
162 /* child of child with WS_MAXIMIZE */
163 test = create_tool_window( WS_CHILD | WS_MAXIMIZE, child );
164 DestroyWindow( test );
166 /* child of child with WS_MINIMIZE */
167 test = create_tool_window( WS_CHILD | WS_MINIMIZE, child );
168 DestroyWindow( test );
170 /* not owned top-level window */
171 test = create_tool_window( 0, 0 );
172 trace( "created top-level %p\n", test );
173 check_parents( test, desktop, 0, 0, 0, test, test );
174 SetWindowLongA( test, GWL_STYLE, WS_POPUP );
175 check_parents( test, desktop, 0, 0, 0, test, test );
176 SetWindowLongA( test, GWL_STYLE, WS_CHILD );
177 check_parents( test, desktop, 0, desktop, 0, test, desktop );
178 DestroyWindow( test );
180 /* not owned top-level window with WS_MAXIMIZE */
181 test = create_tool_window( WS_MAXIMIZE, 0 );
182 DestroyWindow( test );
184 /* owned top-level window */
185 test = create_tool_window( 0, hwndMain );
186 trace( "created owned top-level %p\n", test );
187 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
188 SetWindowLongA( test, GWL_STYLE, WS_POPUP );
189 check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
190 SetWindowLongA( test, GWL_STYLE, WS_CHILD );
191 check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
192 DestroyWindow( test );
194 /* owned top-level window with WS_MAXIMIZE */
195 test = create_tool_window( WS_MAXIMIZE, hwndMain );
196 DestroyWindow( test );
198 /* not owned popup */
199 test = create_tool_window( WS_POPUP, 0 );
200 trace( "created popup %p\n", test );
201 check_parents( test, desktop, 0, 0, 0, test, test );
202 SetWindowLongA( test, GWL_STYLE, WS_CHILD );
203 check_parents( test, desktop, 0, desktop, 0, test, desktop );
204 SetWindowLongA( test, GWL_STYLE, 0 );
205 check_parents( test, desktop, 0, 0, 0, test, test );
206 DestroyWindow( test );
208 /* not owned popup with WS_MAXIMIZE */
209 test = create_tool_window( WS_POPUP | WS_MAXIMIZE, 0 );
210 DestroyWindow( test );
212 /* owned popup */
213 test = create_tool_window( WS_POPUP, hwndMain );
214 trace( "created owned popup %p\n", test );
215 check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
216 SetWindowLongA( test, GWL_STYLE, WS_CHILD );
217 check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
218 SetWindowLongA( test, GWL_STYLE, 0 );
219 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
220 DestroyWindow( test );
222 /* owned popup with WS_MAXIMIZE */
223 test = create_tool_window( WS_POPUP | WS_MAXIMIZE, hwndMain );
224 DestroyWindow( test );
226 /* top-level window owned by child (same as owned by top-level) */
227 test = create_tool_window( 0, child );
228 trace( "created top-level owned by child %p\n", test );
229 check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
230 DestroyWindow( test );
232 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
233 test = create_tool_window( WS_MAXIMIZE, child );
234 DestroyWindow( test );
236 /* popup owned by desktop (same as not owned) */
237 test = create_tool_window( WS_POPUP, desktop );
238 trace( "created popup owned by desktop %p\n", test );
239 check_parents( test, desktop, 0, 0, 0, test, test );
240 DestroyWindow( test );
242 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
243 test = create_tool_window( WS_POPUP | WS_MAXIMIZE, desktop );
244 DestroyWindow( test );
246 /* popup owned by child (same as owned by top-level) */
247 test = create_tool_window( WS_POPUP, child );
248 trace( "created popup owned by child %p\n", test );
249 check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
250 DestroyWindow( test );
252 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
253 test = create_tool_window( WS_POPUP | WS_MAXIMIZE, child );
254 DestroyWindow( test );
256 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
257 test = create_tool_window( WS_POPUP | WS_CHILD, 0 );
258 trace( "created WS_CHILD popup %p\n", test );
259 check_parents( test, desktop, 0, 0, 0, test, test );
260 DestroyWindow( test );
262 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
263 test = create_tool_window( WS_POPUP | WS_CHILD | WS_MAXIMIZE, 0 );
264 DestroyWindow( test );
266 /* owned popup with WS_CHILD (same as WS_POPUP only) */
267 test = create_tool_window( WS_POPUP | WS_CHILD, hwndMain );
268 trace( "created owned WS_CHILD popup %p\n", test );
269 check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
270 DestroyWindow( test );
272 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
273 test = create_tool_window( WS_POPUP | WS_CHILD | WS_MAXIMIZE, hwndMain );
274 DestroyWindow( test );
276 /******************** parent changes *************************/
277 trace( "testing parent changes\n" );
279 /* desktop window */
280 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
281 #if 0 /* this test succeeds on NT but crashes on win9x systems */
282 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
283 ok( !ret, "Set GWL_HWNDPARENT succeeded on desktop\n" );
284 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
285 ok( !SetParent( desktop, hwndMain ), "SetParent succeeded on desktop\n" );
286 check_parents( desktop, 0, 0, 0, 0, 0, 0 );
287 #endif
288 /* normal child window */
289 test = create_tool_window( WS_CHILD, hwndMain );
290 trace( "created child %p\n", test );
292 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
293 ok( ret == hwndMain, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain );
294 check_parents( test, hwndMain2, hwndMain2, hwndMain2, 0, hwndMain2, hwndMain2 );
296 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
297 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
298 check_parents( test, child, child, child, 0, hwndMain, hwndMain );
300 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)desktop );
301 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
302 check_parents( test, desktop, 0, desktop, 0, test, desktop );
304 /* window is now child of desktop so GWL_HWNDPARENT changes owner from now on */
305 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
306 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
307 check_parents( test, desktop, child, desktop, child, test, desktop );
309 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 );
310 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
311 check_parents( test, desktop, 0, desktop, 0, test, desktop );
312 DestroyWindow( test );
314 /* not owned top-level window */
315 test = create_tool_window( 0, 0 );
316 trace( "created top-level %p\n", test );
318 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
319 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
320 check_parents( test, desktop, hwndMain2, 0, hwndMain2, test, test );
322 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
323 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
324 check_parents( test, desktop, child, 0, child, test, test );
326 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 );
327 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
328 check_parents( test, desktop, 0, 0, 0, test, test );
329 DestroyWindow( test );
331 /* not owned popup */
332 test = create_tool_window( WS_POPUP, 0 );
333 trace( "created popup %p\n", test );
335 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
336 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
337 check_parents( test, desktop, hwndMain2, hwndMain2, hwndMain2, test, hwndMain2 );
339 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
340 ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
341 check_parents( test, desktop, child, child, child, test, hwndMain );
343 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 );
344 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
345 check_parents( test, desktop, 0, 0, 0, test, test );
346 DestroyWindow( test );
348 /* normal child window */
349 test = create_tool_window( WS_CHILD, hwndMain );
350 trace( "created child %p\n", test );
352 ret = SetParent( test, desktop );
353 ok( ret == hwndMain, "SetParent return value %p expected %p\n", ret, hwndMain );
354 check_parents( test, desktop, 0, desktop, 0, test, desktop );
356 ret = SetParent( test, child );
357 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
358 check_parents( test, child, child, child, 0, hwndMain, hwndMain );
360 ret = SetParent( test, hwndMain2 );
361 ok( ret == child, "SetParent return value %p expected %p\n", ret, child );
362 check_parents( test, hwndMain2, hwndMain2, hwndMain2, 0, hwndMain2, hwndMain2 );
363 DestroyWindow( test );
365 /* not owned top-level window */
366 test = create_tool_window( 0, 0 );
367 trace( "created top-level %p\n", test );
369 ret = SetParent( test, child );
370 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
371 check_parents( test, child, child, 0, 0, hwndMain, test );
372 DestroyWindow( test );
374 /* owned popup */
375 test = create_tool_window( WS_POPUP, hwndMain2 );
376 trace( "created owned popup %p\n", test );
378 ret = SetParent( test, child );
379 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
380 check_parents( test, child, child, hwndMain2, hwndMain2, hwndMain, hwndMain2 );
382 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (ULONG_PTR)hwndMain );
383 ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
384 check_parents( test, hwndMain, hwndMain, hwndMain2, hwndMain2, hwndMain, hwndMain2 );
385 DestroyWindow( test );
387 /**************** test owner destruction *******************/
389 /* owned child popup */
390 owner = create_tool_window( 0, 0 );
391 test = create_tool_window( WS_POPUP, owner );
392 trace( "created owner %p and popup %p\n", owner, test );
393 ret = SetParent( test, child );
394 ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
395 check_parents( test, child, child, owner, owner, hwndMain, owner );
396 /* window is now child of 'child' but owned by 'owner' */
397 DestroyWindow( owner );
398 ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
399 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
400 * while Win95, Win2k, WinXP do.
402 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
403 ok( !IsWindow(owner), "Owner %p not destroyed\n", owner );
404 DestroyWindow(test);
406 /* owned top-level popup */
407 owner = create_tool_window( 0, 0 );
408 test = create_tool_window( WS_POPUP, owner );
409 trace( "created owner %p and popup %p\n", owner, test );
410 check_parents( test, desktop, owner, owner, owner, test, owner );
411 DestroyWindow( owner );
412 ok( !IsWindow(test), "Window %p not destroyed by owner destruction\n", test );
414 /* top-level popup owned by child */
415 owner = create_tool_window( WS_CHILD, hwndMain2 );
416 test = create_tool_window( WS_POPUP, 0 );
417 trace( "created owner %p and popup %p\n", owner, test );
418 ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (ULONG_PTR)owner );
419 ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
420 check_parents( test, desktop, owner, owner, owner, test, hwndMain2 );
421 DestroyWindow( owner );
422 ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
423 ok( !IsWindow(owner), "Owner %p not destroyed\n", owner );
424 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
425 * while Win95, Win2k, WinXP do.
427 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
428 DestroyWindow(test);
430 /* final cleanup */
431 DestroyWindow(child);
435 static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
437 switch (msg)
439 case WM_GETMINMAXINFO:
441 MINMAXINFO* minmax = (MINMAXINFO *)lparam;
443 trace("hwnd %p, WM_GETMINMAXINFO, %08x, %08lx\n", hwnd, wparam, lparam);
444 trace("ptReserved (%ld,%ld), ptMaxSize (%ld,%ld), ptMaxPosition (%ld,%ld)\n"
445 " ptMinTrackSize (%ld,%ld), ptMaxTrackSize (%ld,%ld)\n",
446 minmax->ptReserved.x, minmax->ptReserved.y,
447 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
448 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
449 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
450 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
451 SetWindowLongA(hwnd, GWL_USERDATA, 0x20031021);
452 break;
454 case WM_WINDOWPOSCHANGING:
456 BOOL is_win9x = GetWindowLongW(hwnd, GWL_WNDPROC) == 0;
457 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
458 trace("main: WM_WINDOWPOSCHANGING\n");
459 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
460 winpos->hwnd, winpos->hwndInsertAfter,
461 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
462 if (!(winpos->flags & SWP_NOMOVE))
464 ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
465 ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
467 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
468 if (!(winpos->flags & SWP_NOSIZE) && !is_win9x)
470 ok(winpos->cx >= 0 && winpos->cx <= 32767, "bad winpos->cx %d\n", winpos->cx);
471 ok(winpos->cy >= 0 && winpos->cy <= 32767, "bad winpos->cy %d\n", winpos->cy);
473 break;
475 case WM_WINDOWPOSCHANGED:
477 RECT rc1, rc2;
478 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
479 trace("main: WM_WINDOWPOSCHANGED\n");
480 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
481 winpos->hwnd, winpos->hwndInsertAfter,
482 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
483 ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
484 ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
486 ok(winpos->cx >= 0 && winpos->cx <= 32767, "bad winpos->cx %d\n", winpos->cx);
487 ok(winpos->cy >= 0 && winpos->cy <= 32767, "bad winpos->cy %d\n", winpos->cy);
489 GetWindowRect(hwnd, &rc1);
490 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1.left, rc1.top, rc1.right, rc1.bottom);
491 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
492 /* note: winpos coordinates are relative to parent */
493 MapWindowPoints(GetParent(hwnd), 0, (LPPOINT)&rc2, 2);
494 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2.left, rc2.top, rc2.right, rc2.bottom);
495 #if 0 /* Uncomment this once the test succeeds in all cases */
496 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
497 #endif
499 GetClientRect(hwnd, &rc2);
500 DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc1);
501 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
502 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
503 break;
505 case WM_NCCREATE:
507 BOOL got_getminmaxinfo = GetWindowLongA(hwnd, GWL_USERDATA) == 0x20031021;
508 CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
510 trace("WM_NCCREATE: hwnd %p, parent %p, style %08lx\n", hwnd, cs->hwndParent, cs->style);
511 if (got_getminmaxinfo)
512 trace("%p got WM_GETMINMAXINFO\n", hwnd);
514 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
515 ok(got_getminmaxinfo, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
516 else
517 ok(!got_getminmaxinfo, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
518 break;
522 return DefWindowProcA(hwnd, msg, wparam, lparam);
525 static LRESULT WINAPI tool_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
527 switch (msg)
529 case WM_GETMINMAXINFO:
531 MINMAXINFO* minmax = (MINMAXINFO *)lparam;
533 trace("hwnd %p, WM_GETMINMAXINFO, %08x, %08lx\n", hwnd, wparam, lparam);
534 trace("ptReserved (%ld,%ld), ptMaxSize (%ld,%ld), ptMaxPosition (%ld,%ld)\n"
535 " ptMinTrackSize (%ld,%ld), ptMaxTrackSize (%ld,%ld)\n",
536 minmax->ptReserved.x, minmax->ptReserved.y,
537 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
538 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
539 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
540 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
541 SetWindowLongA(hwnd, GWL_USERDATA, 0x20031021);
542 break;
544 case WM_NCCREATE:
546 BOOL got_getminmaxinfo = GetWindowLongA(hwnd, GWL_USERDATA) == 0x20031021;
547 CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
549 trace("WM_NCCREATE: hwnd %p, parent %p, style %08lx\n", hwnd, cs->hwndParent, cs->style);
550 if (got_getminmaxinfo)
551 trace("%p got WM_GETMINMAXINFO\n", hwnd);
553 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
554 ok(got_getminmaxinfo, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
555 else
556 ok(!got_getminmaxinfo, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
557 break;
561 return DefWindowProcA(hwnd, msg, wparam, lparam);
564 static BOOL RegisterWindowClasses(void)
566 WNDCLASSA cls;
568 cls.style = 0;
569 cls.lpfnWndProc = main_window_procA;
570 cls.cbClsExtra = 0;
571 cls.cbWndExtra = 0;
572 cls.hInstance = GetModuleHandleA(0);
573 cls.hIcon = 0;
574 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
575 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
576 cls.lpszMenuName = NULL;
577 cls.lpszClassName = "MainWindowClass";
579 if(!RegisterClassA(&cls)) return FALSE;
581 cls.style = 0;
582 cls.lpfnWndProc = tool_window_procA;
583 cls.cbClsExtra = 0;
584 cls.cbWndExtra = 0;
585 cls.hInstance = GetModuleHandleA(0);
586 cls.hIcon = 0;
587 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
588 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
589 cls.lpszMenuName = NULL;
590 cls.lpszClassName = "ToolWindowClass";
592 if(!RegisterClassA(&cls)) return FALSE;
594 return TRUE;
597 static void verify_window_info(HWND hwnd, const WINDOWINFO *info, BOOL test_borders)
599 RECT rcWindow, rcClient;
600 UINT border;
601 DWORD status;
603 ok(IsWindow(hwnd), "bad window handle\n");
605 GetWindowRect(hwnd, &rcWindow);
606 ok(EqualRect(&rcWindow, &info->rcWindow), "wrong rcWindow\n");
608 GetClientRect(hwnd, &rcClient);
609 /* translate to screen coordinates */
610 MapWindowPoints(hwnd, 0, (LPPOINT)&rcClient, 2);
611 ok(EqualRect(&rcClient, &info->rcClient), "wrong rcClient\n");
613 ok(info->dwStyle == (DWORD)GetWindowLongA(hwnd, GWL_STYLE), "wrong dwStyle\n");
614 ok(info->dwExStyle == (DWORD)GetWindowLongA(hwnd, GWL_EXSTYLE), "wrong dwExStyle\n");
615 status = (GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0;
616 ok(info->dwWindowStatus == status, "wrong dwWindowStatus\n");
618 if (test_borders && !IsRectEmpty(&rcWindow))
620 trace("rcWindow: %ld,%ld - %ld,%ld\n", rcWindow.left, rcWindow.top, rcWindow.right, rcWindow.bottom);
621 trace("rcClient: %ld,%ld - %ld,%ld\n", rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
623 ok(info->cxWindowBorders == (unsigned)(rcClient.left - rcWindow.left),
624 "wrong cxWindowBorders %d != %ld\n", info->cxWindowBorders, rcClient.left - rcWindow.left);
625 border = min(rcWindow.bottom - rcClient.bottom, rcClient.top - rcWindow.top);
626 ok(info->cyWindowBorders == border,
627 "wrong cyWindowBorders %d != %d\n", info->cyWindowBorders, border);
630 ok(info->atomWindowType == GetClassLongA(hwnd, GCW_ATOM), "wrong atomWindowType\n");
631 ok(info->wCreatorVersion == 0x0400, "wrong wCreatorVersion %04x\n", info->wCreatorVersion);
634 static void test_nonclient_area(HWND hwnd)
636 DWORD style, exstyle;
637 RECT rc_window, rc_client, rc;
638 BOOL menu;
640 style = GetWindowLongA(hwnd, GWL_STYLE);
641 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
642 menu = !(style & WS_CHILD) && GetMenu(hwnd) != 0;
644 GetWindowRect(hwnd, &rc_window);
645 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc_window.left, rc_window.top, rc_window.right, rc_window.bottom);
646 GetClientRect(hwnd, &rc_client);
647 trace("client: (%ld,%ld)-(%ld,%ld)\n", rc_client.left, rc_client.top, rc_client.right, rc_client.bottom);
649 /* avoid some cases when things go wrong */
650 if (IsRectEmpty(&rc_window) || IsRectEmpty(&rc_client) ||
651 rc_window.right > 32768 || rc_window.bottom > 32768) return;
653 CopyRect(&rc, &rc_client);
654 MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
655 AdjustWindowRectEx(&rc, style, menu, exstyle);
656 trace("calc window: (%ld,%ld)-(%ld,%ld)\n", rc.left, rc.top, rc.right, rc.bottom);
657 #if 0 /* Uncomment this once the test succeeds in all cases */
658 ok(EqualRect(&rc, &rc_window), "window rect does not match\n");
659 #endif
661 CopyRect(&rc, &rc_window);
662 DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc);
663 MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
664 trace("calc client: (%ld,%ld)-(%ld,%ld)\n", rc.left, rc.top, rc.right, rc.bottom);
665 #if 0 /* Uncomment this once the test succeeds in all cases */
666 ok(EqualRect(&rc, &rc_client), "client rect does not match\n");
667 #endif
669 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
670 SetRect(&rc_client, 0, 0, 250, 150);
671 CopyRect(&rc_window, &rc_client);
672 MapWindowPoints(hwnd, 0, (LPPOINT)&rc_window, 2);
673 AdjustWindowRectEx(&rc_window, style, menu, exstyle);
674 trace("calc window: (%ld,%ld)-(%ld,%ld)\n",
675 rc_window.left, rc_window.top, rc_window.right, rc_window.bottom);
677 CopyRect(&rc, &rc_window);
678 DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc);
679 MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
680 trace("calc client: (%ld,%ld)-(%ld,%ld)\n", rc.left, rc.top, rc.right, rc.bottom);
681 #if 0 /* Uncomment this once the test succeeds in all cases */
682 ok(EqualRect(&rc, &rc_client), "client rect does not match\n");
683 #endif
686 static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
688 static const char *CBT_code_name[10] = {
689 "HCBT_MOVESIZE",
690 "HCBT_MINMAX",
691 "HCBT_QS",
692 "HCBT_CREATEWND",
693 "HCBT_DESTROYWND",
694 "HCBT_ACTIVATE",
695 "HCBT_CLICKSKIPPED",
696 "HCBT_KEYSKIPPED",
697 "HCBT_SYSCOMMAND",
698 "HCBT_SETFOCUS" };
699 const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
701 trace("CBT: %d (%s), %08x, %08lx\n", nCode, code_name, wParam, lParam);
703 /* on HCBT_DESTROYWND window state is undefined */
704 if (nCode != HCBT_DESTROYWND && wParam)
706 BOOL is_win9x = GetWindowLongW((HWND)wParam, GWL_WNDPROC) == 0;
707 if (is_win9x && nCode == HCBT_CREATEWND)
708 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
709 else
710 test_nonclient_area((HWND)wParam);
712 if (pGetWindowInfo)
714 WINDOWINFO info;
716 /* Win98 actually does check the info.cbSize and doesn't allow
717 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
718 * WinXP do not check it at all.
720 info.cbSize = sizeof(WINDOWINFO);
721 ok(pGetWindowInfo((HWND)wParam, &info), "GetWindowInfo should not fail\n");
722 /* win2k SP4 returns broken border info if GetWindowInfo
723 * is being called from HCBT_DESTROYWND or HCBT_MINMAX hook proc.
725 verify_window_info((HWND)wParam, &info, nCode != HCBT_MINMAX);
729 switch (nCode)
731 case HCBT_CREATEWND:
733 #if 0 /* Uncomment this once the test succeeds in all cases */
734 static const RECT rc_null;
735 RECT rc;
736 #endif
737 LONG style;
738 CBT_CREATEWNDA *createwnd = (CBT_CREATEWNDA *)lParam;
739 trace("HCBT_CREATEWND: hwnd %p, parent %p, style %08lx\n",
740 (HWND)wParam, createwnd->lpcs->hwndParent, createwnd->lpcs->style);
741 ok(createwnd->hwndInsertAfter == HWND_TOP, "hwndInsertAfter should be always HWND_TOP\n");
743 /* WS_VISIBLE should be turned off yet */
744 style = createwnd->lpcs->style & ~WS_VISIBLE;
745 ok(style == GetWindowLongA((HWND)wParam, GWL_STYLE),
746 "style of hwnd and style in the CREATESTRUCT do not match: %08lx != %08lx\n",
747 GetWindowLongA((HWND)wParam, GWL_STYLE), style);
749 #if 0 /* Uncomment this once the test succeeds in all cases */
750 if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
752 ok(GetParent((HWND)wParam) == hwndMessage,
753 "wrong result from GetParent %p: message window %p\n",
754 GetParent((HWND)wParam), hwndMessage);
756 else
757 ok(!GetParent((HWND)wParam), "GetParent should return 0 at this point\n");
759 ok(!GetWindow((HWND)wParam, GW_OWNER), "GW_OWNER should be set to 0 at this point\n");
760 #endif
761 #if 0 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
762 * Win9x still has them set to 0.
764 ok(GetWindow((HWND)wParam, GW_HWNDFIRST) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
765 ok(GetWindow((HWND)wParam, GW_HWNDLAST) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
766 #endif
767 ok(!GetWindow((HWND)wParam, GW_HWNDPREV), "GW_HWNDPREV should be set to 0 at this point\n");
768 ok(!GetWindow((HWND)wParam, GW_HWNDNEXT), "GW_HWNDNEXT should be set to 0 at this point\n");
770 #if 0 /* Uncomment this once the test succeeds in all cases */
771 if (pGetAncestor)
773 ok(pGetAncestor((HWND)wParam, GA_PARENT) == hwndMessage, "GA_PARENT should be set to hwndMessage at this point\n");
774 ok(pGetAncestor((HWND)wParam, GA_ROOT) == (HWND)wParam,
775 "GA_ROOT is set to %p, expected %p\n", pGetAncestor((HWND)wParam, GA_ROOT), (HWND)wParam);
777 if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
778 ok(pGetAncestor((HWND)wParam, GA_ROOTOWNER) == hwndMessage,
779 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
780 else
781 ok(pGetAncestor((HWND)wParam, GA_ROOTOWNER) == (HWND)wParam,
782 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor((HWND)wParam, GA_ROOTOWNER), (HWND)wParam);
785 ok(GetWindowRect((HWND)wParam, &rc), "GetWindowRect failed\n");
786 ok(EqualRect(&rc, &rc_null), "window rect should be set to 0 HCBT_CREATEWND\n");
787 ok(GetClientRect((HWND)wParam, &rc), "GetClientRect failed\n");
788 ok(EqualRect(&rc, &rc_null), "client rect should be set to 0 on HCBT_CREATEWND\n");
789 #endif
790 break;
794 return CallNextHookEx(hhook, nCode, wParam, lParam);
797 static void test_shell_window()
799 BOOL ret;
800 DWORD error;
801 HMODULE hinst, hUser32;
802 BOOL (WINAPI*SetShellWindow)(HWND);
803 BOOL (WINAPI*SetShellWindowEx)(HWND, HWND);
804 HWND hwnd1, hwnd2, hwnd3, hwnd4, hwnd5;
805 HWND shellWindow, nextWnd;
807 shellWindow = GetShellWindow();
808 hinst = GetModuleHandle(0);
809 hUser32 = GetModuleHandleA("user32");
811 SetShellWindow = (void *)GetProcAddress(hUser32, "SetShellWindow");
812 SetShellWindowEx = (void *)GetProcAddress(hUser32, "SetShellWindowEx");
814 trace("previous shell window: %p\n", shellWindow);
816 if (shellWindow) {
817 DWORD pid;
818 HANDLE hProcess;
820 ret = DestroyWindow(shellWindow);
821 error = GetLastError();
823 ok(!ret, "DestroyWindow(shellWindow)\n");
824 /* passes on Win XP, but not on Win98
825 ok(error==ERROR_ACCESS_DENIED, "ERROR_ACCESS_DENIED after DestroyWindow(shellWindow)\n"); */
827 /* close old shell instance */
828 GetWindowThreadProcessId(shellWindow, &pid);
829 hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
830 ret = TerminateProcess(hProcess, 0);
831 ok(ret, "termination of previous shell process failed: GetLastError()=%ld\n", GetLastError());
832 WaitForSingleObject(hProcess, INFINITE); /* wait for termination */
833 CloseHandle(hProcess);
836 hwnd1 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst, 0);
837 trace("created window 1: %p\n", hwnd1);
839 ret = SetShellWindow(hwnd1);
840 ok(ret, "first call to SetShellWindow(hwnd1)\n");
841 shellWindow = GetShellWindow();
842 ok(shellWindow==hwnd1, "wrong shell window: %p\n", shellWindow);
844 ret = SetShellWindow(hwnd1);
845 ok(!ret, "second call to SetShellWindow(hwnd1)\n");
847 ret = SetShellWindow(0);
848 error = GetLastError();
849 /* passes on Win XP, but not on Win98
850 ok(!ret, "reset shell window by SetShellWindow(0)\n");
851 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
853 ret = SetShellWindow(hwnd1);
854 /* passes on Win XP, but not on Win98
855 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
857 todo_wine
859 SetWindowLong(hwnd1, GWL_EXSTYLE, GetWindowLong(hwnd1,GWL_EXSTYLE)|WS_EX_TOPMOST);
860 ret = GetWindowLong(hwnd1,GWL_EXSTYLE)&WS_EX_TOPMOST? TRUE: FALSE;
861 ok(!ret, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
864 ret = DestroyWindow(hwnd1);
865 ok(ret, "DestroyWindow(hwnd1)\n");
867 hwnd2 = CreateWindowEx(WS_EX_TOPMOST, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst, 0);
868 trace("created window 2: %p\n", hwnd2);
869 ret = SetShellWindow(hwnd2);
870 ok(!ret, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
872 hwnd3 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst, 0);
873 trace("created window 3: %p\n", hwnd3);
875 hwnd4 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst, 0);
876 trace("created window 4: %p\n", hwnd4);
878 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
879 ok(nextWnd==hwnd3, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd);
881 ret = SetShellWindow(hwnd4);
882 ok(ret, "SetShellWindow(hwnd4)\n");
883 shellWindow = GetShellWindow();
884 ok(shellWindow==hwnd4, "wrong shell window: %p - expected hwnd4\n", shellWindow);
886 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
887 ok(nextWnd==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd);
889 ret = SetWindowPos(hwnd4, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
890 ok(ret, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
892 ret = SetWindowPos(hwnd4, hwnd3, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
893 ok(ret, "SetWindowPos(hwnd4, hwnd3\n");
895 ret = SetShellWindow(hwnd3);
896 ok(!ret, "SetShellWindow(hwnd3)\n");
897 shellWindow = GetShellWindow();
898 ok(shellWindow==hwnd4, "wrong shell window: %p - expected hwnd4\n", shellWindow);
900 hwnd5 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst, 0);
901 trace("created window 5: %p\n", hwnd5);
902 ret = SetWindowPos(hwnd4, hwnd5, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
903 ok(ret, "SetWindowPos(hwnd4, hwnd5)\n");
905 todo_wine
907 nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
908 ok(nextWnd==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd);
911 /* destroy test windows */
912 DestroyWindow(hwnd2);
913 DestroyWindow(hwnd3);
914 DestroyWindow(hwnd4);
915 DestroyWindow(hwnd5);
918 /************** MDI test ****************/
920 static const char mdi_lParam_test_message[] = "just a test string";
922 static void test_MDI_create(HWND parent, HWND mdi_client)
924 MDICREATESTRUCTA mdi_cs;
925 HWND mdi_child;
926 static const WCHAR classW[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
927 static const WCHAR titleW[] = {'M','D','I',' ','c','h','i','l','d',0};
928 BOOL isWin9x = FALSE;
930 mdi_cs.szClass = "MDI_child_Class_1";
931 mdi_cs.szTitle = "MDI child";
932 mdi_cs.hOwner = GetModuleHandle(0);
933 mdi_cs.x = CW_USEDEFAULT;
934 mdi_cs.y = CW_USEDEFAULT;
935 mdi_cs.cx = CW_USEDEFAULT;
936 mdi_cs.cy = CW_USEDEFAULT;
937 mdi_cs.style = 0;
938 mdi_cs.lParam = (LPARAM)mdi_lParam_test_message;
939 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
940 ok(mdi_child != 0, "MDI child creation failed\n");
941 DestroyWindow(mdi_child);
943 mdi_cs.style = 0x7fffffff; /* without WS_POPUP */
944 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
945 ok(mdi_child != 0, "MDI child creation failed\n");
946 DestroyWindow(mdi_child);
948 mdi_cs.style = 0xffffffff; /* with WS_POPUP */
949 mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
950 if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
952 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
953 DestroyWindow(mdi_child);
955 else
956 ok(mdi_child != 0, "MDI child creation failed\n");
958 /* test MDICREATESTRUCT A<->W mapping */
959 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
960 mdi_cs.style = 0;
961 mdi_cs.szClass = (LPCSTR)classW;
962 mdi_cs.szTitle = (LPCSTR)titleW;
963 SetLastError(0xdeadbeef);
964 mdi_child = (HWND)SendMessageW(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
965 if (!mdi_child)
967 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
968 isWin9x = TRUE;
969 else
970 ok(mdi_child != 0, "MDI child creation failed\n");
972 DestroyWindow(mdi_child);
974 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
976 CW_USEDEFAULT, CW_USEDEFAULT,
977 CW_USEDEFAULT, CW_USEDEFAULT,
978 mdi_client, GetModuleHandle(0),
979 (LPARAM)mdi_lParam_test_message);
980 ok(mdi_child != 0, "MDI child creation failed\n");
981 DestroyWindow(mdi_child);
983 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
984 0x7fffffff, /* without WS_POPUP */
985 CW_USEDEFAULT, CW_USEDEFAULT,
986 CW_USEDEFAULT, CW_USEDEFAULT,
987 mdi_client, GetModuleHandle(0),
988 (LPARAM)mdi_lParam_test_message);
989 ok(mdi_child != 0, "MDI child creation failed\n");
990 DestroyWindow(mdi_child);
992 mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
993 0xffffffff, /* with WS_POPUP */
994 CW_USEDEFAULT, CW_USEDEFAULT,
995 CW_USEDEFAULT, CW_USEDEFAULT,
996 mdi_client, GetModuleHandle(0),
997 (LPARAM)mdi_lParam_test_message);
998 if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
1000 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1001 DestroyWindow(mdi_child);
1003 else
1004 ok(mdi_child != 0, "MDI child creation failed\n");
1006 /* test MDICREATESTRUCT A<->W mapping */
1007 SetLastError(0xdeadbeef);
1008 mdi_child = CreateMDIWindowW(classW, titleW,
1010 CW_USEDEFAULT, CW_USEDEFAULT,
1011 CW_USEDEFAULT, CW_USEDEFAULT,
1012 mdi_client, GetModuleHandle(0),
1013 (LPARAM)mdi_lParam_test_message);
1014 if (!mdi_child)
1016 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
1017 isWin9x = TRUE;
1018 else
1019 ok(mdi_child != 0, "MDI child creation failed\n");
1021 DestroyWindow(mdi_child);
1023 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
1025 CW_USEDEFAULT, CW_USEDEFAULT,
1026 CW_USEDEFAULT, CW_USEDEFAULT,
1027 mdi_client, 0, GetModuleHandle(0),
1028 (LPVOID)mdi_lParam_test_message);
1029 ok(mdi_child != 0, "MDI child creation failed\n");
1030 DestroyWindow(mdi_child);
1032 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
1033 0x7fffffff, /* without WS_POPUP */
1034 CW_USEDEFAULT, CW_USEDEFAULT,
1035 CW_USEDEFAULT, CW_USEDEFAULT,
1036 mdi_client, 0, GetModuleHandle(0),
1037 (LPVOID)mdi_lParam_test_message);
1038 ok(mdi_child != 0, "MDI child creation failed\n");
1039 DestroyWindow(mdi_child);
1041 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
1042 0xffffffff, /* with WS_POPUP */
1043 CW_USEDEFAULT, CW_USEDEFAULT,
1044 CW_USEDEFAULT, CW_USEDEFAULT,
1045 mdi_client, 0, GetModuleHandle(0),
1046 (LPVOID)mdi_lParam_test_message);
1047 if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
1049 ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1050 DestroyWindow(mdi_child);
1052 else
1053 ok(mdi_child != 0, "MDI child creation failed\n");
1055 /* test MDICREATESTRUCT A<->W mapping */
1056 SetLastError(0xdeadbeef);
1057 mdi_child = CreateWindowExW(WS_EX_MDICHILD, classW, titleW,
1059 CW_USEDEFAULT, CW_USEDEFAULT,
1060 CW_USEDEFAULT, CW_USEDEFAULT,
1061 mdi_client, 0, GetModuleHandle(0),
1062 (LPVOID)mdi_lParam_test_message);
1063 if (!mdi_child)
1065 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
1066 isWin9x = TRUE;
1067 else
1068 ok(mdi_child != 0, "MDI child creation failed\n");
1070 DestroyWindow(mdi_child);
1072 /* This test fails on Win9x */
1073 if (!isWin9x)
1075 mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_2", "MDI child",
1076 WS_CHILD,
1077 CW_USEDEFAULT, CW_USEDEFAULT,
1078 CW_USEDEFAULT, CW_USEDEFAULT,
1079 parent, 0, GetModuleHandle(0),
1080 (LPVOID)mdi_lParam_test_message);
1081 ok(!mdi_child, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1084 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1085 WS_CHILD, /* without WS_POPUP */
1086 CW_USEDEFAULT, CW_USEDEFAULT,
1087 CW_USEDEFAULT, CW_USEDEFAULT,
1088 mdi_client, 0, GetModuleHandle(0),
1089 (LPVOID)mdi_lParam_test_message);
1090 ok(mdi_child != 0, "MDI child creation failed\n");
1091 DestroyWindow(mdi_child);
1093 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1094 WS_CHILD | WS_POPUP, /* with WS_POPUP */
1095 CW_USEDEFAULT, CW_USEDEFAULT,
1096 CW_USEDEFAULT, CW_USEDEFAULT,
1097 mdi_client, 0, GetModuleHandle(0),
1098 (LPVOID)mdi_lParam_test_message);
1099 ok(mdi_child != 0, "MDI child creation failed\n");
1100 DestroyWindow(mdi_child);
1102 /* maximized child */
1103 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1104 WS_CHILD | WS_MAXIMIZE,
1105 CW_USEDEFAULT, CW_USEDEFAULT,
1106 CW_USEDEFAULT, CW_USEDEFAULT,
1107 mdi_client, 0, GetModuleHandle(0),
1108 (LPVOID)mdi_lParam_test_message);
1109 ok(mdi_child != 0, "MDI child creation failed\n");
1110 DestroyWindow(mdi_child);
1112 trace("Creating maximized child with a caption\n");
1113 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1114 WS_CHILD | WS_MAXIMIZE | WS_CAPTION,
1115 CW_USEDEFAULT, CW_USEDEFAULT,
1116 CW_USEDEFAULT, CW_USEDEFAULT,
1117 mdi_client, 0, GetModuleHandle(0),
1118 (LPVOID)mdi_lParam_test_message);
1119 ok(mdi_child != 0, "MDI child creation failed\n");
1120 DestroyWindow(mdi_child);
1122 trace("Creating maximized child with a caption and a thick frame\n");
1123 mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1124 WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
1125 CW_USEDEFAULT, CW_USEDEFAULT,
1126 CW_USEDEFAULT, CW_USEDEFAULT,
1127 mdi_client, 0, GetModuleHandle(0),
1128 (LPVOID)mdi_lParam_test_message);
1129 ok(mdi_child != 0, "MDI child creation failed\n");
1130 DestroyWindow(mdi_child);
1133 /**********************************************************************
1134 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1136 * Note: The rule here is that client rect of the maximized MDI child
1137 * is equal to the client rect of the MDI client window.
1139 static void MDI_ChildGetMinMaxInfo( HWND client, HWND hwnd, MINMAXINFO* lpMinMax )
1141 RECT rect;
1143 GetClientRect( client, &rect );
1144 AdjustWindowRectEx( &rect, GetWindowLongA( hwnd, GWL_STYLE ),
1145 0, GetWindowLongA( hwnd, GWL_EXSTYLE ));
1147 rect.right -= rect.left;
1148 rect.bottom -= rect.top;
1149 lpMinMax->ptMaxSize.x = rect.right;
1150 lpMinMax->ptMaxSize.y = rect.bottom;
1152 lpMinMax->ptMaxPosition.x = rect.left;
1153 lpMinMax->ptMaxPosition.y = rect.top;
1155 trace("max rect (%ld,%ld - %ld, %ld)\n",
1156 rect.left, rect.top, rect.right, rect.bottom);
1159 static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
1161 switch (msg)
1163 case WM_NCCREATE:
1164 case WM_CREATE:
1166 CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
1167 MDICREATESTRUCTA *mdi_cs = (MDICREATESTRUCTA *)cs->lpCreateParams;
1169 ok(cs->dwExStyle & WS_EX_MDICHILD, "WS_EX_MDICHILD should be set\n");
1170 ok(mdi_cs->lParam == (LPARAM)mdi_lParam_test_message, "wrong mdi_cs->lParam\n");
1172 ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_1"), "wrong class name\n");
1173 ok(!lstrcmpA(cs->lpszClass, mdi_cs->szClass), "class name does not match\n");
1174 ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
1175 ok(!lstrcmpA(cs->lpszName, mdi_cs->szTitle), "title does not match\n");
1176 ok(cs->hInstance == mdi_cs->hOwner, "%p != %p\n", cs->hInstance, mdi_cs->hOwner);
1178 /* MDICREATESTRUCT should have original values */
1179 ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff,
1180 "mdi_cs->style does not match (%08lx)\n", mdi_cs->style);
1181 ok(mdi_cs->x == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->x);
1182 ok(mdi_cs->y == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->y);
1183 ok(mdi_cs->cx == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cx);
1184 ok(mdi_cs->cy == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cy);
1186 /* CREATESTRUCT should have fixed values */
1187 ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);
1188 ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
1190 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1191 ok(cs->cx != CW_USEDEFAULT && cs->cx != 0, "%d == CW_USEDEFAULT\n", cs->cx);
1192 ok(cs->cy != CW_USEDEFAULT && cs->cy != 0, "%d == CW_USEDEFAULT\n", cs->cy);
1194 ok(!(cs->style & WS_POPUP), "WS_POPUP is not allowed\n");
1196 if (GetWindowLongA(cs->hwndParent, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
1198 LONG style = mdi_cs->style | WS_CHILD | WS_CLIPSIBLINGS;
1199 ok(cs->style == style,
1200 "cs->style does not match (%08lx)\n", cs->style);
1202 else
1204 LONG style = mdi_cs->style;
1205 style &= ~WS_POPUP;
1206 style |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION |
1207 WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
1208 ok(cs->style == style,
1209 "cs->style does not match (%08lx)\n", cs->style);
1211 break;
1214 case WM_GETMINMAXINFO:
1216 HWND client = GetParent(hwnd);
1217 RECT rc;
1218 MINMAXINFO *minmax = (MINMAXINFO *)lparam;
1219 MINMAXINFO my_minmax;
1220 LONG style, exstyle;
1222 style = GetWindowLongA(hwnd, GWL_STYLE);
1223 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
1225 GetWindowRect(client, &rc);
1226 trace("MDI client %p window size = (%ld x %ld)\n", client, rc.right-rc.left, rc.bottom-rc.top);
1227 GetClientRect(client, &rc);
1228 trace("MDI client %p client size = (%ld x %ld)\n", client, rc.right, rc.bottom);
1229 trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN),
1230 GetSystemMetrics(SM_CYSCREEN));
1232 GetClientRect(client, &rc);
1233 if ((style & WS_CAPTION) == WS_CAPTION)
1234 style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1235 AdjustWindowRectEx(&rc, style, 0, exstyle);
1236 trace("MDI child: calculated max window size = (%ld x %ld)\n", rc.right-rc.left, rc.bottom-rc.top);
1238 trace("ptReserved = (%ld,%ld)\n"
1239 "ptMaxSize = (%ld,%ld)\n"
1240 "ptMaxPosition = (%ld,%ld)\n"
1241 "ptMinTrackSize = (%ld,%ld)\n"
1242 "ptMaxTrackSize = (%ld,%ld)\n",
1243 minmax->ptReserved.x, minmax->ptReserved.y,
1244 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
1245 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
1246 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
1247 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
1249 ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %ld != %ld\n",
1250 minmax->ptMaxSize.x, rc.right - rc.left);
1251 ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %ld != %ld\n",
1252 minmax->ptMaxSize.y, rc.bottom - rc.top);
1254 DefMDIChildProcA(hwnd, msg, wparam, lparam);
1256 trace("DefMDIChildProc returned:\n"
1257 "ptReserved = (%ld,%ld)\n"
1258 "ptMaxSize = (%ld,%ld)\n"
1259 "ptMaxPosition = (%ld,%ld)\n"
1260 "ptMinTrackSize = (%ld,%ld)\n"
1261 "ptMaxTrackSize = (%ld,%ld)\n",
1262 minmax->ptReserved.x, minmax->ptReserved.y,
1263 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
1264 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
1265 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
1266 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
1268 MDI_ChildGetMinMaxInfo(client, hwnd, &my_minmax);
1269 ok(minmax->ptMaxSize.x == my_minmax.ptMaxSize.x, "default width of maximized child %ld != %ld\n",
1270 minmax->ptMaxSize.x, my_minmax.ptMaxSize.x);
1271 ok(minmax->ptMaxSize.y == my_minmax.ptMaxSize.y, "default height of maximized child %ld != %ld\n",
1272 minmax->ptMaxSize.y, my_minmax.ptMaxSize.y);
1274 return 1;
1277 return DefMDIChildProcA(hwnd, msg, wparam, lparam);
1280 static LRESULT WINAPI mdi_child_wnd_proc_2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
1282 switch (msg)
1284 case WM_NCCREATE:
1285 case WM_CREATE:
1287 CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
1289 trace("%s\n", (msg == WM_NCCREATE) ? "WM_NCCREATE" : "WM_CREATE");
1290 trace("x %d, y %d, cx %d, cy %d\n", cs->x, cs->y, cs->cx, cs->cy);
1292 ok(!(cs->dwExStyle & WS_EX_MDICHILD), "WS_EX_MDICHILD should not be set\n");
1293 ok(cs->lpCreateParams == mdi_lParam_test_message, "wrong cs->lpCreateParams\n");
1295 ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_2"), "wrong class name\n");
1296 ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
1298 /* CREATESTRUCT should have fixed values */
1299 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1300 while NT does. */
1301 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1302 ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
1304 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1305 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1306 while Win95, Win2k, WinXP do. */
1307 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1308 ok(cs->cy == 0, "%d != 0\n", cs->cy);
1309 break;
1312 case WM_GETMINMAXINFO:
1314 HWND parent = GetParent(hwnd);
1315 RECT rc;
1316 MINMAXINFO *minmax = (MINMAXINFO *)lparam;
1317 LONG style, exstyle;
1319 trace("WM_GETMINMAXINFO\n");
1321 style = GetWindowLongA(hwnd, GWL_STYLE);
1322 exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
1324 GetClientRect(parent, &rc);
1325 trace("parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
1327 GetClientRect(parent, &rc);
1328 if ((style & WS_CAPTION) == WS_CAPTION)
1329 style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1330 AdjustWindowRectEx(&rc, style, 0, exstyle);
1331 trace("calculated max child window size = (%ld x %ld)\n", rc.right-rc.left, rc.bottom-rc.top);
1333 trace("ptReserved = (%ld,%ld)\n"
1334 "ptMaxSize = (%ld,%ld)\n"
1335 "ptMaxPosition = (%ld,%ld)\n"
1336 "ptMinTrackSize = (%ld,%ld)\n"
1337 "ptMaxTrackSize = (%ld,%ld)\n",
1338 minmax->ptReserved.x, minmax->ptReserved.y,
1339 minmax->ptMaxSize.x, minmax->ptMaxSize.y,
1340 minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
1341 minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
1342 minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
1344 ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %ld != %ld\n",
1345 minmax->ptMaxSize.x, rc.right - rc.left);
1346 ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %ld != %ld\n",
1347 minmax->ptMaxSize.y, rc.bottom - rc.top);
1348 break;
1351 case WM_WINDOWPOSCHANGED:
1353 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1354 RECT rc1, rc2;
1356 GetWindowRect(hwnd, &rc1);
1357 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1.left, rc1.top, rc1.right, rc1.bottom);
1358 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
1359 /* note: winpos coordinates are relative to parent */
1360 MapWindowPoints(GetParent(hwnd), 0, (LPPOINT)&rc2, 2);
1361 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2.left, rc2.top, rc2.right, rc2.bottom);
1362 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
1364 GetWindowRect(hwnd, &rc1);
1365 GetClientRect(hwnd, &rc2);
1366 DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc1);
1367 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
1368 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
1370 /* fall through */
1371 case WM_WINDOWPOSCHANGING:
1373 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1374 WINDOWPOS my_winpos = *winpos;
1376 trace("%s\n", (msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1377 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1378 winpos->hwnd, winpos->hwndInsertAfter,
1379 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
1381 DefWindowProcA(hwnd, msg, wparam, lparam);
1383 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1384 winpos->hwnd, winpos->hwndInsertAfter,
1385 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
1387 ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
1388 "DefWindowProc should not change WINDOWPOS values\n");
1390 return 1;
1393 return DefWindowProcA(hwnd, msg, wparam, lparam);
1396 static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
1398 static HWND mdi_client;
1400 switch (msg)
1402 case WM_CREATE:
1404 CLIENTCREATESTRUCT client_cs;
1405 RECT rc;
1407 GetClientRect(hwnd, &rc);
1409 client_cs.hWindowMenu = 0;
1410 client_cs.idFirstChild = 1;
1412 /* MDIClient without MDIS_ALLCHILDSTYLES */
1413 mdi_client = CreateWindowExA(0, "mdiclient",
1414 NULL,
1415 WS_CHILD /*| WS_VISIBLE*/,
1416 /* tests depend on a not zero MDIClient size */
1417 0, 0, rc.right, rc.bottom,
1418 hwnd, 0, GetModuleHandle(0),
1419 (LPVOID)&client_cs);
1420 assert(mdi_client);
1421 test_MDI_create(hwnd, mdi_client);
1422 DestroyWindow(mdi_client);
1424 /* MDIClient with MDIS_ALLCHILDSTYLES */
1425 mdi_client = CreateWindowExA(0, "mdiclient",
1426 NULL,
1427 WS_CHILD | MDIS_ALLCHILDSTYLES /*| WS_VISIBLE*/,
1428 /* tests depend on a not zero MDIClient size */
1429 0, 0, rc.right, rc.bottom,
1430 hwnd, 0, GetModuleHandle(0),
1431 (LPVOID)&client_cs);
1432 assert(mdi_client);
1433 test_MDI_create(hwnd, mdi_client);
1434 DestroyWindow(mdi_client);
1435 break;
1438 case WM_WINDOWPOSCHANGED:
1440 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1441 RECT rc1, rc2;
1443 GetWindowRect(hwnd, &rc1);
1444 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1.left, rc1.top, rc1.right, rc1.bottom);
1445 SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
1446 /* note: winpos coordinates are relative to parent */
1447 MapWindowPoints(GetParent(hwnd), 0, (LPPOINT)&rc2, 2);
1448 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2.left, rc2.top, rc2.right, rc2.bottom);
1449 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
1451 GetWindowRect(hwnd, &rc1);
1452 GetClientRect(hwnd, &rc2);
1453 DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc1);
1454 MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
1455 ok(EqualRect(&rc1, &rc2), "rects do not match\n");
1457 /* fall through */
1458 case WM_WINDOWPOSCHANGING:
1460 WINDOWPOS *winpos = (WINDOWPOS *)lparam;
1461 WINDOWPOS my_winpos = *winpos;
1463 trace("%s\n", (msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1464 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1465 winpos->hwnd, winpos->hwndInsertAfter,
1466 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
1468 DefWindowProcA(hwnd, msg, wparam, lparam);
1470 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1471 winpos->hwnd, winpos->hwndInsertAfter,
1472 winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
1474 ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
1475 "DefWindowProc should not change WINDOWPOS values\n");
1477 return 1;
1480 case WM_CLOSE:
1481 PostQuitMessage(0);
1482 break;
1484 return DefFrameProcA(hwnd, mdi_client, msg, wparam, lparam);
1487 static BOOL mdi_RegisterWindowClasses(void)
1489 WNDCLASSA cls;
1491 cls.style = 0;
1492 cls.lpfnWndProc = mdi_main_wnd_procA;
1493 cls.cbClsExtra = 0;
1494 cls.cbWndExtra = 0;
1495 cls.hInstance = GetModuleHandleA(0);
1496 cls.hIcon = 0;
1497 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
1498 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
1499 cls.lpszMenuName = NULL;
1500 cls.lpszClassName = "MDI_parent_Class";
1501 if(!RegisterClassA(&cls)) return FALSE;
1503 cls.lpfnWndProc = mdi_child_wnd_proc_1;
1504 cls.lpszClassName = "MDI_child_Class_1";
1505 if(!RegisterClassA(&cls)) return FALSE;
1507 cls.lpfnWndProc = mdi_child_wnd_proc_2;
1508 cls.lpszClassName = "MDI_child_Class_2";
1509 if(!RegisterClassA(&cls)) return FALSE;
1511 return TRUE;
1514 static void test_mdi(void)
1516 HWND mdi_hwndMain;
1517 /*MSG msg;*/
1519 if (!mdi_RegisterWindowClasses()) assert(0);
1521 mdi_hwndMain = CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
1522 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
1523 WS_MAXIMIZEBOX /*| WS_VISIBLE*/,
1524 100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
1525 GetDesktopWindow(), 0,
1526 GetModuleHandle(0), NULL);
1527 assert(mdi_hwndMain);
1529 while(GetMessage(&msg, 0, 0, 0))
1531 TranslateMessage(&msg);
1532 DispatchMessage(&msg);
1537 static void test_icons(void)
1539 WNDCLASSEXA cls;
1540 HWND hwnd;
1541 HICON icon = LoadIconA(0, (LPSTR)IDI_APPLICATION);
1542 HICON icon2 = LoadIconA(0, (LPSTR)IDI_QUESTION);
1543 HICON small_icon = LoadImageA(0, (LPSTR)IDI_APPLICATION, IMAGE_ICON,
1544 GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED );
1545 HICON res;
1547 cls.cbSize = sizeof(cls);
1548 cls.style = 0;
1549 cls.lpfnWndProc = DefWindowProcA;
1550 cls.cbClsExtra = 0;
1551 cls.cbWndExtra = 0;
1552 cls.hInstance = 0;
1553 cls.hIcon = LoadIconA(0, (LPSTR)IDI_HAND);
1554 cls.hIconSm = small_icon;
1555 cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
1556 cls.hbrBackground = GetStockObject(WHITE_BRUSH);
1557 cls.lpszMenuName = NULL;
1558 cls.lpszClassName = "IconWindowClass";
1560 RegisterClassExA(&cls);
1562 hwnd = CreateWindowExA(0, "IconWindowClass", "icon test", 0,
1563 100, 100, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL);
1564 assert( hwnd );
1566 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
1567 ok( res == 0, "wrong big icon %p/0\n", res );
1568 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon );
1569 ok( res == 0, "wrong previous big icon %p/0\n", res );
1570 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
1571 ok( res == icon, "wrong big icon after set %p/%p\n", res, icon );
1572 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon2 );
1573 ok( res == icon, "wrong previous big icon %p/%p\n", res, icon );
1574 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
1575 ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
1577 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
1578 ok( res == 0, "wrong small icon %p/0\n", res );
1579 /* this test is XP specific */
1580 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1581 ok( res != 0, "wrong small icon %p\n", res );*/
1582 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon );
1583 ok( res == 0, "wrong previous small icon %p/0\n", res );
1584 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
1585 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );
1586 /* this test is XP specific */
1587 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1588 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
1589 res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)small_icon );
1590 ok( res == icon, "wrong previous small icon %p/%p\n", res, icon );
1591 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
1592 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );
1593 /* this test is XP specific */
1594 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1595 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
1597 /* make sure the big icon hasn't changed */
1598 res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
1599 ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
1602 static void test_SetWindowPos(HWND hwnd)
1604 BOOL is_win9x = GetWindowLongW(hwnd, GWL_WNDPROC) == 0;
1606 /* Win9x truncates coordinates to 16-bit irrespectively */
1607 if (is_win9x) return;
1609 SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE);
1610 SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE);
1612 SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE);
1613 SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE);
1616 static void test_SetMenu(HWND parent)
1618 HWND child;
1619 HMENU hMenu, ret;
1620 BOOL is_win9x = GetWindowLongW(parent, GWL_WNDPROC) == 0;
1622 hMenu = CreateMenu();
1623 assert(hMenu);
1625 ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
1626 test_nonclient_area(parent);
1627 ret = GetMenu(parent);
1628 ok(ret == hMenu, "unexpected menu id %p\n", ret);
1629 /* test whether we can destroy a menu assigned to a window */
1630 ok(DestroyMenu(hMenu), "DestroyMenu error %ld\n", GetLastError());
1631 ok(!IsMenu(hMenu), "menu handle should be not valid after DestroyMenu\n");
1632 ret = GetMenu(parent);
1633 /* This test fails on Win9x */
1634 if (!is_win9x)
1635 ok(ret == hMenu, "unexpected menu id %p\n", ret);
1636 ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
1637 test_nonclient_area(parent);
1639 hMenu = CreateMenu();
1640 assert(hMenu);
1642 /* parent */
1643 ret = GetMenu(parent);
1644 ok(ret == 0, "unexpected menu id %p\n", ret);
1646 ok(!SetMenu(parent, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
1647 test_nonclient_area(parent);
1648 ret = GetMenu(parent);
1649 ok(ret == 0, "unexpected menu id %p\n", ret);
1651 ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
1652 test_nonclient_area(parent);
1653 ret = GetMenu(parent);
1654 ok(ret == hMenu, "unexpected menu id %p\n", ret);
1656 ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
1657 test_nonclient_area(parent);
1658 ret = GetMenu(parent);
1659 ok(ret == 0, "unexpected menu id %p\n", ret);
1661 /* child */
1662 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, parent, (HMENU)10, 0, NULL);
1663 assert(child);
1665 ret = GetMenu(child);
1666 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
1668 ok(!SetMenu(child, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
1669 test_nonclient_area(child);
1670 ret = GetMenu(child);
1671 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
1673 ok(!SetMenu(child, hMenu), "SetMenu on a child window should fail\n");
1674 test_nonclient_area(child);
1675 ret = GetMenu(child);
1676 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
1678 ok(!SetMenu(child, 0), "SetMenu(0) on a child window should fail\n");
1679 test_nonclient_area(child);
1680 ret = GetMenu(child);
1681 ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
1683 DestroyWindow(child);
1684 DestroyMenu(hMenu);
1687 static void test_window_tree(HWND parent, const DWORD *style, const int *order, int total)
1689 HWND child[5], hwnd;
1690 int i;
1692 assert(total <= 5);
1694 hwnd = GetWindow(parent, GW_CHILD);
1695 ok(!hwnd, "have to start without children to perform the test\n");
1697 for (i = 0; i < total; i++)
1699 child[i] = CreateWindowExA(0, "static", "", style[i], 0,0,10,10,
1700 parent, 0, 0, NULL);
1701 trace("child[%d] = %p\n", i, child[i]);
1702 ok(child[i] != 0, "CreateWindowEx failed to create child window\n");
1705 hwnd = GetWindow(parent, GW_CHILD);
1706 ok(hwnd != 0, "GetWindow(GW_CHILD) failed\n");
1707 ok(hwnd == GetWindow(child[total - 1], GW_HWNDFIRST), "GW_HWNDFIRST is wrong\n");
1708 ok(child[order[total - 1]] == GetWindow(child[0], GW_HWNDLAST), "GW_HWNDLAST is wrong\n");
1710 for (i = 0; i < total; i++)
1712 trace("hwnd[%d] = %p\n", i, hwnd);
1713 ok(child[order[i]] == hwnd, "Z order of child #%d is wrong\n", i);
1715 hwnd = GetWindow(hwnd, GW_HWNDNEXT);
1718 for (i = 0; i < total; i++)
1719 ok(DestroyWindow(child[i]), "DestroyWindow failed\n");
1722 static void test_children_zorder(HWND parent)
1724 const DWORD simple_style[5] = { WS_CHILD, WS_CHILD, WS_CHILD, WS_CHILD,
1725 WS_CHILD };
1726 const int simple_order[5] = { 0, 1, 2, 3, 4 };
1728 const DWORD complex_style[5] = { WS_CHILD, WS_CHILD | WS_MAXIMIZE,
1729 WS_CHILD | WS_VISIBLE, WS_CHILD,
1730 WS_CHILD | WS_MAXIMIZE | WS_VISIBLE };
1731 const int complex_order_1[1] = { 0 };
1732 const int complex_order_2[2] = { 1, 0 };
1733 const int complex_order_3[3] = { 1, 0, 2 };
1734 const int complex_order_4[4] = { 1, 0, 2, 3 };
1735 const int complex_order_5[5] = { 4, 1, 0, 2, 3 };
1737 /* simple WS_CHILD */
1738 test_window_tree(parent, simple_style, simple_order, 5);
1740 /* complex children styles */
1741 test_window_tree(parent, complex_style, complex_order_1, 1);
1742 test_window_tree(parent, complex_style, complex_order_2, 2);
1743 test_window_tree(parent, complex_style, complex_order_3, 3);
1744 test_window_tree(parent, complex_style, complex_order_4, 4);
1745 test_window_tree(parent, complex_style, complex_order_5, 5);
1748 static void test_SetFocus(HWND hwnd)
1750 HWND child;
1752 /* check if we can set focus to non-visible windows */
1754 ShowWindow(hwnd, SW_SHOW);
1755 SetFocus(0);
1756 SetFocus(hwnd);
1757 ok( GetFocus() == hwnd, "Failed to set focus to visible window %p\n", hwnd );
1758 ok( GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE, "Window %p not visible\n", hwnd );
1759 ShowWindow(hwnd, SW_HIDE);
1760 SetFocus(0);
1761 SetFocus(hwnd);
1762 ok( GetFocus() == hwnd, "Failed to set focus to invisible window %p\n", hwnd );
1763 ok( !(GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE), "Window %p still visible\n", hwnd );
1764 child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, NULL);
1765 assert(child);
1766 SetFocus(child);
1767 ok( GetFocus() == child, "Failed to set focus to invisible child %p\n", child );
1768 ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
1769 ShowWindow(child, SW_SHOW);
1770 ok( GetWindowLong(child,GWL_STYLE) & WS_VISIBLE, "Child %p is not visible\n", child );
1771 ok( GetFocus() == child, "Focus no longer on child %p\n", child );
1772 ShowWindow(child, SW_HIDE);
1773 ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
1774 ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
1775 ShowWindow(child, SW_SHOW);
1776 SetFocus(child);
1777 ok( GetFocus() == child, "Focus should be on child %p\n", child );
1778 SetWindowPos(child,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW);
1779 ok( GetFocus() == child, "Focus should still be on child %p\n", child );
1781 ShowWindow(child, SW_HIDE);
1782 SetFocus(hwnd);
1783 ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
1784 SetWindowPos(child,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
1785 ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
1786 ShowWindow(child, SW_HIDE);
1787 ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
1789 ShowWindow(hwnd, SW_SHOW);
1790 ShowWindow(child, SW_SHOW);
1791 SetFocus(child);
1792 ok( GetFocus() == child, "Focus should be on child %p\n", child );
1793 EnableWindow(hwnd, FALSE);
1794 ok( GetFocus() == child, "Focus should still be on child %p\n", child );
1795 EnableWindow(hwnd, TRUE);
1797 DestroyWindow( child );
1800 static void test_SetActiveWindow(HWND hwnd)
1802 HWND hwnd2;
1804 ShowWindow(hwnd, SW_SHOW);
1805 SetActiveWindow(0);
1806 SetActiveWindow(hwnd);
1807 ok( GetActiveWindow() == hwnd, "Failed to set focus to visible window %p\n", hwnd );
1808 SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW);
1809 ok( GetActiveWindow() == hwnd, "Window %p no longer active\n", hwnd );
1810 SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
1811 ShowWindow(hwnd, SW_HIDE);
1812 ok( GetActiveWindow() != hwnd, "Window %p is still active\n", hwnd );
1813 ShowWindow(hwnd, SW_SHOW);
1815 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
1816 ok( GetActiveWindow() == hwnd2, "Window %p is not active\n", hwnd2 );
1817 DestroyWindow(hwnd2);
1818 ok( GetActiveWindow() != hwnd2, "Window %p is still active\n", hwnd2 );
1820 hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
1821 ok( GetActiveWindow() == hwnd2, "Window %p is not active\n", hwnd2 );
1822 SetWindowPos(hwnd2,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW);
1823 ok( GetActiveWindow() == hwnd2, "Window %p no longer active (%p)\n", hwnd2, GetActiveWindow() );
1824 DestroyWindow(hwnd2);
1825 ok( GetActiveWindow() != hwnd2, "Window %p is still active\n", hwnd2 );
1828 START_TEST(win)
1830 pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
1831 pGetWindowInfo = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetWindowInfo" );
1833 hwndMain = CreateWindowExA(0, "static", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, 0, NULL);
1834 if (hwndMain)
1836 ok(!GetParent(hwndMain), "GetParent should return 0 for message only windows\n");
1837 if (pGetAncestor)
1839 hwndMessage = pGetAncestor(hwndMain, GA_PARENT);
1840 ok(hwndMessage != 0, "GetAncestor(GA_PARENT) should not return 0 for message only windows\n");
1841 trace("hwndMessage %p\n", hwndMessage);
1843 DestroyWindow(hwndMain);
1845 else
1846 trace("CreateWindowExA with parent HWND_MESSAGE failed\n");
1848 if (!RegisterWindowClasses()) assert(0);
1850 hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
1851 assert(hhook);
1853 hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
1854 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
1855 WS_MAXIMIZEBOX | WS_POPUP,
1856 100, 100, 200, 200,
1857 0, 0, 0, NULL);
1858 hwndMain2 = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
1859 WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
1860 WS_MAXIMIZEBOX | WS_POPUP,
1861 100, 100, 200, 200,
1862 0, 0, 0, NULL);
1863 assert( hwndMain );
1864 assert( hwndMain2 );
1866 test_parent_owner();
1867 test_shell_window();
1869 test_mdi();
1870 test_icons();
1871 test_SetWindowPos(hwndMain);
1872 test_SetMenu(hwndMain);
1873 test_SetFocus(hwndMain);
1874 test_SetActiveWindow(hwndMain);
1876 test_children_zorder(hwndMain);
1878 UnhookWindowsHookEx(hhook);