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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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 static const char* szAWRClass
= "Winsize";
61 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
63 /* try to make sure pending X events have been processed before continuing */
64 static void flush_events(void)
68 DWORD time
= GetTickCount() + diff
;
72 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, diff
, QS_ALLINPUT
);
73 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
74 diff
= time
- GetTickCount();
78 /* check the values returned by the various parent/owner functions on a given window */
79 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
80 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
86 res
= pGetAncestor( hwnd
, GA_PARENT
);
87 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
89 res
= (HWND
)GetWindowLongPtrA( hwnd
, GWLP_HWNDPARENT
);
90 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
91 res
= GetParent( hwnd
);
92 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
93 res
= GetWindow( hwnd
, GW_OWNER
);
94 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
97 res
= pGetAncestor( hwnd
, GA_ROOT
);
98 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
99 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
100 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
104 BOOL CALLBACK
EnumChildProc( HWND hwndChild
, LPARAM lParam
)
107 trace("EnumChildProc on %p\n", hwndChild
);
108 if (*(LPINT
)lParam
> 1) return FALSE
;
112 /* will search for the given window */
113 BOOL CALLBACK
EnumChildProc1( HWND hwndChild
, LPARAM lParam
)
115 trace("EnumChildProc1 on %p\n", hwndChild
);
116 if ((HWND
)lParam
== hwndChild
) return FALSE
;
120 static HWND
create_tool_window( LONG style
, HWND parent
)
122 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
123 0, 0, 100, 100, parent
, 0, 0, NULL
);
124 ok( ret
!= 0, "Creation failed\n" );
128 /* test parent and owner values for various combinations */
129 static void test_parent_owner(void)
132 HWND test
, owner
, ret
;
133 HWND desktop
= GetDesktopWindow();
134 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
137 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
139 /* child without parent, should fail */
140 SetLastError(0xdeadbeef);
141 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
142 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
143 ok( GetLastError() == ERROR_TLW_WITH_WSCHILD
, "CreateWindowExA should call SetLastError\n" );
144 ok( !test
, "WS_CHILD without parent created\n" );
147 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
148 style
= GetWindowLongA( desktop
, GWL_STYLE
);
149 ok( !SetWindowLongA( desktop
, GWL_STYLE
, WS_POPUP
), "Set GWL_STYLE on desktop succeeded\n" );
150 ok( !SetWindowLongA( desktop
, GWL_STYLE
, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
151 ok( GetWindowLongA( desktop
, GWL_STYLE
) == style
, "Desktop style changed\n" );
153 /* normal child window */
154 test
= create_tool_window( WS_CHILD
, hwndMain
);
155 trace( "created child %p\n", test
);
156 check_parents( test
, hwndMain
, hwndMain
, hwndMain
, 0, hwndMain
, hwndMain
);
157 SetWindowLongA( test
, GWL_STYLE
, 0 );
158 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
159 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
160 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
161 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
162 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
163 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
164 DestroyWindow( test
);
166 /* normal child window with WS_MAXIMIZE */
167 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
168 DestroyWindow( test
);
170 /* normal child window with WS_THICKFRAME */
171 test
= create_tool_window( WS_CHILD
| WS_THICKFRAME
, hwndMain
);
172 DestroyWindow( test
);
174 /* popup window with WS_THICKFRAME */
175 test
= create_tool_window( WS_POPUP
| WS_THICKFRAME
, hwndMain
);
176 DestroyWindow( test
);
178 /* child of desktop */
179 test
= create_tool_window( WS_CHILD
, desktop
);
180 trace( "created child of desktop %p\n", test
);
181 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
182 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
183 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
184 SetWindowLongA( test
, GWL_STYLE
, 0 );
185 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
186 DestroyWindow( test
);
188 /* child of desktop with WS_MAXIMIZE */
189 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, desktop
);
190 DestroyWindow( test
);
192 /* child of desktop with WS_MINIMIZE */
193 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, desktop
);
194 DestroyWindow( test
);
197 test
= create_tool_window( WS_CHILD
, child
);
198 trace( "created child of child %p\n", test
);
199 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
200 SetWindowLongA( test
, GWL_STYLE
, 0 );
201 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
202 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
203 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
204 DestroyWindow( test
);
206 /* child of child with WS_MAXIMIZE */
207 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, child
);
208 DestroyWindow( test
);
210 /* child of child with WS_MINIMIZE */
211 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, child
);
212 DestroyWindow( test
);
214 /* not owned top-level window */
215 test
= create_tool_window( 0, 0 );
216 trace( "created top-level %p\n", test
);
217 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
218 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
219 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
220 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
221 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
222 DestroyWindow( test
);
224 /* not owned top-level window with WS_MAXIMIZE */
225 test
= create_tool_window( WS_MAXIMIZE
, 0 );
226 DestroyWindow( test
);
228 /* owned top-level window */
229 test
= create_tool_window( 0, hwndMain
);
230 trace( "created owned top-level %p\n", test
);
231 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
232 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
233 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
234 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
235 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
236 DestroyWindow( test
);
238 /* owned top-level window with WS_MAXIMIZE */
239 test
= create_tool_window( WS_MAXIMIZE
, hwndMain
);
240 DestroyWindow( test
);
242 /* not owned popup */
243 test
= create_tool_window( WS_POPUP
, 0 );
244 trace( "created popup %p\n", test
);
245 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
246 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
247 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
248 SetWindowLongA( test
, GWL_STYLE
, 0 );
249 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
250 DestroyWindow( test
);
252 /* not owned popup with WS_MAXIMIZE */
253 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, 0 );
254 DestroyWindow( test
);
257 test
= create_tool_window( WS_POPUP
, hwndMain
);
258 trace( "created owned popup %p\n", test
);
259 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
260 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
261 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
262 SetWindowLongA( test
, GWL_STYLE
, 0 );
263 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
264 DestroyWindow( test
);
266 /* owned popup with WS_MAXIMIZE */
267 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, hwndMain
);
268 DestroyWindow( test
);
270 /* top-level window owned by child (same as owned by top-level) */
271 test
= create_tool_window( 0, child
);
272 trace( "created top-level owned by child %p\n", test
);
273 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
274 DestroyWindow( test
);
276 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
277 test
= create_tool_window( WS_MAXIMIZE
, child
);
278 DestroyWindow( test
);
280 /* popup owned by desktop (same as not owned) */
281 test
= create_tool_window( WS_POPUP
, desktop
);
282 trace( "created popup owned by desktop %p\n", test
);
283 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
284 DestroyWindow( test
);
286 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
287 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, desktop
);
288 DestroyWindow( test
);
290 /* popup owned by child (same as owned by top-level) */
291 test
= create_tool_window( WS_POPUP
, child
);
292 trace( "created popup owned by child %p\n", test
);
293 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
294 DestroyWindow( test
);
296 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
297 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, child
);
298 DestroyWindow( test
);
300 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
301 test
= create_tool_window( WS_POPUP
| WS_CHILD
, 0 );
302 trace( "created WS_CHILD popup %p\n", test
);
303 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
304 DestroyWindow( test
);
306 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
307 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, 0 );
308 DestroyWindow( test
);
310 /* owned popup with WS_CHILD (same as WS_POPUP only) */
311 test
= create_tool_window( WS_POPUP
| WS_CHILD
, hwndMain
);
312 trace( "created owned WS_CHILD popup %p\n", test
);
313 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
314 DestroyWindow( test
);
316 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
317 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
318 DestroyWindow( test
);
320 /******************** parent changes *************************/
321 trace( "testing parent changes\n" );
324 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
325 #if 0 /* this test succeeds on NT but crashes on win9x systems */
326 ret
= (HWND
)SetWindowLongA( test
, GWL_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
327 ok( !ret
, "Set GWL_HWNDPARENT succeeded on desktop\n" );
328 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
329 ok( !SetParent( desktop
, hwndMain
), "SetParent succeeded on desktop\n" );
330 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
332 /* normal child window */
333 test
= create_tool_window( WS_CHILD
, hwndMain
);
334 trace( "created child %p\n", test
);
336 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
337 ok( ret
== hwndMain
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain
);
338 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
340 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
341 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
342 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
344 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)desktop
);
345 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
346 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
348 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
349 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
350 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
351 check_parents( test
, desktop
, child
, desktop
, child
, test
, desktop
);
353 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
354 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
355 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
356 DestroyWindow( test
);
358 /* not owned top-level window */
359 test
= create_tool_window( 0, 0 );
360 trace( "created top-level %p\n", test
);
362 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
363 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
364 check_parents( test
, desktop
, hwndMain2
, 0, hwndMain2
, test
, test
);
366 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
367 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
368 check_parents( test
, desktop
, child
, 0, child
, test
, test
);
370 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
371 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
372 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
373 DestroyWindow( test
);
375 /* not owned popup */
376 test
= create_tool_window( WS_POPUP
, 0 );
377 trace( "created popup %p\n", test
);
379 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
380 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
381 check_parents( test
, desktop
, hwndMain2
, hwndMain2
, hwndMain2
, test
, hwndMain2
);
383 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
384 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
385 check_parents( test
, desktop
, child
, child
, child
, test
, hwndMain
);
387 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
388 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
389 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
390 DestroyWindow( test
);
392 /* normal child window */
393 test
= create_tool_window( WS_CHILD
, hwndMain
);
394 trace( "created child %p\n", test
);
396 ret
= SetParent( test
, desktop
);
397 ok( ret
== hwndMain
, "SetParent return value %p expected %p\n", ret
, hwndMain
);
398 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
400 ret
= SetParent( test
, child
);
401 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
402 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
404 ret
= SetParent( test
, hwndMain2
);
405 ok( ret
== child
, "SetParent return value %p expected %p\n", ret
, child
);
406 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
407 DestroyWindow( test
);
409 /* not owned top-level window */
410 test
= create_tool_window( 0, 0 );
411 trace( "created top-level %p\n", test
);
413 ret
= SetParent( test
, child
);
414 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
415 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
416 DestroyWindow( test
);
419 test
= create_tool_window( WS_POPUP
, hwndMain2
);
420 trace( "created owned popup %p\n", test
);
422 ret
= SetParent( test
, child
);
423 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
424 check_parents( test
, child
, child
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
426 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)hwndMain
);
427 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
428 check_parents( test
, hwndMain
, hwndMain
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
429 DestroyWindow( test
);
431 /**************** test owner destruction *******************/
433 /* owned child popup */
434 owner
= create_tool_window( 0, 0 );
435 test
= create_tool_window( WS_POPUP
, owner
);
436 trace( "created owner %p and popup %p\n", owner
, test
);
437 ret
= SetParent( test
, child
);
438 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
439 check_parents( test
, child
, child
, owner
, owner
, hwndMain
, owner
);
440 /* window is now child of 'child' but owned by 'owner' */
441 DestroyWindow( owner
);
442 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
443 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
444 * while Win95, Win2k, WinXP do.
446 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
447 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
450 /* owned top-level popup */
451 owner
= create_tool_window( 0, 0 );
452 test
= create_tool_window( WS_POPUP
, owner
);
453 trace( "created owner %p and popup %p\n", owner
, test
);
454 check_parents( test
, desktop
, owner
, owner
, owner
, test
, owner
);
455 DestroyWindow( owner
);
456 ok( !IsWindow(test
), "Window %p not destroyed by owner destruction\n", test
);
458 /* top-level popup owned by child */
459 owner
= create_tool_window( WS_CHILD
, hwndMain2
);
460 test
= create_tool_window( WS_POPUP
, 0 );
461 trace( "created owner %p and popup %p\n", owner
, test
);
462 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)owner
);
463 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
464 check_parents( test
, desktop
, owner
, owner
, owner
, test
, hwndMain2
);
465 DestroyWindow( owner
);
466 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
467 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
468 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
469 * while Win95, Win2k, WinXP do.
471 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
475 DestroyWindow(child
);
478 owner
= create_tool_window( WS_OVERLAPPED
, 0 );
479 test
= create_tool_window( WS_POPUP
, desktop
);
481 ok( !GetWindow( test
, GW_OWNER
), "Wrong owner window\n" );
483 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
484 "EnumChildWindows should have returned FALSE\n" );
485 ok( numChildren
== 0, "numChildren should be 0 got %d\n", numChildren
);
487 SetWindowLongA( test
, GWL_STYLE
, (GetWindowLongA( test
, GWL_STYLE
) & ~WS_POPUP
) | WS_CHILD
);
488 ret
= SetParent( test
, owner
);
489 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
492 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
493 "EnumChildWindows should have returned TRUE\n" );
494 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
496 child
= create_tool_window( WS_CHILD
, owner
);
498 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
499 "EnumChildWindows should have returned FALSE\n" );
500 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
501 DestroyWindow( child
);
503 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
504 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
506 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
507 "EnumChildWindows should have returned TRUE\n" );
508 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
510 ret
= SetParent( child
, owner
);
511 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
512 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
514 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
515 "EnumChildWindows should have returned FALSE\n" );
516 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
518 ret
= SetParent( child
, NULL
);
519 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
520 ok( ret
== owner
, "SetParent return value %p expected %p\n", ret
, owner
);
522 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
523 "EnumChildWindows should have returned TRUE\n" );
524 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
526 /* even GW_OWNER == owner it's still a desktop's child */
527 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
528 "EnumChildWindows should have found %p and returned FALSE\n", child
);
530 DestroyWindow( child
);
531 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, NULL
);
533 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
534 "EnumChildWindows should have found %p and returned FALSE\n", child
);
536 DestroyWindow( child
);
537 DestroyWindow( test
);
538 DestroyWindow( owner
);
542 static LRESULT WINAPI
main_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
546 case WM_GETMINMAXINFO
:
548 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
550 trace("hwnd %p, WM_GETMINMAXINFO, %08x, %08lx\n", hwnd
, wparam
, lparam
);
551 trace("ptReserved (%d,%d), ptMaxSize (%d,%d), ptMaxPosition (%d,%d)\n"
552 " ptMinTrackSize (%d,%d), ptMaxTrackSize (%d,%d)\n",
553 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
554 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
555 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
556 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
557 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
558 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
561 case WM_WINDOWPOSCHANGING
:
563 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
564 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
565 trace("main: WM_WINDOWPOSCHANGING\n");
566 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
567 winpos
->hwnd
, winpos
->hwndInsertAfter
,
568 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
569 if (!(winpos
->flags
& SWP_NOMOVE
))
571 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
572 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
574 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
575 if (!(winpos
->flags
& SWP_NOSIZE
) && !is_win9x
)
577 ok(winpos
->cx
>= 0 && winpos
->cx
<= 32767, "bad winpos->cx %d\n", winpos
->cx
);
578 ok(winpos
->cy
>= 0 && winpos
->cy
<= 32767, "bad winpos->cy %d\n", winpos
->cy
);
582 case WM_WINDOWPOSCHANGED
:
585 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
586 trace("main: WM_WINDOWPOSCHANGED\n");
587 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
588 winpos
->hwnd
, winpos
->hwndInsertAfter
,
589 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
590 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
591 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
593 ok(winpos
->cx
>= 0 && winpos
->cx
<= 32767, "bad winpos->cx %d\n", winpos
->cx
);
594 ok(winpos
->cy
>= 0 && winpos
->cy
<= 32767, "bad winpos->cy %d\n", winpos
->cy
);
596 GetWindowRect(hwnd
, &rc1
);
597 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
598 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
599 /* note: winpos coordinates are relative to parent */
600 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
601 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
602 #if 0 /* Uncomment this once the test succeeds in all cases */
603 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
606 GetClientRect(hwnd
, &rc2
);
607 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
608 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
609 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
610 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
615 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
616 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
618 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
619 if (got_getminmaxinfo
)
620 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
622 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
623 ok(got_getminmaxinfo
, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
625 ok(!got_getminmaxinfo
, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
629 if (test_lbuttondown_flag
)
630 ShowWindow((HWND
)wparam
, SW_SHOW
);
634 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
637 static LRESULT WINAPI
tool_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
641 case WM_GETMINMAXINFO
:
643 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
645 trace("hwnd %p, WM_GETMINMAXINFO, %08x, %08lx\n", hwnd
, wparam
, lparam
);
646 trace("ptReserved (%d,%d), ptMaxSize (%d,%d), ptMaxPosition (%d,%d)\n"
647 " ptMinTrackSize (%d,%d), ptMaxTrackSize (%d,%d)\n",
648 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
649 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
650 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
651 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
652 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
653 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
658 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
659 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
661 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
662 if (got_getminmaxinfo
)
663 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
665 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
666 ok(got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
668 ok(!got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
673 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
676 static BOOL
RegisterWindowClasses(void)
680 cls
.style
= CS_DBLCLKS
;
681 cls
.lpfnWndProc
= main_window_procA
;
684 cls
.hInstance
= GetModuleHandleA(0);
686 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
687 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
688 cls
.lpszMenuName
= NULL
;
689 cls
.lpszClassName
= "MainWindowClass";
691 if(!RegisterClassA(&cls
)) return FALSE
;
694 cls
.lpfnWndProc
= tool_window_procA
;
697 cls
.hInstance
= GetModuleHandleA(0);
699 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
700 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
701 cls
.lpszMenuName
= NULL
;
702 cls
.lpszClassName
= "ToolWindowClass";
704 if(!RegisterClassA(&cls
)) return FALSE
;
709 static void verify_window_info(HWND hwnd
, const WINDOWINFO
*info
, BOOL test_borders
)
711 RECT rcWindow
, rcClient
;
715 ok(IsWindow(hwnd
), "bad window handle\n");
717 GetWindowRect(hwnd
, &rcWindow
);
718 ok(EqualRect(&rcWindow
, &info
->rcWindow
), "wrong rcWindow\n");
720 GetClientRect(hwnd
, &rcClient
);
721 /* translate to screen coordinates */
722 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rcClient
, 2);
723 ok(EqualRect(&rcClient
, &info
->rcClient
), "wrong rcClient\n");
725 ok(info
->dwStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_STYLE
),
726 "wrong dwStyle: %08x != %08x\n", info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
));
727 /* Windows reports a not documented exstyle 0x800 in WINDOWINFO, but
728 * doesn't return it in GetWindowLong(hwnd, GWL_EXSTYLE).
730 ok((info
->dwExStyle
& ~0x800) == (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
731 "wrong dwExStyle: %08x != %08x\n", info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
));
732 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
733 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04x != %04x\n",
734 info
->dwWindowStatus
, status
);
736 if (test_borders
&& !IsRectEmpty(&rcWindow
))
738 trace("rcWindow: %d,%d - %d,%d\n", rcWindow
.left
, rcWindow
.top
, rcWindow
.right
, rcWindow
.bottom
);
739 trace("rcClient: %d,%d - %d,%d\n", rcClient
.left
, rcClient
.top
, rcClient
.right
, rcClient
.bottom
);
741 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
742 "wrong cxWindowBorders %d != %d\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
743 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
744 ok(info
->cyWindowBorders
== border
,
745 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
748 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType\n");
749 ok(info
->wCreatorVersion
== 0x0400, "wrong wCreatorVersion %04x\n", info
->wCreatorVersion
);
752 static void FixedAdjustWindowRectEx(RECT
* rc
, LONG style
, BOOL menu
, LONG exstyle
)
754 AdjustWindowRectEx(rc
, style
, menu
, exstyle
);
755 /* AdjustWindowRectEx does not include scroll bars */
756 if (style
& WS_VSCROLL
)
758 if(exstyle
& WS_EX_LEFTSCROLLBAR
)
759 rc
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
761 rc
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
763 if (style
& WS_HSCROLL
)
764 rc
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
767 static void test_nonclient_area(HWND hwnd
)
769 DWORD style
, exstyle
;
770 RECT rc_window
, rc_client
, rc
;
772 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
774 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
775 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
776 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
778 GetWindowRect(hwnd
, &rc_window
);
779 trace("window: (%d,%d)-(%d,%d)\n", rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
780 GetClientRect(hwnd
, &rc_client
);
781 trace("client: (%d,%d)-(%d,%d)\n", rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
);
783 /* avoid some cases when things go wrong */
784 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
785 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
787 CopyRect(&rc
, &rc_client
);
788 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
789 FixedAdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
791 trace("calc window: (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
792 ok(EqualRect(&rc
, &rc_window
), "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d\n", style
, exstyle
, menu
);
795 CopyRect(&rc
, &rc_window
);
796 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
797 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
798 trace("calc client: (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
799 ok(EqualRect(&rc
, &rc_client
), "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d\n", style
, exstyle
, menu
);
801 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
805 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
806 SetRect(&rc_client
, 0, 0, 250, 150);
807 CopyRect(&rc_window
, &rc_client
);
808 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
809 FixedAdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
810 trace("calc window: (%d,%d)-(%d,%d)\n",
811 rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
813 CopyRect(&rc
, &rc_window
);
814 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
815 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
816 trace("calc client: (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
817 ok(EqualRect(&rc
, &rc_client
), "synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d\n", style
, exstyle
, menu
);
820 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
822 static const char *CBT_code_name
[10] = {
833 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
835 trace("CBT: %d (%s), %08x, %08lx\n", nCode
, code_name
, wParam
, lParam
);
837 /* on HCBT_DESTROYWND window state is undefined */
838 if (nCode
!= HCBT_DESTROYWND
&& IsWindow((HWND
)wParam
))
844 /* Win98 actually does check the info.cbSize and doesn't allow
845 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
846 * WinXP do not check it at all.
848 info
.cbSize
= sizeof(WINDOWINFO
);
849 ok(pGetWindowInfo((HWND
)wParam
, &info
), "GetWindowInfo should not fail\n");
850 /* win2k SP4 returns broken border info if GetWindowInfo
851 * is being called from HCBT_DESTROYWND or HCBT_MINMAX hook proc.
853 verify_window_info((HWND
)wParam
, &info
, nCode
!= HCBT_MINMAX
);
861 #if 0 /* Uncomment this once the test succeeds in all cases */
862 static const RECT rc_null
;
866 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
867 trace("HCBT_CREATEWND: hwnd %p, parent %p, style %08x\n",
868 (HWND
)wParam
, createwnd
->lpcs
->hwndParent
, createwnd
->lpcs
->style
);
869 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
871 /* WS_VISIBLE should be turned off yet */
872 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
873 ok(style
== GetWindowLongA((HWND
)wParam
, GWL_STYLE
),
874 "style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
875 GetWindowLongA((HWND
)wParam
, GWL_STYLE
), style
);
877 #if 0 /* Uncomment this once the test succeeds in all cases */
878 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
880 ok(GetParent((HWND
)wParam
) == hwndMessage
,
881 "wrong result from GetParent %p: message window %p\n",
882 GetParent((HWND
)wParam
), hwndMessage
);
885 ok(!GetParent((HWND
)wParam
), "GetParent should return 0 at this point\n");
887 ok(!GetWindow((HWND
)wParam
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
889 #if 0 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
890 * Win9x still has them set to 0.
892 ok(GetWindow((HWND
)wParam
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
893 ok(GetWindow((HWND
)wParam
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
895 ok(!GetWindow((HWND
)wParam
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
896 ok(!GetWindow((HWND
)wParam
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
898 #if 0 /* Uncomment this once the test succeeds in all cases */
901 ok(pGetAncestor((HWND
)wParam
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
902 ok(pGetAncestor((HWND
)wParam
, GA_ROOT
) == (HWND
)wParam
,
903 "GA_ROOT is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOT
), (HWND
)wParam
);
905 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
906 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == hwndMessage
,
907 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
909 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == (HWND
)wParam
,
910 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
), (HWND
)wParam
);
913 ok(GetWindowRect((HWND
)wParam
, &rc
), "GetWindowRect failed\n");
914 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
915 ok(GetClientRect((HWND
)wParam
, &rc
), "GetClientRect failed\n");
916 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
922 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
925 static void test_shell_window(void)
929 HMODULE hinst
, hUser32
;
930 BOOL (WINAPI
*SetShellWindow
)(HWND
);
931 BOOL (WINAPI
*SetShellWindowEx
)(HWND
, HWND
);
932 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
933 HWND shellWindow
, nextWnd
;
935 if (!GetWindowLongW(GetDesktopWindow(), GWL_STYLE
))
937 trace("Skipping shell window test on Win9x\n");
941 shellWindow
= GetShellWindow();
942 hinst
= GetModuleHandle(0);
943 hUser32
= GetModuleHandleA("user32");
945 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
946 SetShellWindowEx
= (void *)GetProcAddress(hUser32
, "SetShellWindowEx");
948 trace("previous shell window: %p\n", shellWindow
);
954 ret
= DestroyWindow(shellWindow
);
955 error
= GetLastError();
957 ok(!ret
, "DestroyWindow(shellWindow)\n");
958 /* passes on Win XP, but not on Win98 */
959 ok(error
==ERROR_ACCESS_DENIED
, "ERROR_ACCESS_DENIED after DestroyWindow(shellWindow)\n");
961 /* close old shell instance */
962 GetWindowThreadProcessId(shellWindow
, &pid
);
963 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
964 ret
= TerminateProcess(hProcess
, 0);
965 ok(ret
, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
966 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
967 CloseHandle(hProcess
);
970 hwnd1
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
971 trace("created window 1: %p\n", hwnd1
);
973 ret
= SetShellWindow(hwnd1
);
974 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
975 shellWindow
= GetShellWindow();
976 ok(shellWindow
==hwnd1
, "wrong shell window: %p\n", shellWindow
);
978 ret
= SetShellWindow(hwnd1
);
979 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
981 ret
= SetShellWindow(0);
982 error
= GetLastError();
983 /* passes on Win XP, but not on Win98
984 ok(!ret, "reset shell window by SetShellWindow(0)\n");
985 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
987 ret
= SetShellWindow(hwnd1
);
988 /* passes on Win XP, but not on Win98
989 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
993 SetWindowLong(hwnd1
, GWL_EXSTYLE
, GetWindowLong(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
994 ret
= GetWindowLong(hwnd1
,GWL_EXSTYLE
)&WS_EX_TOPMOST
? TRUE
: FALSE
;
995 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
998 ret
= DestroyWindow(hwnd1
);
999 ok(ret
, "DestroyWindow(hwnd1)\n");
1001 hwnd2
= CreateWindowEx(WS_EX_TOPMOST
, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
1002 trace("created window 2: %p\n", hwnd2
);
1003 ret
= SetShellWindow(hwnd2
);
1004 ok(!ret
, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
1006 hwnd3
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
1007 trace("created window 3: %p\n", hwnd3
);
1009 hwnd4
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
1010 trace("created window 4: %p\n", hwnd4
);
1012 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1013 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd
);
1015 ret
= SetShellWindow(hwnd4
);
1016 ok(ret
, "SetShellWindow(hwnd4)\n");
1017 shellWindow
= GetShellWindow();
1018 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1020 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1021 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
1023 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1024 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1026 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1027 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
1029 ret
= SetShellWindow(hwnd3
);
1030 ok(!ret
, "SetShellWindow(hwnd3)\n");
1031 shellWindow
= GetShellWindow();
1032 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1034 hwnd5
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
1035 trace("created window 5: %p\n", hwnd5
);
1036 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1037 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
1041 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1042 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
1045 /* destroy test windows */
1046 DestroyWindow(hwnd2
);
1047 DestroyWindow(hwnd3
);
1048 DestroyWindow(hwnd4
);
1049 DestroyWindow(hwnd5
);
1052 /************** MDI test ****************/
1054 static const char mdi_lParam_test_message
[] = "just a test string";
1056 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT first_id
)
1058 MDICREATESTRUCTA mdi_cs
;
1060 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1061 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
1062 BOOL isWin9x
= FALSE
;
1064 mdi_cs
.szClass
= "MDI_child_Class_1";
1065 mdi_cs
.szTitle
= "MDI child";
1066 mdi_cs
.hOwner
= GetModuleHandle(0);
1067 mdi_cs
.x
= CW_USEDEFAULT
;
1068 mdi_cs
.y
= CW_USEDEFAULT
;
1069 mdi_cs
.cx
= CW_USEDEFAULT
;
1070 mdi_cs
.cy
= CW_USEDEFAULT
;
1072 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1073 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1074 ok(mdi_child
!= 0, "MDI child creation failed\n");
1075 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1076 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1077 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1079 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
1080 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1081 ok(mdi_child
!= 0, "MDI child creation failed\n");
1082 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1083 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1084 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1086 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
1087 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1088 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1090 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1094 ok(mdi_child
!= 0, "MDI child creation failed\n");
1095 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1096 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1097 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1100 /* test MDICREATESTRUCT A<->W mapping */
1101 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1103 mdi_cs
.szClass
= (LPCSTR
)classW
;
1104 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
1105 SetLastError(0xdeadbeef);
1106 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1109 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1112 ok(mdi_child
!= 0, "MDI child creation failed\n");
1116 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1117 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1118 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1121 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1123 CW_USEDEFAULT
, CW_USEDEFAULT
,
1124 CW_USEDEFAULT
, CW_USEDEFAULT
,
1125 mdi_client
, GetModuleHandle(0),
1126 (LPARAM
)mdi_lParam_test_message
);
1127 ok(mdi_child
!= 0, "MDI child creation failed\n");
1128 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1129 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1130 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1132 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1133 0x7fffffff, /* without WS_POPUP */
1134 CW_USEDEFAULT
, CW_USEDEFAULT
,
1135 CW_USEDEFAULT
, CW_USEDEFAULT
,
1136 mdi_client
, GetModuleHandle(0),
1137 (LPARAM
)mdi_lParam_test_message
);
1138 ok(mdi_child
!= 0, "MDI child creation failed\n");
1139 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1140 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1141 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1143 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1144 0xffffffff, /* with WS_POPUP */
1145 CW_USEDEFAULT
, CW_USEDEFAULT
,
1146 CW_USEDEFAULT
, CW_USEDEFAULT
,
1147 mdi_client
, GetModuleHandle(0),
1148 (LPARAM
)mdi_lParam_test_message
);
1149 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1151 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1155 ok(mdi_child
!= 0, "MDI child creation failed\n");
1156 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1157 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1158 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1161 /* test MDICREATESTRUCT A<->W mapping */
1162 SetLastError(0xdeadbeef);
1163 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1165 CW_USEDEFAULT
, CW_USEDEFAULT
,
1166 CW_USEDEFAULT
, CW_USEDEFAULT
,
1167 mdi_client
, GetModuleHandle(0),
1168 (LPARAM
)mdi_lParam_test_message
);
1171 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1174 ok(mdi_child
!= 0, "MDI child creation failed\n");
1178 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1179 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1180 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1183 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1185 CW_USEDEFAULT
, CW_USEDEFAULT
,
1186 CW_USEDEFAULT
, CW_USEDEFAULT
,
1187 mdi_client
, 0, GetModuleHandle(0),
1188 (LPVOID
)mdi_lParam_test_message
);
1189 ok(mdi_child
!= 0, "MDI child creation failed\n");
1190 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1191 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1192 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1194 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1195 0x7fffffff, /* without WS_POPUP */
1196 CW_USEDEFAULT
, CW_USEDEFAULT
,
1197 CW_USEDEFAULT
, CW_USEDEFAULT
,
1198 mdi_client
, 0, GetModuleHandle(0),
1199 (LPVOID
)mdi_lParam_test_message
);
1200 ok(mdi_child
!= 0, "MDI child creation failed\n");
1201 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1202 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1203 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1205 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1206 0xffffffff, /* with WS_POPUP */
1207 CW_USEDEFAULT
, CW_USEDEFAULT
,
1208 CW_USEDEFAULT
, CW_USEDEFAULT
,
1209 mdi_client
, 0, GetModuleHandle(0),
1210 (LPVOID
)mdi_lParam_test_message
);
1211 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1213 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1217 ok(mdi_child
!= 0, "MDI child creation failed\n");
1218 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1219 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1220 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1223 /* test MDICREATESTRUCT A<->W mapping */
1224 SetLastError(0xdeadbeef);
1225 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1227 CW_USEDEFAULT
, CW_USEDEFAULT
,
1228 CW_USEDEFAULT
, CW_USEDEFAULT
,
1229 mdi_client
, 0, GetModuleHandle(0),
1230 (LPVOID
)mdi_lParam_test_message
);
1233 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1236 ok(mdi_child
!= 0, "MDI child creation failed\n");
1240 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1241 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1242 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1245 /* This test fails on Win9x */
1248 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1250 CW_USEDEFAULT
, CW_USEDEFAULT
,
1251 CW_USEDEFAULT
, CW_USEDEFAULT
,
1252 parent
, 0, GetModuleHandle(0),
1253 (LPVOID
)mdi_lParam_test_message
);
1254 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1257 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1258 WS_CHILD
, /* without WS_POPUP */
1259 CW_USEDEFAULT
, CW_USEDEFAULT
,
1260 CW_USEDEFAULT
, CW_USEDEFAULT
,
1261 mdi_client
, 0, GetModuleHandle(0),
1262 (LPVOID
)mdi_lParam_test_message
);
1263 ok(mdi_child
!= 0, "MDI child creation failed\n");
1264 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1265 DestroyWindow(mdi_child
);
1267 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1268 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1269 CW_USEDEFAULT
, CW_USEDEFAULT
,
1270 CW_USEDEFAULT
, CW_USEDEFAULT
,
1271 mdi_client
, 0, GetModuleHandle(0),
1272 (LPVOID
)mdi_lParam_test_message
);
1273 ok(mdi_child
!= 0, "MDI child creation failed\n");
1274 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1275 DestroyWindow(mdi_child
);
1277 /* maximized child */
1278 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1279 WS_CHILD
| WS_MAXIMIZE
,
1280 CW_USEDEFAULT
, CW_USEDEFAULT
,
1281 CW_USEDEFAULT
, CW_USEDEFAULT
,
1282 mdi_client
, 0, GetModuleHandle(0),
1283 (LPVOID
)mdi_lParam_test_message
);
1284 ok(mdi_child
!= 0, "MDI child creation failed\n");
1285 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1286 DestroyWindow(mdi_child
);
1288 trace("Creating maximized child with a caption\n");
1289 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1290 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1291 CW_USEDEFAULT
, CW_USEDEFAULT
,
1292 CW_USEDEFAULT
, CW_USEDEFAULT
,
1293 mdi_client
, 0, GetModuleHandle(0),
1294 (LPVOID
)mdi_lParam_test_message
);
1295 ok(mdi_child
!= 0, "MDI child creation failed\n");
1296 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1297 DestroyWindow(mdi_child
);
1299 trace("Creating maximized child with a caption and a thick frame\n");
1300 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1301 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1302 CW_USEDEFAULT
, CW_USEDEFAULT
,
1303 CW_USEDEFAULT
, CW_USEDEFAULT
,
1304 mdi_client
, 0, GetModuleHandle(0),
1305 (LPVOID
)mdi_lParam_test_message
);
1306 ok(mdi_child
!= 0, "MDI child creation failed\n");
1307 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1308 DestroyWindow(mdi_child
);
1311 /**********************************************************************
1312 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1314 * Note: The rule here is that client rect of the maximized MDI child
1315 * is equal to the client rect of the MDI client window.
1317 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1321 GetClientRect( client
, &rect
);
1322 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1323 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1325 rect
.right
-= rect
.left
;
1326 rect
.bottom
-= rect
.top
;
1327 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1328 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1330 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1331 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1333 trace("max rect (%d,%d - %d, %d)\n",
1334 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1337 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1344 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1345 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs
->lpCreateParams
;
1347 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1348 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1350 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1351 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1352 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1353 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1354 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1356 /* MDICREATESTRUCT should have original values */
1357 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff,
1358 "mdi_cs->style does not match (%08x)\n", mdi_cs
->style
);
1359 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1360 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1361 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1362 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1364 /* CREATESTRUCT should have fixed values */
1365 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1366 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1368 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1369 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1370 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1372 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1374 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1376 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1377 ok(cs
->style
== style
,
1378 "cs->style does not match (%08x)\n", cs
->style
);
1382 LONG style
= mdi_cs
->style
;
1384 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1385 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1386 ok(cs
->style
== style
,
1387 "cs->style does not match (%08x)\n", cs
->style
);
1392 case WM_GETMINMAXINFO
:
1394 HWND client
= GetParent(hwnd
);
1396 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1397 MINMAXINFO my_minmax
;
1398 LONG style
, exstyle
;
1400 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1401 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1403 GetWindowRect(client
, &rc
);
1404 trace("MDI client %p window size = (%d x %d)\n", client
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1405 GetClientRect(client
, &rc
);
1406 trace("MDI client %p client size = (%d x %d)\n", client
, rc
.right
, rc
.bottom
);
1407 trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN
),
1408 GetSystemMetrics(SM_CYSCREEN
));
1410 GetClientRect(client
, &rc
);
1411 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1412 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1413 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1414 trace("MDI child: calculated max window size = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1416 trace("ptReserved = (%d,%d)\n"
1417 "ptMaxSize = (%d,%d)\n"
1418 "ptMaxPosition = (%d,%d)\n"
1419 "ptMinTrackSize = (%d,%d)\n"
1420 "ptMaxTrackSize = (%d,%d)\n",
1421 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1422 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1423 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1424 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1425 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1427 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1428 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1429 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1430 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1432 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1434 trace("DefMDIChildProc returned:\n"
1435 "ptReserved = (%d,%d)\n"
1436 "ptMaxSize = (%d,%d)\n"
1437 "ptMaxPosition = (%d,%d)\n"
1438 "ptMinTrackSize = (%d,%d)\n"
1439 "ptMaxTrackSize = (%d,%d)\n",
1440 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1441 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1442 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1443 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1444 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1446 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1447 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %d != %d\n",
1448 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1449 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %d != %d\n",
1450 minmax
->ptMaxSize
.y
, my_minmax
.ptMaxSize
.y
);
1455 case WM_MDIACTIVATE
:
1457 HWND active
, client
= GetParent(hwnd
);
1458 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1459 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
1460 if (hwnd
== (HWND
)lparam
) /* if we are being activated */
1461 ok (active
== (HWND
)lparam
, "new active %p != active %p\n", (HWND
)lparam
, active
);
1463 ok (active
== (HWND
)wparam
, "old active %p != active %p\n", (HWND
)wparam
, active
);
1467 return DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1470 static LRESULT WINAPI
mdi_child_wnd_proc_2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1477 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1479 trace("%s\n", (msg
== WM_NCCREATE
) ? "WM_NCCREATE" : "WM_CREATE");
1480 trace("x %d, y %d, cx %d, cy %d\n", cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1482 ok(!(cs
->dwExStyle
& WS_EX_MDICHILD
), "WS_EX_MDICHILD should not be set\n");
1483 ok(cs
->lpCreateParams
== mdi_lParam_test_message
, "wrong cs->lpCreateParams\n");
1485 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_2"), "wrong class name\n");
1486 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1488 /* CREATESTRUCT should have fixed values */
1489 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1491 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1492 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1494 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1495 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1496 while Win95, Win2k, WinXP do. */
1497 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1498 ok(cs
->cy
== 0, "%d != 0\n", cs
->cy
);
1502 case WM_GETMINMAXINFO
:
1504 HWND parent
= GetParent(hwnd
);
1506 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1507 LONG style
, exstyle
;
1509 trace("WM_GETMINMAXINFO\n");
1511 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1512 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1514 GetClientRect(parent
, &rc
);
1515 trace("parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
1517 GetClientRect(parent
, &rc
);
1518 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1519 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1520 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1521 trace("calculated max child window size = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1523 trace("ptReserved = (%d,%d)\n"
1524 "ptMaxSize = (%d,%d)\n"
1525 "ptMaxPosition = (%d,%d)\n"
1526 "ptMinTrackSize = (%d,%d)\n"
1527 "ptMaxTrackSize = (%d,%d)\n",
1528 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1529 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1530 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1531 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1532 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1534 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1535 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1536 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1537 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1541 case WM_WINDOWPOSCHANGED
:
1543 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1546 GetWindowRect(hwnd
, &rc1
);
1547 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1548 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1549 /* note: winpos coordinates are relative to parent */
1550 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1551 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1552 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1554 GetWindowRect(hwnd
, &rc1
);
1555 GetClientRect(hwnd
, &rc2
);
1556 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1557 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1558 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1561 case WM_WINDOWPOSCHANGING
:
1563 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1564 WINDOWPOS my_winpos
= *winpos
;
1566 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1567 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1568 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1569 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1571 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1573 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1574 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1575 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1577 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1578 "DefWindowProc should not change WINDOWPOS values\n");
1583 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1586 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1588 static HWND mdi_client
;
1594 CLIENTCREATESTRUCT client_cs
;
1597 GetClientRect(hwnd
, &rc
);
1599 client_cs
.hWindowMenu
= 0;
1600 client_cs
.idFirstChild
= 1;
1602 /* MDIClient without MDIS_ALLCHILDSTYLES */
1603 mdi_client
= CreateWindowExA(0, "mdiclient",
1605 WS_CHILD
/*| WS_VISIBLE*/,
1606 /* tests depend on a not zero MDIClient size */
1607 0, 0, rc
.right
, rc
.bottom
,
1608 hwnd
, 0, GetModuleHandle(0),
1609 (LPVOID
)&client_cs
);
1611 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1612 DestroyWindow(mdi_client
);
1614 /* MDIClient with MDIS_ALLCHILDSTYLES */
1615 mdi_client
= CreateWindowExA(0, "mdiclient",
1617 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
1618 /* tests depend on a not zero MDIClient size */
1619 0, 0, rc
.right
, rc
.bottom
,
1620 hwnd
, 0, GetModuleHandle(0),
1621 (LPVOID
)&client_cs
);
1623 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1624 DestroyWindow(mdi_client
);
1628 case WM_WINDOWPOSCHANGED
:
1630 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1633 GetWindowRect(hwnd
, &rc1
);
1634 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1635 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1636 /* note: winpos coordinates are relative to parent */
1637 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1638 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1639 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1641 GetWindowRect(hwnd
, &rc1
);
1642 GetClientRect(hwnd
, &rc2
);
1643 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1644 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1645 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1648 case WM_WINDOWPOSCHANGING
:
1650 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1651 WINDOWPOS my_winpos
= *winpos
;
1653 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1654 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1655 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1656 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1658 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1660 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1661 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1662 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1664 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1665 "DefWindowProc should not change WINDOWPOS values\n");
1674 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
1677 static BOOL
mdi_RegisterWindowClasses(void)
1682 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
1685 cls
.hInstance
= GetModuleHandleA(0);
1687 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1688 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1689 cls
.lpszMenuName
= NULL
;
1690 cls
.lpszClassName
= "MDI_parent_Class";
1691 if(!RegisterClassA(&cls
)) return FALSE
;
1693 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
1694 cls
.lpszClassName
= "MDI_child_Class_1";
1695 if(!RegisterClassA(&cls
)) return FALSE
;
1697 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
1698 cls
.lpszClassName
= "MDI_child_Class_2";
1699 if(!RegisterClassA(&cls
)) return FALSE
;
1704 static void test_mdi(void)
1709 if (!mdi_RegisterWindowClasses()) assert(0);
1711 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
1712 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
1713 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
1714 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1715 GetDesktopWindow(), 0,
1716 GetModuleHandle(0), NULL
);
1717 assert(mdi_hwndMain
);
1719 while(GetMessage(&msg, 0, 0, 0))
1721 TranslateMessage(&msg);
1722 DispatchMessage(&msg);
1727 static void test_icons(void)
1731 HICON icon
= LoadIconA(0, (LPSTR
)IDI_APPLICATION
);
1732 HICON icon2
= LoadIconA(0, (LPSTR
)IDI_QUESTION
);
1733 HICON small_icon
= LoadImageA(0, (LPSTR
)IDI_APPLICATION
, IMAGE_ICON
,
1734 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
1737 cls
.cbSize
= sizeof(cls
);
1739 cls
.lpfnWndProc
= DefWindowProcA
;
1743 cls
.hIcon
= LoadIconA(0, (LPSTR
)IDI_HAND
);
1744 cls
.hIconSm
= small_icon
;
1745 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1746 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1747 cls
.lpszMenuName
= NULL
;
1748 cls
.lpszClassName
= "IconWindowClass";
1750 RegisterClassExA(&cls
);
1752 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
1753 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
1756 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1757 ok( res
== 0, "wrong big icon %p/0\n", res
);
1758 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
1759 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
1760 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1761 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
1762 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
1763 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
1764 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1765 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1767 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1768 ok( res
== 0, "wrong small icon %p/0\n", res
);
1769 /* this test is XP specific */
1770 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1771 ok( res != 0, "wrong small icon %p\n", res );*/
1772 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
1773 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
1774 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1775 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
1776 /* this test is XP specific */
1777 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1778 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
1779 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
1780 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
1781 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1782 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
1783 /* this test is XP specific */
1784 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1785 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
1787 /* make sure the big icon hasn't changed */
1788 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1789 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1792 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1794 if (msg
== WM_NCCALCSIZE
)
1796 RECT
*rect
= (RECT
*)lparam
;
1797 /* first time around increase the rectangle, next time decrease it */
1798 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
1799 else InflateRect( rect
, -10, -10 );
1802 return DefWindowProc( hwnd
, msg
, wparam
, lparam
);
1805 static void test_SetWindowPos(HWND hwnd
)
1807 RECT orig_win_rc
, rect
;
1809 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
1811 SetRect(&rect
, 111, 222, 333, 444);
1812 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
1813 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1814 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1816 SetRect(&rect
, 111, 222, 333, 444);
1817 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
1818 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1819 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1821 GetWindowRect(hwnd
, &orig_win_rc
);
1823 old_proc
= SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
1824 SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1825 GetWindowRect( hwnd
, &rect
);
1826 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
1827 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1828 GetClientRect( hwnd
, &rect
);
1829 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1830 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
1831 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1833 SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1834 GetWindowRect( hwnd
, &rect
);
1835 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
1836 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1837 GetClientRect( hwnd
, &rect
);
1838 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1839 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
1840 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1842 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1843 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1844 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, old_proc
);
1846 /* Win9x truncates coordinates to 16-bit irrespectively */
1849 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
1850 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
1852 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
1853 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
1856 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1857 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1860 static void test_SetMenu(HWND parent
)
1864 BOOL is_win9x
= GetWindowLongPtrW(parent
, GWLP_WNDPROC
) == 0;
1868 hMenu
= CreateMenu();
1871 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1873 /* fails on (at least) Wine, NT4, XP SP2 */
1874 test_nonclient_area(parent
);
1876 ret
= GetMenu(parent
);
1877 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1878 /* test whether we can destroy a menu assigned to a window */
1879 retok
= DestroyMenu(hMenu
);
1880 ok( retok
, "DestroyMenu error %d\n", GetLastError());
1881 ok(!IsMenu(hMenu
), "menu handle should be not valid after DestroyMenu\n");
1882 ret
= GetMenu(parent
);
1883 /* This test fails on Win9x */
1885 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1886 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1887 test_nonclient_area(parent
);
1889 hMenu
= CreateMenu();
1893 ret
= GetMenu(parent
);
1894 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1896 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1897 test_nonclient_area(parent
);
1898 ret
= GetMenu(parent
);
1899 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1901 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1903 /* fails on (at least) Wine, NT4, XP SP2 */
1904 test_nonclient_area(parent
);
1906 ret
= GetMenu(parent
);
1907 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1909 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1910 test_nonclient_area(parent
);
1911 ret
= GetMenu(parent
);
1912 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1915 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
1918 ret
= GetMenu(child
);
1919 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1921 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1922 test_nonclient_area(child
);
1923 ret
= GetMenu(child
);
1924 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1926 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
1927 test_nonclient_area(child
);
1928 ret
= GetMenu(child
);
1929 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1931 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
1932 test_nonclient_area(child
);
1933 ret
= GetMenu(child
);
1934 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1936 style
= GetWindowLong(child
, GWL_STYLE
);
1937 SetWindowLong(child
, GWL_STYLE
, style
| WS_POPUP
);
1938 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
1939 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
1940 SetWindowLong(child
, GWL_STYLE
, style
);
1942 SetWindowLong(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
1943 ok(!SetMenu(child
, hMenu
), "SetMenu on a overlapped child window should fail\n");
1944 SetWindowLong(child
, GWL_STYLE
, style
);
1946 DestroyWindow(child
);
1950 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
1952 HWND child
[5], hwnd
;
1957 hwnd
= GetWindow(parent
, GW_CHILD
);
1958 ok(!hwnd
, "have to start without children to perform the test\n");
1960 for (i
= 0; i
< total
; i
++)
1962 if (style
[i
] & DS_CONTROL
)
1964 child
[i
] = CreateWindowExA(0, MAKEINTATOM(32770), "", style
[i
] & ~WS_VISIBLE
,
1965 0,0,0,0, parent
, (HMENU
)i
, 0, NULL
);
1966 if (style
[i
] & WS_VISIBLE
)
1967 ShowWindow(child
[i
], SW_SHOW
);
1969 SetWindowPos(child
[i
], HWND_BOTTOM
, 0,0,10,10, SWP_NOACTIVATE
);
1972 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
1973 parent
, (HMENU
)i
, 0, NULL
);
1974 trace("child[%d] = %p\n", i
, child
[i
]);
1975 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
1978 hwnd
= GetWindow(parent
, GW_CHILD
);
1979 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
1980 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
1981 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
1983 for (i
= 0; i
< total
; i
++)
1985 trace("hwnd[%d] = %p\n", i
, hwnd
);
1986 ok(child
[order
[i
]] == hwnd
, "Z order of child #%d is wrong\n", i
);
1988 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
1991 for (i
= 0; i
< total
; i
++)
1992 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
1995 static void test_children_zorder(HWND parent
)
1997 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
1999 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
2001 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
2002 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
2003 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
2004 const int complex_order_1
[1] = { 0 };
2005 const int complex_order_2
[2] = { 1, 0 };
2006 const int complex_order_3
[3] = { 1, 0, 2 };
2007 const int complex_order_4
[4] = { 1, 0, 2, 3 };
2008 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
2009 const DWORD complex_style_6
[3] = { WS_CHILD
| WS_VISIBLE
,
2010 WS_CHILD
| WS_CLIPSIBLINGS
| DS_CONTROL
| WS_VISIBLE
,
2011 WS_CHILD
| WS_VISIBLE
};
2012 const int complex_order_6
[3] = { 0, 1, 2 };
2014 /* simple WS_CHILD */
2015 test_window_tree(parent
, simple_style
, simple_order
, 5);
2017 /* complex children styles */
2018 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
2019 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
2020 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
2021 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
2022 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
2024 /* another set of complex children styles */
2025 test_window_tree(parent
, complex_style_6
, complex_order_6
, 3);
2028 static void test_vis_rgn( HWND hwnd
)
2030 RECT win_rect
, rgn_rect
;
2031 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
2034 ShowWindow(hwnd
,SW_SHOW
);
2035 hdc
= GetDC( hwnd
);
2036 ok( GetRandomRgn( hdc
, hrgn
, SYSRGN
) != 0, "GetRandomRgn failed\n" );
2037 GetWindowRect( hwnd
, &win_rect
);
2038 GetRgnBox( hrgn
, &rgn_rect
);
2039 if (GetVersion() & 0x80000000)
2041 trace("win9x, mapping to screen coords\n");
2042 MapWindowPoints( hwnd
, 0, (POINT
*)&rgn_rect
, 2 );
2044 trace("win: %d,%d-%d,%d\n", win_rect
.left
, win_rect
.top
, win_rect
.right
, win_rect
.bottom
);
2045 trace("rgn: %d,%d-%d,%d\n", rgn_rect
.left
, rgn_rect
.top
, rgn_rect
.right
, rgn_rect
.bottom
);
2046 ok( win_rect
.left
<= rgn_rect
.left
, "rgn left %d not inside win rect %d\n",
2047 rgn_rect
.left
, win_rect
.left
);
2048 ok( win_rect
.top
<= rgn_rect
.top
, "rgn top %d not inside win rect %d\n",
2049 rgn_rect
.top
, win_rect
.top
);
2050 ok( win_rect
.right
>= rgn_rect
.right
, "rgn right %d not inside win rect %d\n",
2051 rgn_rect
.right
, win_rect
.right
);
2052 ok( win_rect
.bottom
>= rgn_rect
.bottom
, "rgn bottom %d not inside win rect %d\n",
2053 rgn_rect
.bottom
, win_rect
.bottom
);
2054 ReleaseDC( hwnd
, hdc
);
2057 static void test_SetFocus(HWND hwnd
)
2061 /* check if we can set focus to non-visible windows */
2063 ShowWindow(hwnd
, SW_SHOW
);
2066 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2067 ok( GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
2068 ShowWindow(hwnd
, SW_HIDE
);
2071 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
2072 ok( !(GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
2073 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2076 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
2077 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2078 ShowWindow(child
, SW_SHOW
);
2079 ok( GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
2080 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
2081 ShowWindow(child
, SW_HIDE
);
2082 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2083 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2084 ShowWindow(child
, SW_SHOW
);
2086 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2087 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
2088 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2090 ShowWindow(child
, SW_HIDE
);
2092 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2093 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
2094 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2095 ShowWindow(child
, SW_HIDE
);
2096 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2098 ShowWindow(hwnd
, SW_SHOW
);
2099 ShowWindow(child
, SW_SHOW
);
2101 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2102 EnableWindow(hwnd
, FALSE
);
2103 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2104 EnableWindow(hwnd
, TRUE
);
2106 DestroyWindow( child
);
2109 static void check_wnd_state(HWND active
, HWND foreground
, HWND focus
, HWND capture
)
2111 ok(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
2113 ok(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
2114 ok(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
2115 ok(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
2118 static void test_SetActiveWindow(HWND hwnd
)
2122 ShowWindow(hwnd
, SW_HIDE
);
2125 check_wnd_state(0, 0, 0, 0);
2127 /*trace("testing SetActiveWindow %p\n", hwnd);*/
2129 ShowWindow(hwnd
, SW_SHOW
);
2130 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2132 hwnd2
= SetActiveWindow(0);
2133 ok(hwnd2
== hwnd
, "SetActiveWindow returned %p instead of %p\n", hwnd2
, hwnd
);
2134 check_wnd_state(0, 0, 0, 0);
2136 hwnd2
= SetActiveWindow(hwnd
);
2137 ok(hwnd2
== 0, "SetActiveWindow returned %p instead of 0\n", hwnd2
);
2138 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2140 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2141 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2143 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2144 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2146 ShowWindow(hwnd
, SW_HIDE
);
2147 check_wnd_state(0, 0, 0, 0);
2149 /*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/
2150 SetActiveWindow(hwnd
);
2151 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2153 ShowWindow(hwnd
, SW_SHOW
);
2154 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2156 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2157 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2159 DestroyWindow(hwnd2
);
2160 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2162 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2163 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2165 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2166 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2168 DestroyWindow(hwnd2
);
2169 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2172 static void test_SetForegroundWindow(HWND hwnd
)
2177 ShowWindow(hwnd
, SW_HIDE
);
2180 check_wnd_state(0, 0, 0, 0);
2182 /*trace("testing SetForegroundWindow %p\n", hwnd);*/
2184 ShowWindow(hwnd
, SW_SHOW
);
2185 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2187 hwnd2
= SetActiveWindow(0);
2188 ok(hwnd2
== hwnd
, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2
, hwnd
);
2189 check_wnd_state(0, 0, 0, 0);
2191 ret
= SetForegroundWindow(hwnd
);
2192 ok(ret
, "SetForegroundWindow returned FALSE instead of TRUE\n");
2193 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2195 SetLastError(0xdeadbeef);
2196 ret
= SetForegroundWindow(0);
2197 ok(!ret
, "SetForegroundWindow returned TRUE instead of FALSE\n");
2198 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
2199 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2201 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2202 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2204 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2205 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2207 ShowWindow(hwnd
, SW_HIDE
);
2208 check_wnd_state(0, 0, 0, 0);
2210 /*trace("testing SetForegroundWindow on an invisible window %p\n", hwnd);*/
2211 ret
= SetForegroundWindow(hwnd
);
2212 ok(ret
, "SetForegroundWindow returned FALSE instead of TRUE\n");
2213 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2215 ShowWindow(hwnd
, SW_SHOW
);
2216 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2218 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2219 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2221 DestroyWindow(hwnd2
);
2222 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2224 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2225 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2227 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2228 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2230 DestroyWindow(hwnd2
);
2231 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2234 static WNDPROC old_button_proc
;
2236 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2241 key_state
= GetKeyState(VK_LBUTTON
);
2242 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
2244 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
2246 if (msg
== WM_LBUTTONDOWN
)
2250 check_wnd_state(button
, button
, button
, button
);
2252 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2254 trace("hwnd %p\n", hwnd
);
2256 check_wnd_state(button
, button
, button
, button
);
2258 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2260 check_wnd_state(button
, button
, button
, button
);
2262 DestroyWindow(hwnd
);
2264 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2266 trace("hwnd %p\n", hwnd
);
2268 check_wnd_state(button
, button
, button
, button
);
2270 /* button wnd proc should release capture on WM_KILLFOCUS if it does
2271 * match internal button state.
2273 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2274 check_wnd_state(button
, button
, button
, 0);
2276 ShowWindow(hwnd
, SW_SHOW
);
2277 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2279 capture
= SetCapture(hwnd
);
2280 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2282 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2284 DestroyWindow(hwnd
);
2286 check_wnd_state(button
, 0, button
, 0);
2292 static void test_capture_1(void)
2294 HWND button
, capture
;
2296 capture
= GetCapture();
2297 ok(capture
== 0, "GetCapture() = %p\n", capture
);
2299 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2301 trace("button %p\n", button
);
2303 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
2305 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
2307 capture
= SetCapture(button
);
2308 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2309 check_wnd_state(button
, 0, button
, button
);
2311 DestroyWindow(button
);
2312 check_wnd_state(0, 0, 0, 0);
2315 static void test_capture_2(void)
2317 HWND button
, hwnd
, capture
;
2319 check_wnd_state(0, 0, 0, 0);
2321 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2323 trace("button %p\n", button
);
2325 check_wnd_state(button
, button
, button
, 0);
2327 capture
= SetCapture(button
);
2328 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2330 check_wnd_state(button
, button
, button
, button
);
2332 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
2333 * internal button state.
2335 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2336 check_wnd_state(button
, button
, button
, button
);
2338 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2340 trace("hwnd %p\n", hwnd
);
2342 check_wnd_state(button
, button
, button
, button
);
2344 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2346 check_wnd_state(button
, button
, button
, button
);
2348 DestroyWindow(hwnd
);
2350 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2352 trace("hwnd %p\n", hwnd
);
2354 check_wnd_state(button
, button
, button
, button
);
2356 ShowWindow(hwnd
, SW_SHOW
);
2358 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
2360 capture
= SetCapture(hwnd
);
2361 ok(capture
== button
, "SetCapture() = %p\n", capture
);
2363 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2365 DestroyWindow(hwnd
);
2366 check_wnd_state(button
, button
, button
, 0);
2368 DestroyWindow(button
);
2369 check_wnd_state(0, 0, 0, 0);
2372 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
2376 ShowWindow(hwnd1
, SW_HIDE
);
2377 ShowWindow(hwnd2
, SW_HIDE
);
2379 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
2380 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
2383 check_wnd_state(0, 0, 0, hwnd1
);
2386 check_wnd_state(0, 0, 0, hwnd2
);
2388 ShowWindow(hwnd1
, SW_SHOW
);
2389 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
2391 ret
= ReleaseCapture();
2392 ok (ret
, "releasecapture did not return TRUE.\n");
2393 ret
= ReleaseCapture();
2394 ok (ret
, "releasecapture did not return TRUE after second try.\n");
2397 static void test_keyboard_input(HWND hwnd
)
2402 ShowWindow(hwnd
, SW_SHOW
);
2406 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
2409 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2411 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2413 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2414 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2415 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2416 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2417 ok( !ret
, "message %04x available\n", msg
.message
);
2419 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2421 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2422 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2423 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2424 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2425 ok( !ret
, "message %04x available\n", msg
.message
);
2427 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2429 keybd_event(VK_SPACE
, 0, 0, 0);
2430 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2431 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2432 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2433 ok( !ret
, "message %04x available\n", msg
.message
);
2436 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2438 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
2440 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2441 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2442 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2443 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2444 ok( !ret
, "message %04x available\n", msg
.message
);
2446 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2448 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2449 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2450 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2451 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2452 ok( !ret
, "message %04x available\n", msg
.message
);
2454 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2456 keybd_event(VK_SPACE
, 0, 0, 0);
2457 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2458 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2459 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2460 ok( !ret
, "message %04x available\n", msg
.message
);
2463 static void test_mouse_input(HWND hwnd
)
2473 ShowWindow(hwnd
, SW_SHOW
);
2476 GetWindowRect(hwnd
, &rc
);
2477 trace("main window %p: (%d,%d)-(%d,%d)\n", hwnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2479 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
2480 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
2483 ShowWindow(popup
, SW_SHOW
);
2484 UpdateWindow(popup
);
2486 GetWindowRect(popup
, &rc
);
2487 trace("popup window %p: (%d,%d)-(%d,%d)\n", popup
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2489 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
2490 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
2491 trace("setting cursor to (%d,%d)\n", x
, y
);
2495 ok(x
== pt
.x
&& y
== pt
.y
, "wrong cursor pos (%d,%d), expected (%d,%d)\n", pt
.x
, pt
.y
, x
, y
);
2497 /* force the system to update its internal queue mouse position,
2498 * otherwise it won't generate relative mouse movements below.
2500 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2501 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2504 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2505 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2506 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2507 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
2508 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
2509 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2510 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2511 ok( !ret
, "message %04x available\n", msg
.message
);
2513 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2514 ShowWindow(popup
, SW_HIDE
);
2515 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2516 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2517 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2519 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2520 ShowWindow(hwnd
, SW_HIDE
);
2521 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2522 ok( !ret
, "message %04x available\n", msg
.message
);
2524 /* test mouse clicks */
2526 ShowWindow(hwnd
, SW_SHOW
);
2527 ShowWindow(popup
, SW_SHOW
);
2529 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2532 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2533 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2534 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2535 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2537 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2538 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2539 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2540 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2542 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2543 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2544 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2545 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2547 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2548 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2549 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2550 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2552 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2553 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2554 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2555 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2557 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2558 ok(!ret
, "message %04x available\n", msg
.message
);
2560 ShowWindow(popup
, SW_HIDE
);
2561 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2563 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2564 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2565 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2566 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2568 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2569 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2570 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2571 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2573 test_lbuttondown_flag
= TRUE
;
2574 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
2575 test_lbuttondown_flag
= FALSE
;
2577 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2578 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2579 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2580 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2581 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2583 /* Test WM_MOUSEACTIVATE */
2584 #define TEST_MOUSEACTIVATE(A,B) \
2585 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
2586 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
2588 TEST_MOUSEACTIVATE(HTERROR
,MA_ACTIVATE
);
2589 TEST_MOUSEACTIVATE(HTTRANSPARENT
,MA_ACTIVATE
);
2590 TEST_MOUSEACTIVATE(HTNOWHERE
,MA_ACTIVATE
);
2591 TEST_MOUSEACTIVATE(HTCLIENT
,MA_ACTIVATE
);
2592 TEST_MOUSEACTIVATE(HTCAPTION
,MA_ACTIVATE
);
2593 TEST_MOUSEACTIVATE(HTSYSMENU
,MA_ACTIVATE
);
2594 TEST_MOUSEACTIVATE(HTSIZE
,MA_ACTIVATE
);
2595 TEST_MOUSEACTIVATE(HTMENU
,MA_ACTIVATE
);
2596 TEST_MOUSEACTIVATE(HTHSCROLL
,MA_ACTIVATE
);
2597 TEST_MOUSEACTIVATE(HTVSCROLL
,MA_ACTIVATE
);
2598 TEST_MOUSEACTIVATE(HTMINBUTTON
,MA_ACTIVATE
);
2599 TEST_MOUSEACTIVATE(HTMAXBUTTON
,MA_ACTIVATE
);
2600 TEST_MOUSEACTIVATE(HTLEFT
,MA_ACTIVATE
);
2601 TEST_MOUSEACTIVATE(HTRIGHT
,MA_ACTIVATE
);
2602 TEST_MOUSEACTIVATE(HTTOP
,MA_ACTIVATE
);
2603 TEST_MOUSEACTIVATE(HTTOPLEFT
,MA_ACTIVATE
);
2604 TEST_MOUSEACTIVATE(HTTOPRIGHT
,MA_ACTIVATE
);
2605 TEST_MOUSEACTIVATE(HTBOTTOM
,MA_ACTIVATE
);
2606 TEST_MOUSEACTIVATE(HTBOTTOMLEFT
,MA_ACTIVATE
);
2607 TEST_MOUSEACTIVATE(HTBOTTOMRIGHT
,MA_ACTIVATE
);
2608 TEST_MOUSEACTIVATE(HTBORDER
,MA_ACTIVATE
);
2609 TEST_MOUSEACTIVATE(HTOBJECT
,MA_ACTIVATE
);
2610 TEST_MOUSEACTIVATE(HTCLOSE
,MA_ACTIVATE
);
2611 TEST_MOUSEACTIVATE(HTHELP
,MA_ACTIVATE
);
2613 /* Clear any messages left behind by WM_MOUSEACTIVATE tests */
2614 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2616 DestroyWindow(popup
);
2619 static void test_validatergn(HWND hwnd
)
2625 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
2626 ShowWindow(hwnd
, SW_SHOW
);
2627 UpdateWindow( hwnd
);
2628 /* test that ValidateRect validates children*/
2629 InvalidateRect( child
, NULL
, 1);
2630 GetWindowRect( child
, &rc
);
2631 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2632 ret
= GetUpdateRect( child
, &rc2
, 0);
2633 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
2634 "Update rectangle is empty!\n");
2635 ValidateRect( hwnd
, &rc
);
2636 ret
= GetUpdateRect( child
, &rc2
, 0);
2637 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2638 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
2639 rc2
.right
, rc2
.bottom
);
2641 /* now test ValidateRgn */
2642 InvalidateRect( child
, NULL
, 1);
2643 GetWindowRect( child
, &rc
);
2644 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2645 rgn
= CreateRectRgnIndirect( &rc
);
2646 ValidateRgn( hwnd
, rgn
);
2647 ret
= GetUpdateRect( child
, &rc2
, 0);
2648 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2649 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
2650 rc2
.right
, rc2
.bottom
);
2653 DestroyWindow( child
);
2656 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
2658 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
2659 GetWindowRect( hwnd
, prc
);
2660 trace("window rect is %d,%d - %d,%d\n",
2661 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2662 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
2663 trace("nccalc rect is %d,%d - %d,%d\n",
2664 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2667 static void test_nccalcscroll(HWND parent
)
2670 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
2671 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
2672 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
2673 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
2674 10, 10, 200, 200, parent
, 0, 0, NULL
);
2675 ShowWindow( parent
, SW_SHOW
);
2676 UpdateWindow( parent
);
2678 /* test window too low for a horizontal scroll bar */
2679 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
2680 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %d,%d - %d,%d\n",
2681 sbheight
, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2683 /* test window just high enough for a horizontal scroll bar */
2684 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
2685 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be %d size is %d,%d - %d,%d\n",
2686 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2688 /* test window too narrow for a vertical scroll bar */
2689 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
2690 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %d,%d - %d,%d\n",
2691 sbwidth
- 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2693 /* test window just wide enough for a vertical scroll bar */
2694 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2695 ok( rc1
.right
- rc1
.left
== 0, "Width should be %d size is %d,%d - %d,%d\n",
2696 0, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2698 /* same test, but with client edge: not enough width */
2699 SetWindowLong( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLong( hwnd
, GWL_EXSTYLE
));
2700 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2701 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
2702 "Width should be %d size is %d,%d - %d,%d\n",
2703 sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
), rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2705 DestroyWindow( hwnd
);
2708 static void test_SetParent(void)
2711 HWND desktop
= GetDesktopWindow();
2713 BOOL is_win9x
= GetWindowLongPtrW(desktop
, GWLP_WNDPROC
) == 0;
2714 HWND parent
, child1
, child2
, child3
, child4
, sibling
;
2716 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
2717 100, 100, 200, 200, 0, 0, 0, NULL
);
2718 assert(parent
!= 0);
2719 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2720 0, 0, 50, 50, parent
, 0, 0, NULL
);
2721 assert(child1
!= 0);
2722 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2723 0, 0, 50, 50, child1
, 0, 0, NULL
);
2724 assert(child2
!= 0);
2725 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2726 0, 0, 50, 50, child2
, 0, 0, NULL
);
2727 assert(child3
!= 0);
2728 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2729 0, 0, 50, 50, child3
, 0, 0, NULL
);
2730 assert(child4
!= 0);
2732 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
2733 parent
, child1
, child2
, child3
, child4
);
2735 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
2736 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
2737 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2738 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2739 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2742 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
2743 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
2744 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2745 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
2746 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2749 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
2751 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2753 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
2754 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
2755 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
2756 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
2757 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
2758 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
2760 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2763 if (!is_win9x
) /* Win9x doesn't survive this test */
2765 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
2766 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
2767 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
2768 ok(SetParent(parent
, child2
) != 0, "SetParent should not fail\n");
2769 ok(SetParent(parent
, child3
) != 0, "SetParent should not fail\n");
2770 ok(!SetParent(child2
, parent
), "SetParent should fail\n");
2771 ok(SetParent(parent
, child4
) != 0, "SetParent should not fail\n");
2773 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
2774 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
2775 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2776 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2777 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2780 hMenu
= CreateMenu();
2781 sibling
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
2782 100, 100, 200, 200, 0, hMenu
, 0, NULL
);
2783 assert(sibling
!= 0);
2785 ok(SetParent(sibling
, parent
) != 0, "SetParent should not fail\n");
2786 ok(GetMenu(sibling
) == hMenu
, "SetParent should not remove menu\n");
2788 ret
= DestroyWindow(parent
);
2789 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
2791 ok(!IsWindow(parent
), "parent still exists\n");
2792 ok(!IsWindow(sibling
), "sibling still exists\n");
2793 ok(!IsWindow(child1
), "child1 still exists\n");
2794 ok(!IsWindow(child2
), "child2 still exists\n");
2795 ok(!IsWindow(child3
), "child3 still exists\n");
2796 ok(!IsWindow(child4
), "child4 still exists\n");
2799 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2801 LPCREATESTRUCT lpcs
;
2808 lpcs
= (LPCREATESTRUCT
)lparam
;
2809 lpss
= (LPSTYLESTRUCT
)lpcs
->lpCreateParams
;
2812 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
2813 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
2814 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
2815 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
2817 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
2819 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
2820 "Ex style (0x%08lx) should match what the caller passed to CreateWindowEx (0x%08lx)\n",
2821 (lpss
->styleOld
& ~WS_EX_WINDOWEDGE
), (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
));
2823 ok(lpss
->styleNew
== lpcs
->style
,
2824 "Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
2825 lpss
->styleNew
, lpcs
->style
);
2829 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
2832 static ATOM atomStyleCheckClass
;
2834 static void register_style_check_class(void)
2842 GetModuleHandle(NULL
),
2844 LoadCursor(NULL
, IDC_ARROW
),
2845 (HBRUSH
)(COLOR_BTNFACE
+1),
2847 TEXT("WineStyleCheck"),
2850 atomStyleCheckClass
= RegisterClass(&wc
);
2853 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
2855 DWORD dwActualStyle
;
2856 DWORD dwActualExStyle
;
2859 HWND hwndParent
= NULL
;
2862 ss
.styleNew
= dwStyleIn
;
2863 ss
.styleOld
= dwExStyleIn
;
2865 if (dwStyleIn
& WS_CHILD
)
2867 hwndParent
= CreateWindowEx(0, MAKEINTATOM(atomStyleCheckClass
), NULL
,
2868 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
2871 hwnd
= CreateWindowEx(dwExStyleIn
, MAKEINTATOM(atomStyleCheckClass
), NULL
,
2872 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
2875 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
2877 TranslateMessage(&msg
);
2878 DispatchMessage(&msg
);
2881 dwActualStyle
= GetWindowLong(hwnd
, GWL_STYLE
);
2882 dwActualExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
2883 ok((dwActualStyle
== dwStyleOut
) && (dwActualExStyle
== dwExStyleOut
),
2884 "Style (0x%08x) should really be 0x%08x and/or Ex style (0x%08x) should really be 0x%08x\n",
2885 dwActualStyle
, dwStyleOut
, dwActualExStyle
, dwExStyleOut
);
2887 DestroyWindow(hwnd
);
2888 if (hwndParent
) DestroyWindow(hwndParent
);
2891 /* tests what window styles the window manager automatically adds */
2892 static void test_window_styles(void)
2894 register_style_check_class();
2896 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
2897 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
2898 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
2899 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
2900 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
2901 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
2902 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
2903 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
2904 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
2905 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
2906 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
2909 static void test_scrollvalidate( HWND parent
)
2912 HRGN hrgn
=CreateRectRgn(0,0,0,0);
2913 HRGN exprgn
, tmprgn
, clipping
;
2914 RECT rc
, rcu
, cliprc
;
2915 /* create two overlapping child windows. The visual region
2916 * of hwnd1 is clipped by the overlapping part of
2917 * hwnd2 because of the WS_CLIPSIBLING style */
2920 clipping
= CreateRectRgn(0,0,0,0);
2921 tmprgn
= CreateRectRgn(0,0,0,0);
2922 exprgn
= CreateRectRgn(0,0,0,0);
2923 hwnd2
= CreateWindowExA(0, "static", NULL
,
2924 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
2925 75, 30, 100, 100, parent
, 0, 0, NULL
);
2926 hwnd1
= CreateWindowExA(0, "static", NULL
,
2927 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
2928 25, 50, 100, 100, parent
, 0, 0, NULL
);
2929 ShowWindow( parent
, SW_SHOW
);
2930 UpdateWindow( parent
);
2931 GetClientRect( hwnd1
, &rc
);
2933 SetRectRgn( clipping
, 10, 10, 90, 90);
2934 hdc
= GetDC( hwnd1
);
2935 /* for a visual touch */
2936 TextOut( hdc
, 0,10, "0123456789", 10);
2937 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
2938 if (winetest_debug
> 0) dump_region(hrgn
);
2939 /* create a region with what is expected */
2940 SetRectRgn( exprgn
, 39,0,49,74);
2941 SetRectRgn( tmprgn
, 88,79,98,93);
2942 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2943 SetRectRgn( tmprgn
, 0,93,98,98);
2944 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2945 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2946 trace("update rect is %d,%d - %d,%d\n",
2947 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
2948 /* now with clipping region */
2949 SelectClipRgn( hdc
, clipping
);
2950 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
2951 if (winetest_debug
> 0) dump_region(hrgn
);
2952 /* create a region with what is expected */
2953 SetRectRgn( exprgn
, 39,10,49,74);
2954 SetRectRgn( tmprgn
, 80,79,90,85);
2955 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2956 SetRectRgn( tmprgn
, 10,85,90,90);
2957 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2958 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2959 trace("update rect is %d,%d - %d,%d\n",
2960 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
2961 ReleaseDC( hwnd1
, hdc
);
2963 /* test scrolling a window with an update region */
2964 DestroyWindow( hwnd2
);
2965 ValidateRect( hwnd1
, NULL
);
2966 SetRect( &rc
, 40,40, 50,50);
2967 InvalidateRect( hwnd1
, &rc
, 1);
2968 GetClientRect( hwnd1
, &rc
);
2970 ScrollWindowEx( hwnd1
, -10, 0, &rc
, &cliprc
, hrgn
, &rcu
,
2971 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
2972 if (winetest_debug
> 0) dump_region(hrgn
);
2973 SetRectRgn( exprgn
, 88,0,98,98);
2974 SetRectRgn( tmprgn
, 30, 40, 50, 50);
2975 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2976 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2978 /* now test ScrollWindowEx with a combination of
2979 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
2980 /* make hwnd2 the child of hwnd1 */
2981 hwnd2
= CreateWindowExA(0, "static", NULL
,
2982 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
2983 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
2984 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
2985 GetClientRect( hwnd1
, &rc
);
2988 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
2989 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
2990 ValidateRect( hwnd1
, NULL
);
2991 ValidateRect( hwnd2
, NULL
);
2992 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
2993 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
2994 if (winetest_debug
> 0) dump_region(hrgn
);
2995 SetRectRgn( exprgn
, 88,0,98,88);
2996 SetRectRgn( tmprgn
, 0,88,98,98);
2997 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2998 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3000 /* SW_SCROLLCHILDREN */
3001 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
3002 ValidateRect( hwnd1
, NULL
);
3003 ValidateRect( hwnd2
, NULL
);
3004 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
3005 if (winetest_debug
> 0) dump_region(hrgn
);
3006 /* expected region is the same as in previous test */
3007 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3009 /* no SW_SCROLLCHILDREN */
3010 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
3011 ValidateRect( hwnd1
, NULL
);
3012 ValidateRect( hwnd2
, NULL
);
3013 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
3014 if (winetest_debug
> 0) dump_region(hrgn
);
3015 /* expected region is the same as in previous test */
3016 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3018 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
3019 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
3020 ValidateRect( hwnd1
, NULL
);
3021 ValidateRect( hwnd2
, NULL
);
3022 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
3023 if (winetest_debug
> 0) dump_region(hrgn
);
3024 SetRectRgn( exprgn
, 88,0,98,20);
3025 SetRectRgn( tmprgn
, 20,20,98,30);
3026 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3027 SetRectRgn( tmprgn
, 20,30,30,88);
3028 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3029 SetRectRgn( tmprgn
, 0,88,30,98);
3030 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3031 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3034 DeleteObject( hrgn
);
3035 DeleteObject( exprgn
);
3036 DeleteObject( tmprgn
);
3037 DestroyWindow( hwnd1
);
3038 DestroyWindow( hwnd2
);
3041 /* couple of tests of return values of scrollbar functions
3042 * called on a scrollbarless window */
3043 static void test_scroll(void)
3048 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
3049 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
3050 100, 100, 200, 200, 0, 0, 0, NULL
);
3052 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
3053 ok( ret
, "GetScrollRange returns FALSE\n");
3054 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
3055 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
3056 si
.cbSize
= sizeof( si
);
3057 si
.fMask
= SIF_PAGE
;
3058 si
.nPage
= 0xdeadbeef;
3059 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
3060 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
3061 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
3063 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
3064 ok( ret
, "GetScrollRange returns FALSE\n");
3065 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
3066 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
3067 si
.cbSize
= sizeof( si
);
3068 si
.fMask
= SIF_PAGE
;
3069 si
.nPage
= 0xdeadbeef;
3070 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
3071 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
3072 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
3074 DestroyWindow( hwnd
);
3077 static void test_scrolldc( HWND parent
)
3080 HRGN exprgn
, tmprgn
, hrgn
;
3081 RECT rc
, rc2
, rcu
, cliprc
;
3085 hrgn
= CreateRectRgn(0,0,0,0);
3086 tmprgn
= CreateRectRgn(0,0,0,0);
3087 exprgn
= CreateRectRgn(0,0,0,0);
3089 hwnd1
= CreateWindowExA(0, "static", NULL
,
3090 WS_CHILD
| WS_VISIBLE
,
3091 25, 50, 100, 100, parent
, 0, 0, NULL
);
3092 ShowWindow( parent
, SW_SHOW
);
3093 UpdateWindow( parent
);
3094 GetClientRect( hwnd1
, &rc
);
3095 hdc
= GetDC( hwnd1
);
3096 /* paint the upper half of the window black */
3098 rc2
.bottom
= ( rc
.top
+ rc
.bottom
) /2;
3099 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3100 /* clip region is the lower half */
3102 cliprc
.top
= (rc
.top
+ rc
.bottom
) /2;
3103 /* test whether scrolled pixels are properly clipped */
3104 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
3105 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3106 /* this scroll should not cause any visible changes */
3107 ScrollDC( hdc
, 5, -20, &rc
, &cliprc
, hrgn
, &rcu
);
3108 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
3109 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3110 /* test with NULL clip rect */
3111 ScrollDC( hdc
, 20, -20, &rc
, NULL
, hrgn
, &rcu
);
3112 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
3113 trace("update rect: %d,%d - %d,%d\n",
3114 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
3115 if (winetest_debug
> 0) dump_region(hrgn
);
3116 SetRect(&rc2
, 0, 0, 100, 100);
3117 ok(EqualRect(&rcu
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
3118 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
3120 SetRectRgn( exprgn
, 0, 0, 20, 80);
3121 SetRectRgn( tmprgn
, 0, 80, 100, 100);
3122 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
3123 if (winetest_debug
> 0) dump_region(exprgn
);
3124 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
3125 /* test clip rect > scroll rect */
3126 FillRect( hdc
, &rc
, GetStockObject(WHITE_BRUSH
));
3128 InflateRect( &rc2
, -(rc
.right
-rc
.left
)/4, -(rc
.bottom
-rc
.top
)/4);
3129 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3130 ScrollDC( hdc
, 10, 10, &rc2
, &rc
, hrgn
, &rcu
);
3131 SetRectRgn( exprgn
, 25, 25, 75, 35);
3132 SetRectRgn( tmprgn
, 25, 35, 35, 75);
3133 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
3134 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
3135 colr
= GetPixel( hdc
, 80, 80);
3136 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3137 trace("update rect: %d,%d - %d,%d\n",
3138 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
3139 if (winetest_debug
> 0) dump_region(hrgn
);
3143 DeleteObject(exprgn
);
3144 DeleteObject(tmprgn
);
3145 DestroyWindow(hwnd1
);
3148 static void test_params(void)
3153 /* Just a param check */
3154 SetLastError(0xdeadbeef);
3155 rc
= GetWindowText(hwndMain2
, NULL
, 1024);
3156 ok( rc
==0, "GetWindowText: rc=%d err=%d\n",rc
,GetLastError());
3158 SetLastError(0xdeadbeef);
3159 hwnd
=CreateWindow("LISTBOX", "TestList",
3160 (LBS_STANDARD
& ~LBS_SORT
),
3162 NULL
, (HMENU
)1, NULL
, 0);
3164 ok(!hwnd
, "CreateWindow with invalid menu handle should fail\n");
3165 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
|| /* NT */
3166 GetLastError() == 0xdeadbeef, /* Win9x */
3167 "wrong last error value %d\n", GetLastError());
3170 static void test_AWRwindow(LPCSTR
class, LONG style
, LONG exStyle
, BOOL menu
)
3174 hwnd
= CreateWindowEx(exStyle
, class, class, style
,
3181 trace("Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style
, exStyle
);
3184 ShowWindow(hwnd
, SW_SHOW
);
3186 test_nonclient_area(hwnd
);
3189 DestroyWindow(hwnd
);
3192 static BOOL
AWR_init(void)
3196 class.style
= CS_HREDRAW
| CS_VREDRAW
;
3197 class.lpfnWndProc
= DefWindowProcA
;
3198 class.cbClsExtra
= 0;
3199 class.cbWndExtra
= 0;
3200 class.hInstance
= 0;
3201 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
3202 class.hCursor
= LoadCursor (0, IDC_ARROW
);
3203 class.hbrBackground
= 0;
3204 class.lpszMenuName
= 0;
3205 class.lpszClassName
= szAWRClass
;
3207 if (!RegisterClass (&class)) {
3208 ok(FALSE
, "RegisterClass failed\n");
3212 hmenu
= CreateMenu();
3215 ok(hmenu
!= 0, "Failed to create menu\n");
3216 ok(AppendMenu(hmenu
, MF_STRING
, 1, "Test!"), "Failed to create menu item\n");
3222 static void test_AWR_window_size(BOOL menu
)
3226 WS_MAXIMIZE
, WS_BORDER
, WS_DLGFRAME
,
3229 WS_MINIMIZEBOX
, WS_MAXIMIZEBOX
,
3230 WS_HSCROLL
, WS_VSCROLL
3234 WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
,
3237 /* These styles have problems on (at least) WinXP (SP2) and Wine */
3238 WS_EX_DLGMODALFRAME
,
3245 /* A exhaustive check of all the styles takes too long
3246 * so just do a (hopefully representative) sample
3248 for (i
= 0; i
< COUNTOF(styles
); ++i
)
3249 test_AWRwindow(szAWRClass
, styles
[i
], 0, menu
);
3250 for (i
= 0; i
< COUNTOF(exStyles
); ++i
) {
3251 test_AWRwindow(szAWRClass
, WS_POPUP
, exStyles
[i
], menu
);
3252 test_AWRwindow(szAWRClass
, WS_THICKFRAME
, exStyles
[i
], menu
);
3257 #define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
3259 static void test_AdjustWindowRect(void)
3264 SHOWSYSMETRIC(SM_CYCAPTION
);
3265 SHOWSYSMETRIC(SM_CYSMCAPTION
);
3266 SHOWSYSMETRIC(SM_CYMENU
);
3267 SHOWSYSMETRIC(SM_CXEDGE
);
3268 SHOWSYSMETRIC(SM_CYEDGE
);
3269 SHOWSYSMETRIC(SM_CXVSCROLL
);
3270 SHOWSYSMETRIC(SM_CYHSCROLL
);
3271 SHOWSYSMETRIC(SM_CXFRAME
);
3272 SHOWSYSMETRIC(SM_CYFRAME
);
3273 SHOWSYSMETRIC(SM_CXDLGFRAME
);
3274 SHOWSYSMETRIC(SM_CYDLGFRAME
);
3275 SHOWSYSMETRIC(SM_CXBORDER
);
3276 SHOWSYSMETRIC(SM_CYBORDER
);
3278 test_AWR_window_size(FALSE
);
3279 test_AWR_window_size(TRUE
);
3283 #undef SHOWSYSMETRIC
3286 /* Global variables to trigger exit from loop */
3287 static int redrawComplete
, WMPAINT_count
;
3289 static LRESULT WINAPI
redraw_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3294 trace("doing WM_PAINT %d\n", WMPAINT_count
);
3296 if (WMPAINT_count
> 10 && redrawComplete
== 0) {
3298 BeginPaint(hwnd
, &ps
);
3299 EndPaint(hwnd
, &ps
);
3305 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3308 /* Ensure we exit from RedrawNow regardless of invalidated area */
3309 static void test_redrawnow(void)
3314 cls
.style
= CS_DBLCLKS
;
3315 cls
.lpfnWndProc
= redraw_window_procA
;
3318 cls
.hInstance
= GetModuleHandleA(0);
3320 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3321 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3322 cls
.lpszMenuName
= NULL
;
3323 cls
.lpszClassName
= "RedrawWindowClass";
3325 if(!RegisterClassA(&cls
)) {
3326 trace("Register failed %d\n", GetLastError());
3330 hwndMain
= CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
3331 CW_USEDEFAULT
, 0, 100, 100, NULL
, NULL
, 0, NULL
);
3333 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3334 ShowWindow(hwndMain
, SW_SHOW
);
3335 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3336 RedrawWindow(hwndMain
, NULL
,NULL
,RDW_UPDATENOW
| RDW_ALLCHILDREN
);
3337 ok( WMPAINT_count
== 1, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3338 redrawComplete
= TRUE
;
3339 ok( WMPAINT_count
< 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count
);
3342 DestroyWindow( hwndMain
);
3345 struct parentdc_stat
{
3351 struct parentdc_test
{
3352 struct parentdc_stat main
, main_todo
;
3353 struct parentdc_stat child1
, child1_todo
;
3354 struct parentdc_stat child2
, child2_todo
;
3357 static LRESULT WINAPI
parentdc_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3362 struct parentdc_stat
*t
= (struct parentdc_stat
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
3367 trace("doing WM_PAINT on %p\n", hwnd
);
3368 GetClientRect(hwnd
, &rc
);
3369 CopyRect(&t
->client
, &rc
);
3370 trace("client rect (%d, %d)-(%d, %d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3371 GetWindowRect(hwnd
, &rc
);
3372 trace("window rect (%d, %d)-(%d, %d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3373 BeginPaint(hwnd
, &ps
);
3374 CopyRect(&t
->paint
, &ps
.rcPaint
);
3375 GetClipBox(ps
.hdc
, &rc
);
3376 CopyRect(&t
->clip
, &rc
);
3377 trace("clip rect (%d, %d)-(%d, %d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3378 trace("paint rect (%d, %d)-(%d, %d)\n", ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
3379 EndPaint(hwnd
, &ps
);
3382 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3385 static void zero_parentdc_stat(struct parentdc_stat
*t
)
3387 SetRectEmpty(&t
->client
);
3388 SetRectEmpty(&t
->clip
);
3389 SetRectEmpty(&t
->paint
);
3392 static void zero_parentdc_test(struct parentdc_test
*t
)
3394 zero_parentdc_stat(&t
->main
);
3395 zero_parentdc_stat(&t
->child1
);
3396 zero_parentdc_stat(&t
->child2
);
3399 #define parentdc_field_ok(t, w, r, f, got) \
3400 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
3401 ": expected %d, got %d\n", \
3404 #define parentdc_todo_field_ok(t, w, r, f, got) \
3405 if (t.w##_todo.r.f) todo_wine { parentdc_field_ok(t, w, r, f, got); } \
3406 else parentdc_field_ok(t, w, r, f, got)
3408 #define parentdc_rect_ok(t, w, r, got) \
3409 parentdc_todo_field_ok(t, w, r, left, got); \
3410 parentdc_todo_field_ok(t, w, r, top, got); \
3411 parentdc_todo_field_ok(t, w, r, right, got); \
3412 parentdc_todo_field_ok(t, w, r, bottom, got);
3414 #define parentdc_win_ok(t, w, got) \
3415 parentdc_rect_ok(t, w, client, got); \
3416 parentdc_rect_ok(t, w, clip, got); \
3417 parentdc_rect_ok(t, w, paint, got);
3419 #define parentdc_ok(t, got) \
3420 parentdc_win_ok(t, main, got); \
3421 parentdc_win_ok(t, child1, got); \
3422 parentdc_win_ok(t, child2, got);
3424 static void test_csparentdc(void)
3426 WNDCLASSA clsMain
, cls
;
3427 HWND hwndMain
, hwnd1
, hwnd2
;
3431 struct parentdc_test test_answer
;
3433 #define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
3434 const struct parentdc_test test1
=
3436 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo
,
3437 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3438 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3441 const struct parentdc_test test2
=
3443 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo
,
3444 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3445 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3448 const struct parentdc_test test3
=
3450 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3451 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3452 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3455 const struct parentdc_test test4
=
3457 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo
,
3458 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo
,
3459 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3462 const struct parentdc_test test5
=
3464 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo
,
3465 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3466 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3469 const struct parentdc_test test6
=
3471 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3472 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3473 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3476 const struct parentdc_test test7
=
3478 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3479 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3480 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3484 clsMain
.style
= CS_DBLCLKS
;
3485 clsMain
.lpfnWndProc
= parentdc_window_procA
;
3486 clsMain
.cbClsExtra
= 0;
3487 clsMain
.cbWndExtra
= 0;
3488 clsMain
.hInstance
= GetModuleHandleA(0);
3490 clsMain
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3491 clsMain
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3492 clsMain
.lpszMenuName
= NULL
;
3493 clsMain
.lpszClassName
= "ParentDcMainWindowClass";
3495 if(!RegisterClassA(&clsMain
)) {
3496 trace("Register failed %d\n", GetLastError());
3500 cls
.style
= CS_DBLCLKS
| CS_PARENTDC
;
3501 cls
.lpfnWndProc
= parentdc_window_procA
;
3504 cls
.hInstance
= GetModuleHandleA(0);
3506 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3507 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3508 cls
.lpszMenuName
= NULL
;
3509 cls
.lpszClassName
= "ParentDcWindowClass";
3511 if(!RegisterClassA(&cls
)) {
3512 trace("Register failed %d\n", GetLastError());
3516 SetRect(&rc
, 0, 0, 150, 150);
3517 AdjustWindowRectEx(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
, 0);
3518 hwndMain
= CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
3519 CW_USEDEFAULT
, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, NULL
, NULL
, 0, NULL
);
3520 SetWindowLongPtrA(hwndMain
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.main
);
3521 hwnd1
= CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD
,
3522 20, 20, 40, 40, hwndMain
, NULL
, 0, NULL
);
3523 SetWindowLongPtrA(hwnd1
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child1
);
3524 hwnd2
= CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD
,
3525 40, 40, 40, 40, hwndMain
, NULL
, 0, NULL
);
3526 SetWindowLongPtrA(hwnd2
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child2
);
3527 ShowWindow(hwndMain
, SW_SHOW
);
3528 ShowWindow(hwnd1
, SW_SHOW
);
3529 ShowWindow(hwnd2
, SW_SHOW
);
3532 zero_parentdc_test(&test_answer
);
3533 InvalidateRect(hwndMain
, NULL
, TRUE
);
3534 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3535 parentdc_ok(test1
, test_answer
);
3537 zero_parentdc_test(&test_answer
);
3538 SetRect(&rc
, 0, 0, 50, 50);
3539 InvalidateRect(hwndMain
, &rc
, TRUE
);
3540 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3541 parentdc_ok(test2
, test_answer
);
3543 zero_parentdc_test(&test_answer
);
3544 SetRect(&rc
, 0, 0, 10, 10);
3545 InvalidateRect(hwndMain
, &rc
, TRUE
);
3546 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3547 parentdc_ok(test3
, test_answer
);
3549 zero_parentdc_test(&test_answer
);
3550 SetRect(&rc
, 40, 40, 50, 50);
3551 InvalidateRect(hwndMain
, &rc
, TRUE
);
3552 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3553 parentdc_ok(test4
, test_answer
);
3555 zero_parentdc_test(&test_answer
);
3556 SetRect(&rc
, 20, 20, 60, 60);
3557 InvalidateRect(hwndMain
, &rc
, TRUE
);
3558 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3559 parentdc_ok(test5
, test_answer
);
3561 zero_parentdc_test(&test_answer
);
3562 SetRect(&rc
, 0, 0, 10, 10);
3563 InvalidateRect(hwnd1
, &rc
, TRUE
);
3564 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3565 parentdc_ok(test6
, test_answer
);
3567 zero_parentdc_test(&test_answer
);
3568 SetRect(&rc
, -5, -5, 65, 65);
3569 InvalidateRect(hwnd1
, &rc
, TRUE
);
3570 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3571 parentdc_ok(test7
, test_answer
);
3573 DestroyWindow(hwndMain
);
3574 DestroyWindow(hwnd1
);
3575 DestroyWindow(hwnd2
);
3578 static void test_IsWindowUnicode(void)
3580 static const char ansi_class_nameA
[] = "ansi class name";
3581 static const WCHAR ansi_class_nameW
[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
3582 static const char unicode_class_nameA
[] = "unicode class name";
3583 static const WCHAR unicode_class_nameW
[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
3588 memset(&classW
, 0, sizeof(classW
));
3589 classW
.hInstance
= GetModuleHandleA(0);
3590 classW
.lpfnWndProc
= DefWindowProcW
;
3591 classW
.lpszClassName
= unicode_class_nameW
;
3592 if (!RegisterClassW(&classW
)) return;
3594 memset(&classA
, 0, sizeof(classA
));
3595 classA
.hInstance
= GetModuleHandleA(0);
3596 classA
.lpfnWndProc
= DefWindowProcA
;
3597 classA
.lpszClassName
= ansi_class_nameA
;
3598 assert(RegisterClassA(&classA
));
3600 /* unicode class: window proc */
3601 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
3602 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3605 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3606 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3607 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3608 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3609 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3611 DestroyWindow(hwnd
);
3613 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
3614 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3617 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3618 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3619 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3620 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3621 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3623 DestroyWindow(hwnd
);
3625 /* ansi class: window proc */
3626 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
3627 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3630 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3631 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3632 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3633 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3634 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3636 DestroyWindow(hwnd
);
3638 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
3639 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3642 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3643 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3644 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3645 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3646 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3648 DestroyWindow(hwnd
);
3650 /* unicode class: class proc */
3651 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
3652 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3655 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3656 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3657 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3658 /* do not restore class window proc back to unicode */
3660 DestroyWindow(hwnd
);
3662 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
3663 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3666 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3667 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3668 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3670 DestroyWindow(hwnd
);
3672 /* ansi class: class proc */
3673 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
3674 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3677 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3678 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3679 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3680 /* do not restore class window proc back to ansi */
3682 DestroyWindow(hwnd
);
3684 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
3685 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3688 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3689 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3690 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3692 DestroyWindow(hwnd
);
3695 static void test_CreateWindow(void)
3700 #define expect_menu(window, menu) \
3701 SetLastError(0xdeadbeef); \
3702 ok(GetMenu(window) == (HMENU)menu, "GetMenu error %d\n", GetLastError())
3704 #define expect_style(window, style)\
3705 ok(GetWindowLong(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLong(window, GWL_STYLE))
3707 #define expect_ex_style(window, ex_style)\
3708 ok(GetWindowLong(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLong(window, GWL_EXSTYLE))
3710 hmenu
= CreateMenu();
3712 parent
= GetDesktopWindow();
3713 assert(parent
!= 0);
3715 SetLastError(0xdeadbeef);
3716 ok(IsMenu(hmenu
), "IsMenu error %d\n", GetLastError());
3719 SetLastError(0xdeadbeef);
3720 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
,
3721 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3722 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3723 expect_menu(hwnd
, 1);
3724 expect_style(hwnd
, WS_CHILD
);
3725 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
3726 DestroyWindow(hwnd
);
3728 SetLastError(0xdeadbeef);
3729 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_CAPTION
,
3730 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3731 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3732 expect_menu(hwnd
, 1);
3733 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
3734 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
3735 DestroyWindow(hwnd
);
3737 SetLastError(0xdeadbeef);
3738 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
,
3739 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3740 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3741 expect_menu(hwnd
, 1);
3742 expect_style(hwnd
, WS_CHILD
);
3743 expect_ex_style(hwnd
, 0);
3744 DestroyWindow(hwnd
);
3746 SetLastError(0xdeadbeef);
3747 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_CAPTION
,
3748 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3749 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3750 expect_menu(hwnd
, 1);
3751 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
3752 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
3753 DestroyWindow(hwnd
);
3756 SetLastError(0xdeadbeef);
3757 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
3758 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3759 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3760 expect_menu(hwnd
, hmenu
);
3761 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
3762 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
3763 DestroyWindow(hwnd
);
3764 SetLastError(0xdeadbeef);
3765 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3766 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3768 hmenu
= CreateMenu();
3770 SetLastError(0xdeadbeef);
3771 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
| WS_CAPTION
,
3772 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3773 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3774 expect_menu(hwnd
, hmenu
);
3775 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
3776 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
3777 DestroyWindow(hwnd
);
3778 SetLastError(0xdeadbeef);
3779 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3780 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3782 hmenu
= CreateMenu();
3784 SetLastError(0xdeadbeef);
3785 hwnd
= CreateWindowEx(0, "static", NULL
, WS_POPUP
,
3786 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3787 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3788 expect_menu(hwnd
, hmenu
);
3789 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
3790 expect_ex_style(hwnd
, 0);
3791 DestroyWindow(hwnd
);
3792 SetLastError(0xdeadbeef);
3793 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3794 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3796 hmenu
= CreateMenu();
3798 SetLastError(0xdeadbeef);
3799 hwnd
= CreateWindowEx(0, "static", NULL
, WS_POPUP
| WS_CAPTION
,
3800 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3801 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3802 expect_menu(hwnd
, hmenu
);
3803 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
3804 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
3805 DestroyWindow(hwnd
);
3806 SetLastError(0xdeadbeef);
3807 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3808 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3810 /* WS_CHILD | WS_POPUP */
3811 SetLastError(0xdeadbeef);
3812 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
3813 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3814 ok(!hwnd
, "CreateWindowEx should fail\n");
3815 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3817 hmenu
= CreateMenu();
3819 SetLastError(0xdeadbeef);
3820 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
3821 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3822 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3823 expect_menu(hwnd
, hmenu
);
3824 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
3825 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
3826 DestroyWindow(hwnd
);
3827 SetLastError(0xdeadbeef);
3828 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3829 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3831 SetLastError(0xdeadbeef);
3832 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
3833 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3834 ok(!hwnd
, "CreateWindowEx should fail\n");
3835 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3837 hmenu
= CreateMenu();
3839 SetLastError(0xdeadbeef);
3840 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
3841 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3842 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3843 expect_menu(hwnd
, hmenu
);
3844 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
3845 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
3846 DestroyWindow(hwnd
);
3847 SetLastError(0xdeadbeef);
3848 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3849 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3851 SetLastError(0xdeadbeef);
3852 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
3853 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3854 ok(!hwnd
, "CreateWindowEx should fail\n");
3855 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3857 hmenu
= CreateMenu();
3859 SetLastError(0xdeadbeef);
3860 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
3861 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3862 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3863 expect_menu(hwnd
, hmenu
);
3864 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
3865 expect_ex_style(hwnd
, 0);
3866 DestroyWindow(hwnd
);
3867 SetLastError(0xdeadbeef);
3868 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3869 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3871 SetLastError(0xdeadbeef);
3872 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
3873 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
3874 ok(!hwnd
, "CreateWindowEx should fail\n");
3875 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3877 hmenu
= CreateMenu();
3879 SetLastError(0xdeadbeef);
3880 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
3881 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
3882 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
3883 expect_menu(hwnd
, hmenu
);
3884 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
3885 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
3886 DestroyWindow(hwnd
);
3887 SetLastError(0xdeadbeef);
3888 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
3889 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
3893 #undef expect_ex_style
3896 /* function that remembers whether the system the test is running on sets the
3897 * last error for user32 functions to make the tests stricter */
3898 static int check_error(DWORD actual
, DWORD expected
)
3900 static int sets_last_error
= -1;
3901 if (sets_last_error
== -1)
3902 sets_last_error
= (actual
!= 0xdeadbeef);
3903 return (!sets_last_error
&& (actual
== 0xdeadbeef)) || (actual
== expected
);
3906 static void test_SetWindowLong(void)
3909 WNDPROC old_window_procW
;
3911 SetLastError(0xdeadbeef);
3912 retval
= SetWindowLongPtr(NULL
, GWLP_WNDPROC
, 0);
3913 ok(!retval
, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%x\n", retval
);
3914 ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE
),
3915 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instad of %d\n", GetLastError());
3917 SetLastError(0xdeadbeef);
3918 retval
= SetWindowLongPtr(hwndMain
, 0xdeadbeef, 0);
3919 ok(!retval
, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%x\n", retval
);
3920 ok(check_error(GetLastError(), ERROR_INVALID_INDEX
),
3921 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instad of %d\n", GetLastError());
3923 SetLastError(0xdeadbeef);
3924 retval
= SetWindowLongPtr(hwndMain
, GWLP_WNDPROC
, 0);
3925 ok((WNDPROC
)retval
== main_window_procA
,
3926 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%x\n", retval
);
3927 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
3928 retval
= GetWindowLongPtr(hwndMain
, GWLP_WNDPROC
);
3929 ok((WNDPROC
)retval
== main_window_procA
,
3930 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%x\n", retval
);
3931 ok(!IsWindowUnicode(hwndMain
), "hwndMain shouldn't be Unicode\n");
3933 old_window_procW
= (WNDPROC
)GetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
);
3934 SetLastError(0xdeadbeef);
3935 retval
= SetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
, 0);
3936 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED
)
3938 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
3939 ok(retval
!= 0, "SetWindowLongPtr error %d\n", GetLastError());
3940 ok((WNDPROC
)retval
== old_window_procW
,
3941 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%x\n", retval
);
3942 ok(IsWindowUnicode(hwndMain
), "hwndMain should now be Unicode\n");
3944 /* set it back to ANSI */
3945 SetWindowLongPtr(hwndMain
, GWLP_WNDPROC
, 0);
3951 pGetAncestor
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
3952 pGetWindowInfo
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetWindowInfo" );
3954 hwndMain
= CreateWindowExA(0, "static", NULL
, 0, 0, 0, 0, 0, HWND_MESSAGE
, 0, 0, NULL
);
3957 ok(!GetParent(hwndMain
), "GetParent should return 0 for message only windows\n");
3960 hwndMessage
= pGetAncestor(hwndMain
, GA_PARENT
);
3961 ok(hwndMessage
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message only windows\n");
3962 trace("hwndMessage %p\n", hwndMessage
);
3964 DestroyWindow(hwndMain
);
3967 trace("CreateWindowExA with parent HWND_MESSAGE failed\n");
3969 if (!RegisterWindowClasses()) assert(0);
3971 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
3974 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
3975 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3976 WS_MAXIMIZEBOX
| WS_POPUP
,
3979 test_nonclient_area(hwndMain
);
3981 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
3982 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3983 WS_MAXIMIZEBOX
| WS_POPUP
,
3987 assert( hwndMain2
);
3989 /* Add the tests below this line */
3994 test_capture_3(hwndMain
, hwndMain2
);
3996 test_CreateWindow();
3997 test_parent_owner();
3999 test_shell_window();
4003 test_SetWindowPos(hwndMain
);
4004 test_SetMenu(hwndMain
);
4005 test_SetFocus(hwndMain
);
4006 test_SetActiveWindow(hwndMain
);
4007 test_SetForegroundWindow(hwndMain
);
4009 test_children_zorder(hwndMain
);
4010 test_keyboard_input(hwndMain
);
4011 test_mouse_input(hwndMain
);
4012 test_validatergn(hwndMain
);
4013 test_nccalcscroll( hwndMain
);
4014 test_scrollvalidate( hwndMain
);
4015 test_scrolldc( hwndMain
);
4017 test_IsWindowUnicode();
4018 test_vis_rgn(hwndMain
);
4020 test_AdjustWindowRect();
4021 test_window_styles();
4024 test_SetWindowLong();
4026 /* add the tests above this line */
4027 UnhookWindowsHookEx(hhook
);