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 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
39 #include "wine/test.h"
41 #ifndef SPI_GETDESKWALLPAPER
42 #define SPI_GETDESKWALLPAPER 0x0073
45 #define LONG_PTR INT_PTR
46 #define ULONG_PTR UINT_PTR
48 void dump_region(HRGN hrgn
);
50 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
51 static BOOL (WINAPI
*pGetWindowInfo
)(HWND
,WINDOWINFO
*);
53 static BOOL test_lbuttondown_flag
;
54 static HWND hwndMessage
;
55 static HWND hwndMain
, hwndMain2
;
58 /* check the values returned by the various parent/owner functions on a given window */
59 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
60 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
66 res
= pGetAncestor( hwnd
, GA_PARENT
);
67 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
69 res
= (HWND
)GetWindowLongA( hwnd
, GWL_HWNDPARENT
);
70 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
71 res
= GetParent( hwnd
);
72 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
73 res
= GetWindow( hwnd
, GW_OWNER
);
74 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
77 res
= pGetAncestor( hwnd
, GA_ROOT
);
78 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
79 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
80 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
85 static HWND
create_tool_window( LONG style
, HWND parent
)
87 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
88 0, 0, 100, 100, parent
, 0, 0, NULL
);
89 ok( ret
!= 0, "Creation failed\n" );
93 /* test parent and owner values for various combinations */
94 static void test_parent_owner(void)
97 HWND test
, owner
, ret
;
98 HWND desktop
= GetDesktopWindow();
99 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
101 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
103 /* child without parent, should fail */
104 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
105 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
106 ok( !test
, "WS_CHILD without parent created\n" );
109 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
110 style
= GetWindowLongA( desktop
, GWL_STYLE
);
111 ok( !SetWindowLongA( desktop
, GWL_STYLE
, WS_POPUP
), "Set GWL_STYLE on desktop succeeded\n" );
112 ok( !SetWindowLongA( desktop
, GWL_STYLE
, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
113 ok( GetWindowLongA( desktop
, GWL_STYLE
) == style
, "Desktop style changed\n" );
115 /* normal child window */
116 test
= create_tool_window( WS_CHILD
, hwndMain
);
117 trace( "created child %p\n", test
);
118 check_parents( test
, hwndMain
, hwndMain
, hwndMain
, 0, hwndMain
, hwndMain
);
119 SetWindowLongA( test
, GWL_STYLE
, 0 );
120 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
121 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
122 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
123 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
124 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
125 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
126 DestroyWindow( test
);
128 /* normal child window with WS_MAXIMIZE */
129 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
130 DestroyWindow( test
);
132 /* normal child window with WS_THICKFRAME */
133 test
= create_tool_window( WS_CHILD
| WS_THICKFRAME
, hwndMain
);
134 DestroyWindow( test
);
136 /* popup window with WS_THICKFRAME */
137 test
= create_tool_window( WS_POPUP
| WS_THICKFRAME
, hwndMain
);
138 DestroyWindow( test
);
140 /* child of desktop */
141 test
= create_tool_window( WS_CHILD
, desktop
);
142 trace( "created child of desktop %p\n", test
);
143 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
144 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
145 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
146 SetWindowLongA( test
, GWL_STYLE
, 0 );
147 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
148 DestroyWindow( test
);
150 /* child of desktop with WS_MAXIMIZE */
151 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, desktop
);
152 DestroyWindow( test
);
154 /* child of desktop with WS_MINIMIZE */
155 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, desktop
);
156 DestroyWindow( test
);
159 test
= create_tool_window( WS_CHILD
, child
);
160 trace( "created child of child %p\n", test
);
161 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
162 SetWindowLongA( test
, GWL_STYLE
, 0 );
163 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
164 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
165 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
166 DestroyWindow( test
);
168 /* child of child with WS_MAXIMIZE */
169 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, child
);
170 DestroyWindow( test
);
172 /* child of child with WS_MINIMIZE */
173 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, child
);
174 DestroyWindow( test
);
176 /* not owned top-level window */
177 test
= create_tool_window( 0, 0 );
178 trace( "created top-level %p\n", test
);
179 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
180 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
181 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
182 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
183 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
184 DestroyWindow( test
);
186 /* not owned top-level window with WS_MAXIMIZE */
187 test
= create_tool_window( WS_MAXIMIZE
, 0 );
188 DestroyWindow( test
);
190 /* owned top-level window */
191 test
= create_tool_window( 0, hwndMain
);
192 trace( "created owned top-level %p\n", test
);
193 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
194 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
195 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
196 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
197 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
198 DestroyWindow( test
);
200 /* owned top-level window with WS_MAXIMIZE */
201 test
= create_tool_window( WS_MAXIMIZE
, hwndMain
);
202 DestroyWindow( test
);
204 /* not owned popup */
205 test
= create_tool_window( WS_POPUP
, 0 );
206 trace( "created popup %p\n", test
);
207 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
208 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
209 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
210 SetWindowLongA( test
, GWL_STYLE
, 0 );
211 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
212 DestroyWindow( test
);
214 /* not owned popup with WS_MAXIMIZE */
215 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, 0 );
216 DestroyWindow( test
);
219 test
= create_tool_window( WS_POPUP
, hwndMain
);
220 trace( "created owned popup %p\n", test
);
221 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
222 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
223 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
224 SetWindowLongA( test
, GWL_STYLE
, 0 );
225 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
226 DestroyWindow( test
);
228 /* owned popup with WS_MAXIMIZE */
229 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, hwndMain
);
230 DestroyWindow( test
);
232 /* top-level window owned by child (same as owned by top-level) */
233 test
= create_tool_window( 0, child
);
234 trace( "created top-level owned by child %p\n", test
);
235 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
236 DestroyWindow( test
);
238 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
239 test
= create_tool_window( WS_MAXIMIZE
, child
);
240 DestroyWindow( test
);
242 /* popup owned by desktop (same as not owned) */
243 test
= create_tool_window( WS_POPUP
, desktop
);
244 trace( "created popup owned by desktop %p\n", test
);
245 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
246 DestroyWindow( test
);
248 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
249 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, desktop
);
250 DestroyWindow( test
);
252 /* popup owned by child (same as owned by top-level) */
253 test
= create_tool_window( WS_POPUP
, child
);
254 trace( "created popup owned by child %p\n", test
);
255 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
256 DestroyWindow( test
);
258 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
259 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, child
);
260 DestroyWindow( test
);
262 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
263 test
= create_tool_window( WS_POPUP
| WS_CHILD
, 0 );
264 trace( "created WS_CHILD popup %p\n", test
);
265 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
266 DestroyWindow( test
);
268 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
269 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, 0 );
270 DestroyWindow( test
);
272 /* owned popup with WS_CHILD (same as WS_POPUP only) */
273 test
= create_tool_window( WS_POPUP
| WS_CHILD
, hwndMain
);
274 trace( "created owned WS_CHILD popup %p\n", test
);
275 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
276 DestroyWindow( test
);
278 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
279 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
280 DestroyWindow( test
);
282 /******************** parent changes *************************/
283 trace( "testing parent changes\n" );
286 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
287 #if 0 /* this test succeeds on NT but crashes on win9x systems */
288 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
289 ok( !ret
, "Set GWL_HWNDPARENT succeeded on desktop\n" );
290 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
291 ok( !SetParent( desktop
, hwndMain
), "SetParent succeeded on desktop\n" );
292 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
294 /* normal child window */
295 test
= create_tool_window( WS_CHILD
, hwndMain
);
296 trace( "created child %p\n", test
);
298 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
299 ok( ret
== hwndMain
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain
);
300 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
302 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)child
);
303 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
304 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
306 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)desktop
);
307 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
308 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
310 /* window is now child of desktop so GWL_HWNDPARENT changes owner from now on */
311 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)child
);
312 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
313 check_parents( test
, desktop
, child
, desktop
, child
, test
, desktop
);
315 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, 0 );
316 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
317 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
318 DestroyWindow( test
);
320 /* not owned top-level window */
321 test
= create_tool_window( 0, 0 );
322 trace( "created top-level %p\n", test
);
324 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
325 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
326 check_parents( test
, desktop
, hwndMain2
, 0, hwndMain2
, test
, test
);
328 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)child
);
329 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
330 check_parents( test
, desktop
, child
, 0, child
, test
, test
);
332 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, 0 );
333 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
334 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
335 DestroyWindow( test
);
337 /* not owned popup */
338 test
= create_tool_window( WS_POPUP
, 0 );
339 trace( "created popup %p\n", test
);
341 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
342 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
343 check_parents( test
, desktop
, hwndMain2
, hwndMain2
, hwndMain2
, test
, hwndMain2
);
345 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)child
);
346 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
347 check_parents( test
, desktop
, child
, child
, child
, test
, hwndMain
);
349 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, 0 );
350 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
351 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
352 DestroyWindow( test
);
354 /* normal child window */
355 test
= create_tool_window( WS_CHILD
, hwndMain
);
356 trace( "created child %p\n", test
);
358 ret
= SetParent( test
, desktop
);
359 ok( ret
== hwndMain
, "SetParent return value %p expected %p\n", ret
, hwndMain
);
360 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
362 ret
= SetParent( test
, child
);
363 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
364 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
366 ret
= SetParent( test
, hwndMain2
);
367 ok( ret
== child
, "SetParent return value %p expected %p\n", ret
, child
);
368 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
369 DestroyWindow( test
);
371 /* not owned top-level window */
372 test
= create_tool_window( 0, 0 );
373 trace( "created top-level %p\n", test
);
375 ret
= SetParent( test
, child
);
376 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
377 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
378 DestroyWindow( test
);
381 test
= create_tool_window( WS_POPUP
, hwndMain2
);
382 trace( "created owned popup %p\n", test
);
384 ret
= SetParent( test
, child
);
385 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
386 check_parents( test
, child
, child
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
388 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (ULONG_PTR
)hwndMain
);
389 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
390 check_parents( test
, hwndMain
, hwndMain
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
391 DestroyWindow( test
);
393 /**************** test owner destruction *******************/
395 /* owned child popup */
396 owner
= create_tool_window( 0, 0 );
397 test
= create_tool_window( WS_POPUP
, owner
);
398 trace( "created owner %p and popup %p\n", owner
, test
);
399 ret
= SetParent( test
, child
);
400 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
401 check_parents( test
, child
, child
, owner
, owner
, hwndMain
, owner
);
402 /* window is now child of 'child' but owned by 'owner' */
403 DestroyWindow( owner
);
404 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
405 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
406 * while Win95, Win2k, WinXP do.
408 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
409 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
412 /* owned top-level popup */
413 owner
= create_tool_window( 0, 0 );
414 test
= create_tool_window( WS_POPUP
, owner
);
415 trace( "created owner %p and popup %p\n", owner
, test
);
416 check_parents( test
, desktop
, owner
, owner
, owner
, test
, owner
);
417 DestroyWindow( owner
);
418 ok( !IsWindow(test
), "Window %p not destroyed by owner destruction\n", test
);
420 /* top-level popup owned by child */
421 owner
= create_tool_window( WS_CHILD
, hwndMain2
);
422 test
= create_tool_window( WS_POPUP
, 0 );
423 trace( "created owner %p and popup %p\n", owner
, test
);
424 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (ULONG_PTR
)owner
);
425 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
426 check_parents( test
, desktop
, owner
, owner
, owner
, test
, hwndMain2
);
427 DestroyWindow( owner
);
428 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
429 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
430 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
431 * while Win95, Win2k, WinXP do.
433 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
437 DestroyWindow(child
);
441 static LRESULT WINAPI
main_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
445 case WM_GETMINMAXINFO
:
447 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
449 trace("hwnd %p, WM_GETMINMAXINFO, %08x, %08lx\n", hwnd
, wparam
, lparam
);
450 trace("ptReserved (%ld,%ld), ptMaxSize (%ld,%ld), ptMaxPosition (%ld,%ld)\n"
451 " ptMinTrackSize (%ld,%ld), ptMaxTrackSize (%ld,%ld)\n",
452 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
453 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
454 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
455 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
456 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
457 SetWindowLongA(hwnd
, GWL_USERDATA
, 0x20031021);
460 case WM_WINDOWPOSCHANGING
:
462 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
463 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
464 trace("main: WM_WINDOWPOSCHANGING\n");
465 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
466 winpos
->hwnd
, winpos
->hwndInsertAfter
,
467 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
468 if (!(winpos
->flags
& SWP_NOMOVE
))
470 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
471 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
473 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
474 if (!(winpos
->flags
& SWP_NOSIZE
) && !is_win9x
)
476 ok(winpos
->cx
>= 0 && winpos
->cx
<= 32767, "bad winpos->cx %d\n", winpos
->cx
);
477 ok(winpos
->cy
>= 0 && winpos
->cy
<= 32767, "bad winpos->cy %d\n", winpos
->cy
);
481 case WM_WINDOWPOSCHANGED
:
484 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
485 trace("main: WM_WINDOWPOSCHANGED\n");
486 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
487 winpos
->hwnd
, winpos
->hwndInsertAfter
,
488 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
489 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
490 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
492 ok(winpos
->cx
>= 0 && winpos
->cx
<= 32767, "bad winpos->cx %d\n", winpos
->cx
);
493 ok(winpos
->cy
>= 0 && winpos
->cy
<= 32767, "bad winpos->cy %d\n", winpos
->cy
);
495 GetWindowRect(hwnd
, &rc1
);
496 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
497 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
498 /* note: winpos coordinates are relative to parent */
499 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
500 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
501 #if 0 /* Uncomment this once the test succeeds in all cases */
502 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
505 GetClientRect(hwnd
, &rc2
);
506 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
507 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
508 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%ld,%ld-%ld,%ld) / (%ld,%ld-%ld,%ld)\n",
509 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
514 BOOL got_getminmaxinfo
= GetWindowLongA(hwnd
, GWL_USERDATA
) == 0x20031021;
515 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
517 trace("WM_NCCREATE: hwnd %p, parent %p, style %08lx\n", hwnd
, cs
->hwndParent
, cs
->style
);
518 if (got_getminmaxinfo
)
519 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
521 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
522 ok(got_getminmaxinfo
, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
524 ok(!got_getminmaxinfo
, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
528 if (test_lbuttondown_flag
)
529 ShowWindow((HWND
)wparam
, SW_SHOW
);
533 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
536 static LRESULT WINAPI
tool_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
540 case WM_GETMINMAXINFO
:
542 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
544 trace("hwnd %p, WM_GETMINMAXINFO, %08x, %08lx\n", hwnd
, wparam
, lparam
);
545 trace("ptReserved (%ld,%ld), ptMaxSize (%ld,%ld), ptMaxPosition (%ld,%ld)\n"
546 " ptMinTrackSize (%ld,%ld), ptMaxTrackSize (%ld,%ld)\n",
547 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
548 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
549 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
550 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
551 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
552 SetWindowLongA(hwnd
, GWL_USERDATA
, 0x20031021);
557 BOOL got_getminmaxinfo
= GetWindowLongA(hwnd
, GWL_USERDATA
) == 0x20031021;
558 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
560 trace("WM_NCCREATE: hwnd %p, parent %p, style %08lx\n", hwnd
, cs
->hwndParent
, cs
->style
);
561 if (got_getminmaxinfo
)
562 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
564 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
565 ok(got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
567 ok(!got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
572 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
575 static BOOL
RegisterWindowClasses(void)
579 cls
.style
= CS_DBLCLKS
;
580 cls
.lpfnWndProc
= main_window_procA
;
583 cls
.hInstance
= GetModuleHandleA(0);
585 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
586 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
587 cls
.lpszMenuName
= NULL
;
588 cls
.lpszClassName
= "MainWindowClass";
590 if(!RegisterClassA(&cls
)) return FALSE
;
593 cls
.lpfnWndProc
= tool_window_procA
;
596 cls
.hInstance
= GetModuleHandleA(0);
598 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
599 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
600 cls
.lpszMenuName
= NULL
;
601 cls
.lpszClassName
= "ToolWindowClass";
603 if(!RegisterClassA(&cls
)) return FALSE
;
608 static void verify_window_info(HWND hwnd
, const WINDOWINFO
*info
, BOOL test_borders
)
610 RECT rcWindow
, rcClient
;
614 ok(IsWindow(hwnd
), "bad window handle\n");
616 GetWindowRect(hwnd
, &rcWindow
);
617 ok(EqualRect(&rcWindow
, &info
->rcWindow
), "wrong rcWindow\n");
619 GetClientRect(hwnd
, &rcClient
);
620 /* translate to screen coordinates */
621 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rcClient
, 2);
622 ok(EqualRect(&rcClient
, &info
->rcClient
), "wrong rcClient\n");
624 ok(info
->dwStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_STYLE
),
625 "wrong dwStyle: %08lx != %08lx\n", info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
));
626 ok(info
->dwExStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
627 "wrong dwExStyle: %08lx != %08lx\n", info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
));
628 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
629 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04lx != %04lx\n",
630 info
->dwWindowStatus
, status
);
632 if (test_borders
&& !IsRectEmpty(&rcWindow
))
634 trace("rcWindow: %ld,%ld - %ld,%ld\n", rcWindow
.left
, rcWindow
.top
, rcWindow
.right
, rcWindow
.bottom
);
635 trace("rcClient: %ld,%ld - %ld,%ld\n", rcClient
.left
, rcClient
.top
, rcClient
.right
, rcClient
.bottom
);
637 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
638 "wrong cxWindowBorders %d != %ld\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
639 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
640 ok(info
->cyWindowBorders
== border
,
641 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
644 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType\n");
645 ok(info
->wCreatorVersion
== 0x0400, "wrong wCreatorVersion %04x\n", info
->wCreatorVersion
);
648 static void test_nonclient_area(HWND hwnd
)
650 DWORD style
, exstyle
;
651 RECT rc_window
, rc_client
, rc
;
654 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
655 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
656 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
658 GetWindowRect(hwnd
, &rc_window
);
659 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
660 GetClientRect(hwnd
, &rc_client
);
661 trace("client: (%ld,%ld)-(%ld,%ld)\n", rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
);
663 /* avoid some cases when things go wrong */
664 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
665 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
667 CopyRect(&rc
, &rc_client
);
668 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
669 AdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
670 trace("calc window: (%ld,%ld)-(%ld,%ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
671 #if 0 /* Uncomment this once the test succeeds in all cases */
672 ok(EqualRect(&rc
, &rc_window
), "window rect does not match\n");
675 CopyRect(&rc
, &rc_window
);
676 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
677 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
678 trace("calc client: (%ld,%ld)-(%ld,%ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
679 #if 0 /* Uncomment this once the test succeeds in all cases */
680 ok(EqualRect(&rc
, &rc_client
), "client rect does not match\n");
683 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
684 SetRect(&rc_client
, 0, 0, 250, 150);
685 CopyRect(&rc_window
, &rc_client
);
686 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
687 AdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
688 trace("calc window: (%ld,%ld)-(%ld,%ld)\n",
689 rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
691 CopyRect(&rc
, &rc_window
);
692 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
693 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
694 trace("calc client: (%ld,%ld)-(%ld,%ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
695 #if 0 /* Uncomment this once the test succeeds in all cases */
696 ok(EqualRect(&rc
, &rc_client
), "client rect does not match\n");
700 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
702 static const char *CBT_code_name
[10] = {
713 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
715 trace("CBT: %d (%s), %08x, %08lx\n", nCode
, code_name
, wParam
, lParam
);
717 /* on HCBT_DESTROYWND window state is undefined */
718 if (nCode
!= HCBT_DESTROYWND
&& IsWindow((HWND
)wParam
))
720 BOOL is_win9x
= GetWindowLongPtrW((HWND
)wParam
, GWLP_WNDPROC
) == 0;
721 if (is_win9x
&& nCode
== HCBT_CREATEWND
)
722 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
724 test_nonclient_area((HWND
)wParam
);
730 /* Win98 actually does check the info.cbSize and doesn't allow
731 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
732 * WinXP do not check it at all.
734 info
.cbSize
= sizeof(WINDOWINFO
);
735 ok(pGetWindowInfo((HWND
)wParam
, &info
), "GetWindowInfo should not fail\n");
736 /* win2k SP4 returns broken border info if GetWindowInfo
737 * is being called from HCBT_DESTROYWND or HCBT_MINMAX hook proc.
739 verify_window_info((HWND
)wParam
, &info
, nCode
!= HCBT_MINMAX
);
747 #if 0 /* Uncomment this once the test succeeds in all cases */
748 static const RECT rc_null
;
752 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
753 trace("HCBT_CREATEWND: hwnd %p, parent %p, style %08lx\n",
754 (HWND
)wParam
, createwnd
->lpcs
->hwndParent
, createwnd
->lpcs
->style
);
755 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
757 /* WS_VISIBLE should be turned off yet */
758 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
759 ok(style
== GetWindowLongA((HWND
)wParam
, GWL_STYLE
),
760 "style of hwnd and style in the CREATESTRUCT do not match: %08lx != %08lx\n",
761 GetWindowLongA((HWND
)wParam
, GWL_STYLE
), style
);
763 #if 0 /* Uncomment this once the test succeeds in all cases */
764 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
766 ok(GetParent((HWND
)wParam
) == hwndMessage
,
767 "wrong result from GetParent %p: message window %p\n",
768 GetParent((HWND
)wParam
), hwndMessage
);
771 ok(!GetParent((HWND
)wParam
), "GetParent should return 0 at this point\n");
773 ok(!GetWindow((HWND
)wParam
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
775 #if 0 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
776 * Win9x still has them set to 0.
778 ok(GetWindow((HWND
)wParam
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
779 ok(GetWindow((HWND
)wParam
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
781 ok(!GetWindow((HWND
)wParam
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
782 ok(!GetWindow((HWND
)wParam
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
784 #if 0 /* Uncomment this once the test succeeds in all cases */
787 ok(pGetAncestor((HWND
)wParam
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
788 ok(pGetAncestor((HWND
)wParam
, GA_ROOT
) == (HWND
)wParam
,
789 "GA_ROOT is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOT
), (HWND
)wParam
);
791 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
792 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == hwndMessage
,
793 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
795 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == (HWND
)wParam
,
796 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
), (HWND
)wParam
);
799 ok(GetWindowRect((HWND
)wParam
, &rc
), "GetWindowRect failed\n");
800 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
801 ok(GetClientRect((HWND
)wParam
, &rc
), "GetClientRect failed\n");
802 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
808 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
811 static void test_shell_window(void)
815 HMODULE hinst
, hUser32
;
816 BOOL (WINAPI
*SetShellWindow
)(HWND
);
817 BOOL (WINAPI
*SetShellWindowEx
)(HWND
, HWND
);
818 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
819 HWND shellWindow
, nextWnd
;
821 if (!GetWindowLongW(GetDesktopWindow(), GWL_STYLE
))
823 trace("Skipping shell window test on Win9x\n");
827 shellWindow
= GetShellWindow();
828 hinst
= GetModuleHandle(0);
829 hUser32
= GetModuleHandleA("user32");
831 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
832 SetShellWindowEx
= (void *)GetProcAddress(hUser32
, "SetShellWindowEx");
834 trace("previous shell window: %p\n", shellWindow
);
840 ret
= DestroyWindow(shellWindow
);
841 error
= GetLastError();
843 ok(!ret
, "DestroyWindow(shellWindow)\n");
844 /* passes on Win XP, but not on Win98 */
845 ok(error
==ERROR_ACCESS_DENIED
, "ERROR_ACCESS_DENIED after DestroyWindow(shellWindow)\n");
847 /* close old shell instance */
848 GetWindowThreadProcessId(shellWindow
, &pid
);
849 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
850 ret
= TerminateProcess(hProcess
, 0);
851 ok(ret
, "termination of previous shell process failed: GetLastError()=%ld\n", GetLastError());
852 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
853 CloseHandle(hProcess
);
856 hwnd1
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
857 trace("created window 1: %p\n", hwnd1
);
859 ret
= SetShellWindow(hwnd1
);
860 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
861 shellWindow
= GetShellWindow();
862 ok(shellWindow
==hwnd1
, "wrong shell window: %p\n", shellWindow
);
864 ret
= SetShellWindow(hwnd1
);
865 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
867 ret
= SetShellWindow(0);
868 error
= GetLastError();
869 /* passes on Win XP, but not on Win98
870 ok(!ret, "reset shell window by SetShellWindow(0)\n");
871 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
873 ret
= SetShellWindow(hwnd1
);
874 /* passes on Win XP, but not on Win98
875 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
879 SetWindowLong(hwnd1
, GWL_EXSTYLE
, GetWindowLong(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
880 ret
= GetWindowLong(hwnd1
,GWL_EXSTYLE
)&WS_EX_TOPMOST
? TRUE
: FALSE
;
881 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
884 ret
= DestroyWindow(hwnd1
);
885 ok(ret
, "DestroyWindow(hwnd1)\n");
887 hwnd2
= CreateWindowEx(WS_EX_TOPMOST
, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
888 trace("created window 2: %p\n", hwnd2
);
889 ret
= SetShellWindow(hwnd2
);
890 ok(!ret
, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
892 hwnd3
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
893 trace("created window 3: %p\n", hwnd3
);
895 hwnd4
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
896 trace("created window 4: %p\n", hwnd4
);
898 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
899 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd
);
901 ret
= SetShellWindow(hwnd4
);
902 ok(ret
, "SetShellWindow(hwnd4)\n");
903 shellWindow
= GetShellWindow();
904 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
906 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
907 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
909 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
910 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
912 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
913 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
915 ret
= SetShellWindow(hwnd3
);
916 ok(!ret
, "SetShellWindow(hwnd3)\n");
917 shellWindow
= GetShellWindow();
918 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
920 hwnd5
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
921 trace("created window 5: %p\n", hwnd5
);
922 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
923 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
927 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
928 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
931 /* destroy test windows */
932 DestroyWindow(hwnd2
);
933 DestroyWindow(hwnd3
);
934 DestroyWindow(hwnd4
);
935 DestroyWindow(hwnd5
);
938 /************** MDI test ****************/
940 static const char mdi_lParam_test_message
[] = "just a test string";
942 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT first_id
)
944 MDICREATESTRUCTA mdi_cs
;
946 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
947 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
948 BOOL isWin9x
= FALSE
;
950 mdi_cs
.szClass
= "MDI_child_Class_1";
951 mdi_cs
.szTitle
= "MDI child";
952 mdi_cs
.hOwner
= GetModuleHandle(0);
953 mdi_cs
.x
= CW_USEDEFAULT
;
954 mdi_cs
.y
= CW_USEDEFAULT
;
955 mdi_cs
.cx
= CW_USEDEFAULT
;
956 mdi_cs
.cy
= CW_USEDEFAULT
;
958 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
959 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
960 ok(mdi_child
!= 0, "MDI child creation failed\n");
961 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
962 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
963 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
965 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
966 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
967 ok(mdi_child
!= 0, "MDI child creation failed\n");
968 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
969 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
970 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
972 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
973 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
974 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
976 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
980 ok(mdi_child
!= 0, "MDI child creation failed\n");
981 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
982 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
983 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
986 /* test MDICREATESTRUCT A<->W mapping */
987 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
989 mdi_cs
.szClass
= (LPCSTR
)classW
;
990 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
991 SetLastError(0xdeadbeef);
992 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
995 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
998 ok(mdi_child
!= 0, "MDI child creation failed\n");
1002 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1003 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1004 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1007 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1009 CW_USEDEFAULT
, CW_USEDEFAULT
,
1010 CW_USEDEFAULT
, CW_USEDEFAULT
,
1011 mdi_client
, GetModuleHandle(0),
1012 (LPARAM
)mdi_lParam_test_message
);
1013 ok(mdi_child
!= 0, "MDI child creation failed\n");
1014 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1015 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1016 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1018 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1019 0x7fffffff, /* without WS_POPUP */
1020 CW_USEDEFAULT
, CW_USEDEFAULT
,
1021 CW_USEDEFAULT
, CW_USEDEFAULT
,
1022 mdi_client
, GetModuleHandle(0),
1023 (LPARAM
)mdi_lParam_test_message
);
1024 ok(mdi_child
!= 0, "MDI child creation failed\n");
1025 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1026 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1027 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1029 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1030 0xffffffff, /* with WS_POPUP */
1031 CW_USEDEFAULT
, CW_USEDEFAULT
,
1032 CW_USEDEFAULT
, CW_USEDEFAULT
,
1033 mdi_client
, GetModuleHandle(0),
1034 (LPARAM
)mdi_lParam_test_message
);
1035 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1037 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1041 ok(mdi_child
!= 0, "MDI child creation failed\n");
1042 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1043 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1044 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1047 /* test MDICREATESTRUCT A<->W mapping */
1048 SetLastError(0xdeadbeef);
1049 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1051 CW_USEDEFAULT
, CW_USEDEFAULT
,
1052 CW_USEDEFAULT
, CW_USEDEFAULT
,
1053 mdi_client
, GetModuleHandle(0),
1054 (LPARAM
)mdi_lParam_test_message
);
1057 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1060 ok(mdi_child
!= 0, "MDI child creation failed\n");
1064 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1065 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1066 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1069 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1071 CW_USEDEFAULT
, CW_USEDEFAULT
,
1072 CW_USEDEFAULT
, CW_USEDEFAULT
,
1073 mdi_client
, 0, GetModuleHandle(0),
1074 (LPVOID
)mdi_lParam_test_message
);
1075 ok(mdi_child
!= 0, "MDI child creation failed\n");
1076 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1077 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1078 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1080 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1081 0x7fffffff, /* without WS_POPUP */
1082 CW_USEDEFAULT
, CW_USEDEFAULT
,
1083 CW_USEDEFAULT
, CW_USEDEFAULT
,
1084 mdi_client
, 0, GetModuleHandle(0),
1085 (LPVOID
)mdi_lParam_test_message
);
1086 ok(mdi_child
!= 0, "MDI child creation failed\n");
1087 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1088 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1089 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1091 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1092 0xffffffff, /* with WS_POPUP */
1093 CW_USEDEFAULT
, CW_USEDEFAULT
,
1094 CW_USEDEFAULT
, CW_USEDEFAULT
,
1095 mdi_client
, 0, GetModuleHandle(0),
1096 (LPVOID
)mdi_lParam_test_message
);
1097 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1099 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1103 ok(mdi_child
!= 0, "MDI child creation failed\n");
1104 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1105 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1106 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1109 /* test MDICREATESTRUCT A<->W mapping */
1110 SetLastError(0xdeadbeef);
1111 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1113 CW_USEDEFAULT
, CW_USEDEFAULT
,
1114 CW_USEDEFAULT
, CW_USEDEFAULT
,
1115 mdi_client
, 0, GetModuleHandle(0),
1116 (LPVOID
)mdi_lParam_test_message
);
1119 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1122 ok(mdi_child
!= 0, "MDI child creation failed\n");
1126 ok(GetWindowLongA(mdi_child
, GWL_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1127 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1128 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1131 /* This test fails on Win9x */
1134 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1136 CW_USEDEFAULT
, CW_USEDEFAULT
,
1137 CW_USEDEFAULT
, CW_USEDEFAULT
,
1138 parent
, 0, GetModuleHandle(0),
1139 (LPVOID
)mdi_lParam_test_message
);
1140 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1143 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1144 WS_CHILD
, /* without WS_POPUP */
1145 CW_USEDEFAULT
, CW_USEDEFAULT
,
1146 CW_USEDEFAULT
, CW_USEDEFAULT
,
1147 mdi_client
, 0, GetModuleHandle(0),
1148 (LPVOID
)mdi_lParam_test_message
);
1149 ok(mdi_child
!= 0, "MDI child creation failed\n");
1150 ok(GetWindowLongA(mdi_child
, GWL_ID
) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1151 DestroyWindow(mdi_child
);
1153 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1154 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1155 CW_USEDEFAULT
, CW_USEDEFAULT
,
1156 CW_USEDEFAULT
, CW_USEDEFAULT
,
1157 mdi_client
, 0, GetModuleHandle(0),
1158 (LPVOID
)mdi_lParam_test_message
);
1159 ok(mdi_child
!= 0, "MDI child creation failed\n");
1160 ok(GetWindowLongA(mdi_child
, GWL_ID
) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1161 DestroyWindow(mdi_child
);
1163 /* maximized child */
1164 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1165 WS_CHILD
| WS_MAXIMIZE
,
1166 CW_USEDEFAULT
, CW_USEDEFAULT
,
1167 CW_USEDEFAULT
, CW_USEDEFAULT
,
1168 mdi_client
, 0, GetModuleHandle(0),
1169 (LPVOID
)mdi_lParam_test_message
);
1170 ok(mdi_child
!= 0, "MDI child creation failed\n");
1171 ok(GetWindowLongA(mdi_child
, GWL_ID
) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1172 DestroyWindow(mdi_child
);
1174 trace("Creating maximized child with a caption\n");
1175 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1176 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1177 CW_USEDEFAULT
, CW_USEDEFAULT
,
1178 CW_USEDEFAULT
, CW_USEDEFAULT
,
1179 mdi_client
, 0, GetModuleHandle(0),
1180 (LPVOID
)mdi_lParam_test_message
);
1181 ok(mdi_child
!= 0, "MDI child creation failed\n");
1182 ok(GetWindowLongA(mdi_child
, GWL_ID
) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1183 DestroyWindow(mdi_child
);
1185 trace("Creating maximized child with a caption and a thick frame\n");
1186 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1187 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1188 CW_USEDEFAULT
, CW_USEDEFAULT
,
1189 CW_USEDEFAULT
, CW_USEDEFAULT
,
1190 mdi_client
, 0, GetModuleHandle(0),
1191 (LPVOID
)mdi_lParam_test_message
);
1192 ok(mdi_child
!= 0, "MDI child creation failed\n");
1193 ok(GetWindowLongA(mdi_child
, GWL_ID
) == 0, "wrong child id %ld\n", GetWindowLongA(mdi_child
, GWL_ID
));
1194 DestroyWindow(mdi_child
);
1197 /**********************************************************************
1198 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1200 * Note: The rule here is that client rect of the maximized MDI child
1201 * is equal to the client rect of the MDI client window.
1203 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1207 GetClientRect( client
, &rect
);
1208 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1209 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1211 rect
.right
-= rect
.left
;
1212 rect
.bottom
-= rect
.top
;
1213 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1214 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1216 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1217 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1219 trace("max rect (%ld,%ld - %ld, %ld)\n",
1220 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1223 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1230 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1231 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs
->lpCreateParams
;
1233 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1234 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1236 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1237 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1238 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1239 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1240 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1242 /* MDICREATESTRUCT should have original values */
1243 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff,
1244 "mdi_cs->style does not match (%08lx)\n", mdi_cs
->style
);
1245 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1246 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1247 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1248 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1250 /* CREATESTRUCT should have fixed values */
1251 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1252 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1254 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1255 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1256 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1258 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1260 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1262 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1263 ok(cs
->style
== style
,
1264 "cs->style does not match (%08lx)\n", cs
->style
);
1268 LONG style
= mdi_cs
->style
;
1270 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1271 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1272 ok(cs
->style
== style
,
1273 "cs->style does not match (%08lx)\n", cs
->style
);
1278 case WM_GETMINMAXINFO
:
1280 HWND client
= GetParent(hwnd
);
1282 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1283 MINMAXINFO my_minmax
;
1284 LONG style
, exstyle
;
1286 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1287 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1289 GetWindowRect(client
, &rc
);
1290 trace("MDI client %p window size = (%ld x %ld)\n", client
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1291 GetClientRect(client
, &rc
);
1292 trace("MDI client %p client size = (%ld x %ld)\n", client
, rc
.right
, rc
.bottom
);
1293 trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN
),
1294 GetSystemMetrics(SM_CYSCREEN
));
1296 GetClientRect(client
, &rc
);
1297 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1298 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1299 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1300 trace("MDI child: calculated max window size = (%ld x %ld)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1302 trace("ptReserved = (%ld,%ld)\n"
1303 "ptMaxSize = (%ld,%ld)\n"
1304 "ptMaxPosition = (%ld,%ld)\n"
1305 "ptMinTrackSize = (%ld,%ld)\n"
1306 "ptMaxTrackSize = (%ld,%ld)\n",
1307 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1308 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1309 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1310 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1311 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1313 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %ld != %ld\n",
1314 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1315 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %ld != %ld\n",
1316 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1318 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1320 trace("DefMDIChildProc returned:\n"
1321 "ptReserved = (%ld,%ld)\n"
1322 "ptMaxSize = (%ld,%ld)\n"
1323 "ptMaxPosition = (%ld,%ld)\n"
1324 "ptMinTrackSize = (%ld,%ld)\n"
1325 "ptMaxTrackSize = (%ld,%ld)\n",
1326 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1327 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1328 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1329 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1330 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1332 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1333 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %ld != %ld\n",
1334 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1335 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %ld != %ld\n",
1336 minmax
->ptMaxSize
.y
, my_minmax
.ptMaxSize
.y
);
1341 case WM_MDIACTIVATE
:
1343 HWND active
, client
= GetParent(hwnd
);
1344 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1345 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
1346 if (hwnd
== (HWND
)lparam
) /* if we are being activated */
1347 ok (active
== (HWND
)lparam
, "new active %p != active %p\n", (HWND
)lparam
, active
);
1349 ok (active
== (HWND
)wparam
, "old active %p != active %p\n", (HWND
)wparam
, active
);
1353 return DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1356 static LRESULT WINAPI
mdi_child_wnd_proc_2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1363 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1365 trace("%s\n", (msg
== WM_NCCREATE
) ? "WM_NCCREATE" : "WM_CREATE");
1366 trace("x %d, y %d, cx %d, cy %d\n", cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1368 ok(!(cs
->dwExStyle
& WS_EX_MDICHILD
), "WS_EX_MDICHILD should not be set\n");
1369 ok(cs
->lpCreateParams
== mdi_lParam_test_message
, "wrong cs->lpCreateParams\n");
1371 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_2"), "wrong class name\n");
1372 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1374 /* CREATESTRUCT should have fixed values */
1375 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1377 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1378 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1380 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1381 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1382 while Win95, Win2k, WinXP do. */
1383 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1384 ok(cs
->cy
== 0, "%d != 0\n", cs
->cy
);
1388 case WM_GETMINMAXINFO
:
1390 HWND parent
= GetParent(hwnd
);
1392 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1393 LONG style
, exstyle
;
1395 trace("WM_GETMINMAXINFO\n");
1397 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1398 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1400 GetClientRect(parent
, &rc
);
1401 trace("parent %p client size = (%ld x %ld)\n", parent
, rc
.right
, rc
.bottom
);
1403 GetClientRect(parent
, &rc
);
1404 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1405 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1406 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1407 trace("calculated max child window size = (%ld x %ld)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1409 trace("ptReserved = (%ld,%ld)\n"
1410 "ptMaxSize = (%ld,%ld)\n"
1411 "ptMaxPosition = (%ld,%ld)\n"
1412 "ptMinTrackSize = (%ld,%ld)\n"
1413 "ptMaxTrackSize = (%ld,%ld)\n",
1414 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1415 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1416 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1417 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1418 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1420 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %ld != %ld\n",
1421 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1422 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %ld != %ld\n",
1423 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1427 case WM_WINDOWPOSCHANGED
:
1429 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1432 GetWindowRect(hwnd
, &rc1
);
1433 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1434 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1435 /* note: winpos coordinates are relative to parent */
1436 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1437 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1438 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1440 GetWindowRect(hwnd
, &rc1
);
1441 GetClientRect(hwnd
, &rc2
);
1442 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1443 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1444 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1447 case WM_WINDOWPOSCHANGING
:
1449 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1450 WINDOWPOS my_winpos
= *winpos
;
1452 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1453 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1454 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1455 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1457 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1459 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1460 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1461 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1463 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1464 "DefWindowProc should not change WINDOWPOS values\n");
1469 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1472 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1474 static HWND mdi_client
;
1480 CLIENTCREATESTRUCT client_cs
;
1483 GetClientRect(hwnd
, &rc
);
1485 client_cs
.hWindowMenu
= 0;
1486 client_cs
.idFirstChild
= 1;
1488 /* MDIClient without MDIS_ALLCHILDSTYLES */
1489 mdi_client
= CreateWindowExA(0, "mdiclient",
1491 WS_CHILD
/*| WS_VISIBLE*/,
1492 /* tests depend on a not zero MDIClient size */
1493 0, 0, rc
.right
, rc
.bottom
,
1494 hwnd
, 0, GetModuleHandle(0),
1495 (LPVOID
)&client_cs
);
1497 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1498 DestroyWindow(mdi_client
);
1500 /* MDIClient with MDIS_ALLCHILDSTYLES */
1501 mdi_client
= CreateWindowExA(0, "mdiclient",
1503 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
1504 /* tests depend on a not zero MDIClient size */
1505 0, 0, rc
.right
, rc
.bottom
,
1506 hwnd
, 0, GetModuleHandle(0),
1507 (LPVOID
)&client_cs
);
1509 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1510 DestroyWindow(mdi_client
);
1514 case WM_WINDOWPOSCHANGED
:
1516 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1519 GetWindowRect(hwnd
, &rc1
);
1520 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1521 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1522 /* note: winpos coordinates are relative to parent */
1523 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1524 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1525 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1527 GetWindowRect(hwnd
, &rc1
);
1528 GetClientRect(hwnd
, &rc2
);
1529 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1530 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1531 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1534 case WM_WINDOWPOSCHANGING
:
1536 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1537 WINDOWPOS my_winpos
= *winpos
;
1539 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1540 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1541 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1542 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1544 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1546 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1547 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1548 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1550 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1551 "DefWindowProc should not change WINDOWPOS values\n");
1560 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
1563 static BOOL
mdi_RegisterWindowClasses(void)
1568 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
1571 cls
.hInstance
= GetModuleHandleA(0);
1573 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1574 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1575 cls
.lpszMenuName
= NULL
;
1576 cls
.lpszClassName
= "MDI_parent_Class";
1577 if(!RegisterClassA(&cls
)) return FALSE
;
1579 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
1580 cls
.lpszClassName
= "MDI_child_Class_1";
1581 if(!RegisterClassA(&cls
)) return FALSE
;
1583 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
1584 cls
.lpszClassName
= "MDI_child_Class_2";
1585 if(!RegisterClassA(&cls
)) return FALSE
;
1590 static void test_mdi(void)
1595 if (!mdi_RegisterWindowClasses()) assert(0);
1597 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
1598 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
1599 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
1600 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1601 GetDesktopWindow(), 0,
1602 GetModuleHandle(0), NULL
);
1603 assert(mdi_hwndMain
);
1605 while(GetMessage(&msg, 0, 0, 0))
1607 TranslateMessage(&msg);
1608 DispatchMessage(&msg);
1613 static void test_icons(void)
1617 HICON icon
= LoadIconA(0, (LPSTR
)IDI_APPLICATION
);
1618 HICON icon2
= LoadIconA(0, (LPSTR
)IDI_QUESTION
);
1619 HICON small_icon
= LoadImageA(0, (LPSTR
)IDI_APPLICATION
, IMAGE_ICON
,
1620 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
1623 cls
.cbSize
= sizeof(cls
);
1625 cls
.lpfnWndProc
= DefWindowProcA
;
1629 cls
.hIcon
= LoadIconA(0, (LPSTR
)IDI_HAND
);
1630 cls
.hIconSm
= small_icon
;
1631 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1632 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1633 cls
.lpszMenuName
= NULL
;
1634 cls
.lpszClassName
= "IconWindowClass";
1636 RegisterClassExA(&cls
);
1638 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
1639 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
1642 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1643 ok( res
== 0, "wrong big icon %p/0\n", res
);
1644 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
1645 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
1646 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1647 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
1648 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
1649 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
1650 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1651 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1653 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1654 ok( res
== 0, "wrong small icon %p/0\n", res
);
1655 /* this test is XP specific */
1656 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1657 ok( res != 0, "wrong small icon %p\n", res );*/
1658 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
1659 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
1660 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1661 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
1662 /* this test is XP specific */
1663 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1664 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
1665 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
1666 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
1667 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1668 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
1669 /* this test is XP specific */
1670 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1671 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
1673 /* make sure the big icon hasn't changed */
1674 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1675 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1678 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1680 if (msg
== WM_NCCALCSIZE
)
1682 RECT
*rect
= (RECT
*)lparam
;
1683 /* first time around increase the rectangle, next time decrease it */
1684 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
1685 else InflateRect( rect
, -10, -10 );
1688 return DefWindowProc( hwnd
, msg
, wparam
, lparam
);
1691 static void test_SetWindowPos(HWND hwnd
)
1693 RECT orig_win_rc
, rect
;
1695 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
1697 SetRect(&rect
, 111, 222, 333, 444);
1698 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
1699 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1700 "wrong window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1702 SetRect(&rect
, 111, 222, 333, 444);
1703 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
1704 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1705 "wrong window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1707 GetWindowRect(hwnd
, &orig_win_rc
);
1709 old_proc
= SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
1710 SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1711 GetWindowRect( hwnd
, &rect
);
1712 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
1713 "invalid window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1714 GetClientRect( hwnd
, &rect
);
1715 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1716 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
1717 "invalid client rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1719 SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1720 GetWindowRect( hwnd
, &rect
);
1721 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
1722 "invalid window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1723 GetClientRect( hwnd
, &rect
);
1724 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1725 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
1726 "invalid client rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1728 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1729 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1730 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, old_proc
);
1732 /* Win9x truncates coordinates to 16-bit irrespectively */
1735 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
1736 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
1738 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
1739 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
1742 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1743 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1746 static void test_SetMenu(HWND parent
)
1750 BOOL is_win9x
= GetWindowLongPtrW(parent
, GWLP_WNDPROC
) == 0;
1754 hMenu
= CreateMenu();
1757 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1758 test_nonclient_area(parent
);
1759 ret
= GetMenu(parent
);
1760 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1761 /* test whether we can destroy a menu assigned to a window */
1762 retok
= DestroyMenu(hMenu
);
1763 ok( retok
, "DestroyMenu error %ld\n", GetLastError());
1764 ok(!IsMenu(hMenu
), "menu handle should be not valid after DestroyMenu\n");
1765 ret
= GetMenu(parent
);
1766 /* This test fails on Win9x */
1768 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1769 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1770 test_nonclient_area(parent
);
1772 hMenu
= CreateMenu();
1776 ret
= GetMenu(parent
);
1777 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1779 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1780 test_nonclient_area(parent
);
1781 ret
= GetMenu(parent
);
1782 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1784 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1785 test_nonclient_area(parent
);
1786 ret
= GetMenu(parent
);
1787 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1789 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1790 test_nonclient_area(parent
);
1791 ret
= GetMenu(parent
);
1792 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1795 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
1798 ret
= GetMenu(child
);
1799 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1801 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1802 test_nonclient_area(child
);
1803 ret
= GetMenu(child
);
1804 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1806 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
1807 test_nonclient_area(child
);
1808 ret
= GetMenu(child
);
1809 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1811 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
1812 test_nonclient_area(child
);
1813 ret
= GetMenu(child
);
1814 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1816 style
= GetWindowLong(child
, GWL_STYLE
);
1817 SetWindowLong(child
, GWL_STYLE
, style
| WS_POPUP
);
1818 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
1819 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
1820 SetWindowLong(child
, GWL_STYLE
, style
);
1822 SetWindowLong(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
1823 ok(!SetMenu(child
, hMenu
), "SetMenu on a overlapped child window should fail\n");
1824 SetWindowLong(child
, GWL_STYLE
, style
);
1826 DestroyWindow(child
);
1830 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
1832 HWND child
[5], hwnd
;
1837 hwnd
= GetWindow(parent
, GW_CHILD
);
1838 ok(!hwnd
, "have to start without children to perform the test\n");
1840 for (i
= 0; i
< total
; i
++)
1842 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
1843 parent
, 0, 0, NULL
);
1844 trace("child[%d] = %p\n", i
, child
[i
]);
1845 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
1848 hwnd
= GetWindow(parent
, GW_CHILD
);
1849 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
1850 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
1851 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
1853 for (i
= 0; i
< total
; i
++)
1855 trace("hwnd[%d] = %p\n", i
, hwnd
);
1856 ok(child
[order
[i
]] == hwnd
, "Z order of child #%d is wrong\n", i
);
1858 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
1861 for (i
= 0; i
< total
; i
++)
1862 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
1865 static void test_children_zorder(HWND parent
)
1867 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
1869 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
1871 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
1872 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
1873 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
1874 const int complex_order_1
[1] = { 0 };
1875 const int complex_order_2
[2] = { 1, 0 };
1876 const int complex_order_3
[3] = { 1, 0, 2 };
1877 const int complex_order_4
[4] = { 1, 0, 2, 3 };
1878 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
1880 /* simple WS_CHILD */
1881 test_window_tree(parent
, simple_style
, simple_order
, 5);
1883 /* complex children styles */
1884 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
1885 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
1886 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
1887 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
1888 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
1891 static void test_SetFocus(HWND hwnd
)
1895 /* check if we can set focus to non-visible windows */
1897 ShowWindow(hwnd
, SW_SHOW
);
1900 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
1901 ok( GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
1902 ShowWindow(hwnd
, SW_HIDE
);
1905 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
1906 ok( !(GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
1907 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
1910 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
1911 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
1912 ShowWindow(child
, SW_SHOW
);
1913 ok( GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
1914 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
1915 ShowWindow(child
, SW_HIDE
);
1916 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
1917 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
1918 ShowWindow(child
, SW_SHOW
);
1920 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
1921 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
1922 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
1924 ShowWindow(child
, SW_HIDE
);
1926 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
1927 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
1928 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
1929 ShowWindow(child
, SW_HIDE
);
1930 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
1932 ShowWindow(hwnd
, SW_SHOW
);
1933 ShowWindow(child
, SW_SHOW
);
1935 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
1936 EnableWindow(hwnd
, FALSE
);
1937 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
1938 EnableWindow(hwnd
, TRUE
);
1940 DestroyWindow( child
);
1943 static void test_SetActiveWindow(HWND hwnd
)
1947 ShowWindow(hwnd
, SW_SHOW
);
1949 SetActiveWindow(hwnd
);
1950 ok( GetActiveWindow() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
1951 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
1952 ok( GetActiveWindow() == hwnd
, "Window %p no longer active\n", hwnd
);
1953 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
1954 ShowWindow(hwnd
, SW_HIDE
);
1955 ok( GetActiveWindow() != hwnd
, "Window %p is still active\n", hwnd
);
1957 /* trace("**testing an invisible window now\n"); */
1958 SetActiveWindow(hwnd
);
1959 ok( GetActiveWindow() == hwnd
, "Window %p not active\n", hwnd
);
1960 ok( !(GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p is visible\n", hwnd
);
1962 ShowWindow(hwnd
, SW_SHOW
);
1964 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
1965 ok( GetActiveWindow() == hwnd2
, "Window %p is not active\n", hwnd2
);
1966 DestroyWindow(hwnd2
);
1967 ok( GetActiveWindow() != hwnd2
, "Window %p is still active\n", hwnd2
);
1969 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
1970 ok( GetActiveWindow() == hwnd2
, "Window %p is not active\n", hwnd2
);
1971 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
1972 ok( GetActiveWindow() == hwnd2
, "Window %p no longer active (%p)\n", hwnd2
, GetActiveWindow() );
1973 DestroyWindow(hwnd2
);
1974 ok( GetActiveWindow() != hwnd2
, "Window %p is still active\n", hwnd2
);
1977 static void check_wnd_state(HWND active
, HWND foreground
, HWND focus
, HWND capture
)
1979 ok(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
1981 ok(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
1982 ok(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
1983 ok(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
1986 static WNDPROC old_button_proc
;
1988 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1993 key_state
= GetKeyState(VK_LBUTTON
);
1994 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
1996 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
1998 if (msg
== WM_LBUTTONDOWN
)
2002 check_wnd_state(button
, button
, button
, button
);
2004 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2006 trace("hwnd %p\n", hwnd
);
2008 check_wnd_state(button
, button
, button
, button
);
2010 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2012 check_wnd_state(button
, button
, button
, button
);
2014 DestroyWindow(hwnd
);
2016 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2018 trace("hwnd %p\n", hwnd
);
2020 check_wnd_state(button
, button
, button
, button
);
2022 /* button wnd proc should release capture on WM_KILLFOCUS if it does
2023 * match internal button state.
2025 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2026 check_wnd_state(button
, button
, button
, 0);
2028 ShowWindow(hwnd
, SW_SHOW
);
2029 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2031 capture
= SetCapture(hwnd
);
2032 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2034 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2036 DestroyWindow(hwnd
);
2038 check_wnd_state(button
, 0, button
, 0);
2044 static void test_capture_1(void)
2046 HWND button
, capture
;
2048 capture
= GetCapture();
2049 ok(capture
== 0, "GetCapture() = %p\n", capture
);
2051 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2053 trace("button %p\n", button
);
2055 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
2057 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
2059 capture
= SetCapture(button
);
2060 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2061 check_wnd_state(button
, 0, button
, button
);
2063 DestroyWindow(button
);
2064 check_wnd_state(0, 0, 0, 0);
2067 static void test_capture_2(void)
2069 HWND button
, hwnd
, capture
;
2071 check_wnd_state(0, 0, 0, 0);
2073 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2075 trace("button %p\n", button
);
2077 check_wnd_state(button
, button
, button
, 0);
2079 capture
= SetCapture(button
);
2080 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2082 check_wnd_state(button
, button
, button
, button
);
2084 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
2085 * internal button state.
2087 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2088 check_wnd_state(button
, button
, button
, button
);
2090 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2092 trace("hwnd %p\n", hwnd
);
2094 check_wnd_state(button
, button
, button
, button
);
2096 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2098 check_wnd_state(button
, button
, button
, button
);
2100 DestroyWindow(hwnd
);
2102 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2104 trace("hwnd %p\n", hwnd
);
2106 check_wnd_state(button
, button
, button
, button
);
2108 ShowWindow(hwnd
, SW_SHOW
);
2110 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
2112 capture
= SetCapture(hwnd
);
2113 ok(capture
== button
, "SetCapture() = %p\n", capture
);
2115 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2117 DestroyWindow(hwnd
);
2118 check_wnd_state(button
, button
, button
, 0);
2120 DestroyWindow(button
);
2121 check_wnd_state(0, 0, 0, 0);
2124 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
2126 ShowWindow(hwnd1
, SW_HIDE
);
2127 ShowWindow(hwnd2
, SW_HIDE
);
2129 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
2130 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
2133 check_wnd_state(0, 0, 0, hwnd1
);
2136 check_wnd_state(0, 0, 0, hwnd2
);
2138 ShowWindow(hwnd1
, SW_SHOW
);
2139 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
2144 static void test_keyboard_input(HWND hwnd
)
2149 ShowWindow(hwnd
, SW_SHOW
);
2152 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
2155 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2157 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2159 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2160 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2161 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2162 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2163 ok( !ret
, "message %04x available\n", msg
.message
);
2165 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2167 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2168 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2169 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2170 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2171 ok( !ret
, "message %04x available\n", msg
.message
);
2173 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2175 keybd_event(VK_SPACE
, 0, 0, 0);
2176 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2177 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2178 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2179 ok( !ret
, "message %04x available\n", msg
.message
);
2182 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2184 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
2186 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2187 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2188 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2189 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2190 ok( !ret
, "message %04x available\n", msg
.message
);
2192 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2194 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2195 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2196 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2197 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2198 ok( !ret
, "message %04x available\n", msg
.message
);
2200 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2202 keybd_event(VK_SPACE
, 0, 0, 0);
2203 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2204 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2205 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2206 ok( !ret
, "message %04x available\n", msg
.message
);
2209 static void test_mouse_input(HWND hwnd
)
2218 ShowWindow(hwnd
, SW_SHOW
);
2221 GetWindowRect(hwnd
, &rc
);
2222 trace("main window %p: (%ld,%ld)-(%ld,%ld)\n", hwnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2224 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
2225 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
2228 ShowWindow(popup
, SW_SHOW
);
2229 UpdateWindow(popup
);
2231 GetWindowRect(popup
, &rc
);
2232 trace("popup window %p: (%ld,%ld)-(%ld,%ld)\n", popup
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2234 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
2235 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
2236 trace("setting cursor to (%d,%d)\n", x
, y
);
2240 ok(x
== pt
.x
&& y
== pt
.y
, "wrong cursor pos (%ld,%ld), expected (%d,%d)\n", pt
.x
, pt
.y
, x
, y
);
2242 /* force the system to update its internal queue mouse position,
2243 * otherwise it won't generate relative mouse movements below.
2245 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2246 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2249 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2250 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2251 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2252 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
2253 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
2254 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2255 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2256 ok( !ret
, "message %04x available\n", msg
.message
);
2258 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2259 ShowWindow(popup
, SW_HIDE
);
2260 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2261 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2262 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2264 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2265 ShowWindow(hwnd
, SW_HIDE
);
2266 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2267 ok( !ret
, "message %04x available\n", msg
.message
);
2269 /* test mouse clicks */
2271 ShowWindow(hwnd
, SW_SHOW
);
2272 ShowWindow(popup
, SW_SHOW
);
2274 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2276 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2277 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2278 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2279 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2281 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2282 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2283 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2284 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2285 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2286 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2287 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2288 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2290 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2291 ok(!ret
, "message %04x available\n", msg
.message
);
2293 ShowWindow(popup
, SW_HIDE
);
2294 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2296 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2297 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2298 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2299 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2301 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2302 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2303 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2304 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2306 test_lbuttondown_flag
= TRUE
;
2307 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
2308 test_lbuttondown_flag
= FALSE
;
2310 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2311 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2312 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2313 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2314 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2316 DestroyWindow(popup
);
2319 static void test_validatergn(HWND hwnd
)
2325 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
2326 ShowWindow(hwnd
, SW_SHOW
);
2327 UpdateWindow( hwnd
);
2328 /* test that ValidateRect validates children*/
2329 InvalidateRect( child
, NULL
, 1);
2330 GetWindowRect( child
, &rc
);
2331 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2332 ret
= GetUpdateRect( child
, &rc2
, 0);
2333 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
2334 "Update rectangle is empty!\n");
2335 ValidateRect( hwnd
, &rc
);
2336 ret
= GetUpdateRect( child
, &rc2
, 0);
2337 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2338 "Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2
.left
, rc2
.top
,
2339 rc2
.right
, rc2
.bottom
);
2341 /* now test ValidateRgn */
2342 InvalidateRect( child
, NULL
, 1);
2343 GetWindowRect( child
, &rc
);
2344 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2345 rgn
= CreateRectRgnIndirect( &rc
);
2346 ValidateRgn( hwnd
, rgn
);
2347 ret
= GetUpdateRect( child
, &rc2
, 0);
2348 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2349 "Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2
.left
, rc2
.top
,
2350 rc2
.right
, rc2
.bottom
);
2353 DestroyWindow( child
);
2356 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
2358 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
2359 GetWindowRect( hwnd
, prc
);
2360 trace("window rect is %ld,%ld - %ld,%ld\n",
2361 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2362 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
2363 trace("nccalc rect is %ld,%ld - %ld,%ld\n",
2364 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2367 static void test_nccalcscroll(HWND parent
)
2370 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
2371 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
2372 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
2373 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
2374 10, 10, 200, 200, parent
, 0, 0, NULL
);
2375 ShowWindow( parent
, SW_SHOW
);
2376 UpdateWindow( parent
);
2378 /* test window too low for a horizontal scroll bar */
2379 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
2380 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %ld,%ld - %ld,%ld\n",
2381 sbheight
, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2383 /* test window just high enough for a horizontal scroll bar */
2384 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
2385 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be %d size is %ld,%ld - %ld,%ld\n",
2386 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2388 /* test window too narrow for a vertical scroll bar */
2389 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
2390 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %ld,%ld - %ld,%ld\n",
2391 sbwidth
- 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2393 /* test window just wide enough for a vertical scroll bar */
2394 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2395 ok( rc1
.right
- rc1
.left
== 0, "Width should be %d size is %ld,%ld - %ld,%ld\n",
2396 0, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2398 /* same test, but with client edge: not enough width */
2399 SetWindowLong( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLong( hwnd
, GWL_EXSTYLE
));
2400 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2401 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
2402 "Width should be %d size is %ld,%ld - %ld,%ld\n",
2403 sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
), rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2405 DestroyWindow( hwnd
);
2408 static void test_SetParent(void)
2411 HWND desktop
= GetDesktopWindow();
2412 BOOL is_win9x
= GetWindowLongPtrW(desktop
, GWLP_WNDPROC
) == 0;
2413 HWND parent
, child1
, child2
, child3
, child4
;
2415 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
2416 100, 100, 200, 200, 0, 0, 0, NULL
);
2417 assert(parent
!= 0);
2418 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2419 0, 0, 50, 50, parent
, 0, 0, NULL
);
2420 assert(child1
!= 0);
2421 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2422 0, 0, 50, 50, child1
, 0, 0, NULL
);
2423 assert(child2
!= 0);
2424 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2425 0, 0, 50, 50, child2
, 0, 0, NULL
);
2426 assert(child3
!= 0);
2427 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2428 0, 0, 50, 50, child3
, 0, 0, NULL
);
2429 assert(child4
!= 0);
2431 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
2432 parent
, child1
, child2
, child3
, child4
);
2434 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
2435 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
2436 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2437 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2438 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2441 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
2442 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
2443 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2444 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
2445 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2448 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
2450 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2452 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
2453 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
2454 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
2455 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
2456 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
2457 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
2459 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2462 if (!is_win9x
) /* Win9x doesn't survive this test */
2464 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
2465 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
2466 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
2467 ok(SetParent(parent
, child2
) != 0, "SetParent should not fail\n");
2468 ok(SetParent(parent
, child3
) != 0, "SetParent should not fail\n");
2469 ok(!SetParent(child2
, parent
), "SetParent should fail\n");
2470 ok(SetParent(parent
, child4
) != 0, "SetParent should not fail\n");
2472 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
2473 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
2474 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2475 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2476 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2479 ret
= DestroyWindow(parent
);
2480 ok( ret
, "DestroyWindow() error %ld\n", GetLastError());
2482 ok(!IsWindow(parent
), "parent still exists\n");
2483 ok(!IsWindow(child1
), "child1 still exists\n");
2484 ok(!IsWindow(child2
), "child2 still exists\n");
2485 ok(!IsWindow(child3
), "child3 still exists\n");
2486 ok(!IsWindow(child4
), "child4 still exists\n");
2489 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2491 LPCREATESTRUCT lpcs
;
2498 lpcs
= (LPCREATESTRUCT
)lparam
;
2499 lpss
= (LPSTYLESTRUCT
)lpcs
->lpCreateParams
;
2502 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
2503 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
2504 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
2505 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
2507 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
2509 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
2510 "Ex style (0x%08lx) should match what the caller passed to CreateWindowEx (0x%08lx)\n",
2511 (lpss
->styleOld
& ~WS_EX_WINDOWEDGE
), (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
));
2513 ok(lpss
->styleNew
== lpcs
->style
,
2514 "Style (0x%08lx) should match what the caller passed to CreateWindowEx (0x%08lx)\n",
2515 lpss
->styleNew
, lpcs
->style
);
2519 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
2522 static ATOM atomStyleCheckClass
;
2524 static void register_style_check_class(void)
2532 GetModuleHandle(NULL
),
2534 LoadCursor(NULL
, IDC_ARROW
),
2535 (HBRUSH
)(COLOR_BTNFACE
+1),
2537 TEXT("WineStyleCheck"),
2540 atomStyleCheckClass
= RegisterClass(&wc
);
2543 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
2545 DWORD dwActualStyle
;
2546 DWORD dwActualExStyle
;
2549 HWND hwndParent
= NULL
;
2552 ss
.styleNew
= dwStyleIn
;
2553 ss
.styleOld
= dwExStyleIn
;
2555 if (dwStyleIn
& WS_CHILD
)
2557 hwndParent
= CreateWindowEx(0, MAKEINTATOM(atomStyleCheckClass
), NULL
,
2558 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
2561 hwnd
= CreateWindowEx(dwExStyleIn
, MAKEINTATOM(atomStyleCheckClass
), NULL
,
2562 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
2565 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
2567 TranslateMessage(&msg
);
2568 DispatchMessage(&msg
);
2571 dwActualStyle
= GetWindowLong(hwnd
, GWL_STYLE
);
2572 dwActualExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
2573 ok((dwActualStyle
== dwStyleOut
) && (dwActualExStyle
== dwExStyleOut
),
2574 "Style (0x%08lx) should really be 0x%08lx and/or Ex style (0x%08lx) should really be 0x%08lx\n",
2575 dwActualStyle
, dwStyleOut
, dwActualExStyle
, dwExStyleOut
);
2577 DestroyWindow(hwnd
);
2578 if (hwndParent
) DestroyWindow(hwndParent
);
2581 /* tests what window styles the window manager automatically adds */
2582 static void test_window_styles()
2584 register_style_check_class();
2586 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
2587 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
2588 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
2589 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
2590 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
2591 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
2592 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
2593 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
2594 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
2595 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
2596 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
2599 void test_scrollvalidate( HWND parent
)
2602 HRGN hrgn
=CreateRectRgn(0,0,0,0);
2603 HRGN exprgn
, tmprgn
, clipping
;
2604 RECT rc
, rcu
, cliprc
;
2605 /* create two overlapping child windows. The visual region
2606 * of hwnd1 is clipped by the overlapping part of
2607 * hwnd2 because of the WS_CLIPSIBLING style */
2610 hwnd2
= CreateWindowExA(0, "static", NULL
,
2611 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
2612 75, 30, 100, 100, parent
, 0, 0, NULL
);
2613 hwnd1
= CreateWindowExA(0, "static", NULL
,
2614 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
2615 25, 50, 100, 100, parent
, 0, 0, NULL
);
2616 ShowWindow( parent
, SW_SHOW
);
2617 UpdateWindow( parent
);
2618 GetClientRect( hwnd1
, &rc
);
2620 clipping
= CreateRectRgn( 10, 10, 90, 90);
2621 hdc
= GetDC( hwnd1
);
2622 /* for a visual touch */
2623 TextOut( hdc
, 0,10, "0123456789", 10);
2624 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
2625 if (winetest_debug
> 0) dump_region(hrgn
);
2626 /* create a region with what is expected */
2627 exprgn
= CreateRectRgn( 39,0,49,74);
2628 tmprgn
= CreateRectRgn( 88,79,98,93);
2629 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2630 tmprgn
= CreateRectRgn( 0,93,98,98);
2631 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2632 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2633 trace("update rect is %ld,%ld - %ld,%ld\n",
2634 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
2635 /* now with clipping region */
2636 SelectClipRgn( hdc
, clipping
);
2637 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
2638 if (winetest_debug
> 0) dump_region(hrgn
);
2639 /* create a region with what is expected */
2640 exprgn
= CreateRectRgn( 39,10,49,74);
2641 tmprgn
= CreateRectRgn( 80,79,90,85);
2642 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2643 tmprgn
= CreateRectRgn( 10,85,90,90);
2644 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2645 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2646 trace("update rect is %ld,%ld - %ld,%ld\n",
2647 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
2648 ReleaseDC( hwnd1
, hdc
);
2650 /* now test ScrollWindowEx with a combination of
2651 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
2652 /* make hwnd2 the child of hwnd1 */
2653 DestroyWindow( hwnd2
);
2654 hwnd2
= CreateWindowExA(0, "static", NULL
,
2655 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
2656 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
2657 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
2658 GetClientRect( hwnd1
, &rc
);
2661 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
2662 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
2663 ValidateRect( hwnd1
, NULL
);
2664 ValidateRect( hwnd2
, NULL
);
2665 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
2666 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
2667 if (winetest_debug
> 0) dump_region(hrgn
);
2668 exprgn
= CreateRectRgn( 88,0,98,88);
2669 tmprgn
= CreateRectRgn( 0,88,98,98);
2670 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2671 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2673 /* SW_SCROLLCHILDREN */
2674 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
2675 ValidateRect( hwnd1
, NULL
);
2676 ValidateRect( hwnd2
, NULL
);
2677 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
2678 if (winetest_debug
> 0) dump_region(hrgn
);
2679 /* expected region is the same as in previous test */
2680 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2682 /* no SW_SCROLLCHILDREN */
2683 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
2684 ValidateRect( hwnd1
, NULL
);
2685 ValidateRect( hwnd2
, NULL
);
2686 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
2687 if (winetest_debug
> 0) dump_region(hrgn
);
2688 /* expected region is the same as in previous test */
2689 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2691 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
2692 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
2693 ValidateRect( hwnd1
, NULL
);
2694 ValidateRect( hwnd2
, NULL
);
2695 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
2696 if (winetest_debug
> 0) dump_region(hrgn
);
2697 exprgn
= CreateRectRgn( 88,0,98,20);
2698 tmprgn
= CreateRectRgn( 20,20,98,30);
2699 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2700 tmprgn
= CreateRectRgn( 20,30,30,88);
2701 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2702 tmprgn
= CreateRectRgn( 0,88,30,98);
2703 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2704 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2707 DeleteObject( hrgn
);
2708 DeleteObject( exprgn
);
2709 DeleteObject( tmprgn
);
2710 DestroyWindow( hwnd1
);
2711 DestroyWindow( hwnd2
);
2714 /* couple of tests of return values of scrollbar functions
2715 * called on a scrollbarless window */
2721 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
2722 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
2723 100, 100, 200, 200, 0, 0, 0, NULL
);
2725 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
2726 ok( ret
, "GetScrollRange returns FALSE\n");
2727 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
2728 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
2729 si
.cbSize
= sizeof( si
);
2730 si
.fMask
= SIF_PAGE
;
2731 si
.nPage
= 0xdeadbeef;
2732 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
2733 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
2734 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
2736 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
2737 ok( ret
, "GetScrollRange returns FALSE\n");
2738 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
2739 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
2740 si
.cbSize
= sizeof( si
);
2741 si
.fMask
= SIF_PAGE
;
2742 si
.nPage
= 0xdeadbeef;
2743 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
2744 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
2745 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
2747 DestroyWindow( hwnd
);
2753 pGetAncestor
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
2754 pGetWindowInfo
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetWindowInfo" );
2756 hwndMain
= CreateWindowExA(0, "static", NULL
, 0, 0, 0, 0, 0, HWND_MESSAGE
, 0, 0, NULL
);
2759 ok(!GetParent(hwndMain
), "GetParent should return 0 for message only windows\n");
2762 hwndMessage
= pGetAncestor(hwndMain
, GA_PARENT
);
2763 ok(hwndMessage
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message only windows\n");
2764 trace("hwndMessage %p\n", hwndMessage
);
2766 DestroyWindow(hwndMain
);
2769 trace("CreateWindowExA with parent HWND_MESSAGE failed\n");
2771 if (!RegisterWindowClasses()) assert(0);
2773 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
2776 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
2777 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2778 WS_MAXIMIZEBOX
| WS_POPUP
,
2781 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
2782 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2783 WS_MAXIMIZEBOX
| WS_POPUP
,
2787 assert( hwndMain2
);
2791 test_capture_3(hwndMain
, hwndMain2
);
2793 test_parent_owner();
2795 test_shell_window();
2799 test_SetWindowPos(hwndMain
);
2800 test_SetMenu(hwndMain
);
2801 test_SetFocus(hwndMain
);
2802 test_SetActiveWindow(hwndMain
);
2804 test_children_zorder(hwndMain
);
2805 test_keyboard_input(hwndMain
);
2806 test_mouse_input(hwndMain
);
2807 test_validatergn(hwndMain
);
2808 test_nccalcscroll( hwndMain
);
2809 test_scrollvalidate( hwndMain
);
2812 UnhookWindowsHookEx(hhook
);
2814 test_window_styles();