2 * Unit tests for window handling
4 * Copyright 2002 Bill Medland
5 * Copyright 2002 Alexandre Julliard
6 * Copyright 2003 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 /* To get ICON_SMALL2 with the MSVC headers */
24 #define _WIN32_WINNT 0x0501
26 #define NONAMELESSUNION
27 #define NONAMELESSSTRUCT
39 #include "wine/test.h"
41 #ifndef SPI_GETDESKWALLPAPER
42 #define SPI_GETDESKWALLPAPER 0x0073
45 #define MAKEINTATOMA(atom) ((LPCSTR)((ULONG_PTR)((WORD)(atom))))
47 #define LONG_PTR INT_PTR
48 #define ULONG_PTR UINT_PTR
50 void dump_region(HRGN hrgn
);
52 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
53 static BOOL (WINAPI
*pGetWindowInfo
)(HWND
,WINDOWINFO
*);
55 static BOOL test_lbuttondown_flag
;
56 static HWND hwndMessage
;
57 static HWND hwndMain
, hwndMain2
;
60 static const char* szAWRClass
= "Winsize";
63 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
65 /* try to make sure pending X events have been processed before continuing */
66 static void flush_events(void)
70 DWORD time
= GetTickCount() + diff
;
74 MsgWaitForMultipleObjects( 0, NULL
, FALSE
, diff
, QS_ALLINPUT
);
75 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
76 diff
= time
- GetTickCount();
80 /* check the values returned by the various parent/owner functions on a given window */
81 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
82 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
88 res
= pGetAncestor( hwnd
, GA_PARENT
);
89 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
91 res
= (HWND
)GetWindowLongPtrA( hwnd
, GWLP_HWNDPARENT
);
92 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
93 res
= GetParent( hwnd
);
94 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
95 res
= GetWindow( hwnd
, GW_OWNER
);
96 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
99 res
= pGetAncestor( hwnd
, GA_ROOT
);
100 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
101 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
102 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
106 BOOL CALLBACK
EnumChildProc( HWND hwndChild
, LPARAM lParam
)
109 trace("EnumChildProc on %p\n", hwndChild
);
110 if (*(LPINT
)lParam
> 1) return FALSE
;
114 /* will search for the given window */
115 BOOL CALLBACK
EnumChildProc1( HWND hwndChild
, LPARAM lParam
)
117 trace("EnumChildProc1 on %p\n", hwndChild
);
118 if ((HWND
)lParam
== hwndChild
) return FALSE
;
122 static HWND
create_tool_window( LONG style
, HWND parent
)
124 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
125 0, 0, 100, 100, parent
, 0, 0, NULL
);
126 ok( ret
!= 0, "Creation failed\n" );
130 /* test parent and owner values for various combinations */
131 static void test_parent_owner(void)
134 HWND test
, owner
, ret
;
135 HWND desktop
= GetDesktopWindow();
136 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
139 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
141 /* child without parent, should fail */
142 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
143 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
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 (%ld,%ld), ptMaxSize (%ld,%ld), ptMaxPosition (%ld,%ld)\n"
552 " ptMinTrackSize (%ld,%ld), ptMaxTrackSize (%ld,%ld)\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: (%ld,%ld)-(%ld,%ld)\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: (%ld,%ld)-(%ld,%ld)\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 (%ld,%ld-%ld,%ld) / (%ld,%ld-%ld,%ld)\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 %08lx\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 (%ld,%ld), ptMaxSize (%ld,%ld), ptMaxPosition (%ld,%ld)\n"
647 " ptMinTrackSize (%ld,%ld), ptMaxTrackSize (%ld,%ld)\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 %08lx\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: %08lx != %08lx\n", info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
));
727 ok(info
->dwExStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
728 "wrong dwExStyle: %08lx != %08lx\n", info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
));
729 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
730 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04lx != %04lx\n",
731 info
->dwWindowStatus
, status
);
733 if (test_borders
&& !IsRectEmpty(&rcWindow
))
735 trace("rcWindow: %ld,%ld - %ld,%ld\n", rcWindow
.left
, rcWindow
.top
, rcWindow
.right
, rcWindow
.bottom
);
736 trace("rcClient: %ld,%ld - %ld,%ld\n", rcClient
.left
, rcClient
.top
, rcClient
.right
, rcClient
.bottom
);
738 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
739 "wrong cxWindowBorders %d != %ld\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
740 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
741 ok(info
->cyWindowBorders
== border
,
742 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
745 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType\n");
746 ok(info
->wCreatorVersion
== 0x0400, "wrong wCreatorVersion %04x\n", info
->wCreatorVersion
);
749 static void FixedAdjustWindowRectEx(RECT
* rc
, LONG style
, BOOL menu
, LONG exstyle
)
751 AdjustWindowRectEx(rc
, style
, menu
, exstyle
);
752 /* AdjustWindowRectEx does not include scroll bars */
753 if (style
& WS_VSCROLL
)
755 if(exstyle
& WS_EX_LEFTSCROLLBAR
)
756 rc
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
758 rc
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
760 if (style
& WS_HSCROLL
)
761 rc
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
764 static void test_nonclient_area(HWND hwnd
)
766 DWORD style
, exstyle
;
767 RECT rc_window
, rc_client
, rc
;
769 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
771 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
772 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
773 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
775 GetWindowRect(hwnd
, &rc_window
);
776 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
777 GetClientRect(hwnd
, &rc_client
);
778 trace("client: (%ld,%ld)-(%ld,%ld)\n", rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
);
780 /* avoid some cases when things go wrong */
781 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
782 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
784 CopyRect(&rc
, &rc_client
);
785 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
786 FixedAdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
788 trace("calc window: (%ld,%ld)-(%ld,%ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
789 ok(EqualRect(&rc
, &rc_window
), "window rect does not match: style:exstyle=0x%08lx:0x%08lx, menu=%d\n", style
, exstyle
, menu
);
792 CopyRect(&rc
, &rc_window
);
793 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
794 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
795 trace("calc client: (%ld,%ld)-(%ld,%ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
796 ok(EqualRect(&rc
, &rc_client
), "client rect does not match: style:exstyle=0x%08lx:0x%08lx, menu=%d\n", style
, exstyle
, menu
);
798 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
802 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
803 SetRect(&rc_client
, 0, 0, 250, 150);
804 CopyRect(&rc_window
, &rc_client
);
805 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
806 FixedAdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
807 trace("calc window: (%ld,%ld)-(%ld,%ld)\n",
808 rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
810 CopyRect(&rc
, &rc_window
);
811 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
812 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
813 trace("calc client: (%ld,%ld)-(%ld,%ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
814 ok(EqualRect(&rc
, &rc_client
), "synthetic rect does not match: style:exstyle=0x%08lx:0x%08lx, menu=%d\n", style
, exstyle
, menu
);
817 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
819 static const char *CBT_code_name
[10] = {
830 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
832 trace("CBT: %d (%s), %08x, %08lx\n", nCode
, code_name
, wParam
, lParam
);
834 /* on HCBT_DESTROYWND window state is undefined */
835 if (nCode
!= HCBT_DESTROYWND
&& IsWindow((HWND
)wParam
))
841 /* Win98 actually does check the info.cbSize and doesn't allow
842 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
843 * WinXP do not check it at all.
845 info
.cbSize
= sizeof(WINDOWINFO
);
846 ok(pGetWindowInfo((HWND
)wParam
, &info
), "GetWindowInfo should not fail\n");
847 /* win2k SP4 returns broken border info if GetWindowInfo
848 * is being called from HCBT_DESTROYWND or HCBT_MINMAX hook proc.
850 verify_window_info((HWND
)wParam
, &info
, nCode
!= HCBT_MINMAX
);
858 #if 0 /* Uncomment this once the test succeeds in all cases */
859 static const RECT rc_null
;
863 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
864 trace("HCBT_CREATEWND: hwnd %p, parent %p, style %08lx\n",
865 (HWND
)wParam
, createwnd
->lpcs
->hwndParent
, createwnd
->lpcs
->style
);
866 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
868 /* WS_VISIBLE should be turned off yet */
869 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
870 ok(style
== GetWindowLongA((HWND
)wParam
, GWL_STYLE
),
871 "style of hwnd and style in the CREATESTRUCT do not match: %08lx != %08lx\n",
872 GetWindowLongA((HWND
)wParam
, GWL_STYLE
), style
);
874 #if 0 /* Uncomment this once the test succeeds in all cases */
875 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
877 ok(GetParent((HWND
)wParam
) == hwndMessage
,
878 "wrong result from GetParent %p: message window %p\n",
879 GetParent((HWND
)wParam
), hwndMessage
);
882 ok(!GetParent((HWND
)wParam
), "GetParent should return 0 at this point\n");
884 ok(!GetWindow((HWND
)wParam
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
886 #if 0 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
887 * Win9x still has them set to 0.
889 ok(GetWindow((HWND
)wParam
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
890 ok(GetWindow((HWND
)wParam
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
892 ok(!GetWindow((HWND
)wParam
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
893 ok(!GetWindow((HWND
)wParam
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
895 #if 0 /* Uncomment this once the test succeeds in all cases */
898 ok(pGetAncestor((HWND
)wParam
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
899 ok(pGetAncestor((HWND
)wParam
, GA_ROOT
) == (HWND
)wParam
,
900 "GA_ROOT is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOT
), (HWND
)wParam
);
902 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
903 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == hwndMessage
,
904 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
906 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == (HWND
)wParam
,
907 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
), (HWND
)wParam
);
910 ok(GetWindowRect((HWND
)wParam
, &rc
), "GetWindowRect failed\n");
911 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
912 ok(GetClientRect((HWND
)wParam
, &rc
), "GetClientRect failed\n");
913 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
919 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
922 static void test_shell_window(void)
926 HMODULE hinst
, hUser32
;
927 BOOL (WINAPI
*SetShellWindow
)(HWND
);
928 BOOL (WINAPI
*SetShellWindowEx
)(HWND
, HWND
);
929 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
930 HWND shellWindow
, nextWnd
;
932 if (!GetWindowLongW(GetDesktopWindow(), GWL_STYLE
))
934 trace("Skipping shell window test on Win9x\n");
938 shellWindow
= GetShellWindow();
939 hinst
= GetModuleHandle(0);
940 hUser32
= GetModuleHandleA("user32");
942 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
943 SetShellWindowEx
= (void *)GetProcAddress(hUser32
, "SetShellWindowEx");
945 trace("previous shell window: %p\n", shellWindow
);
951 ret
= DestroyWindow(shellWindow
);
952 error
= GetLastError();
954 ok(!ret
, "DestroyWindow(shellWindow)\n");
955 /* passes on Win XP, but not on Win98 */
956 ok(error
==ERROR_ACCESS_DENIED
, "ERROR_ACCESS_DENIED after DestroyWindow(shellWindow)\n");
958 /* close old shell instance */
959 GetWindowThreadProcessId(shellWindow
, &pid
);
960 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
961 ret
= TerminateProcess(hProcess
, 0);
962 ok(ret
, "termination of previous shell process failed: GetLastError()=%ld\n", GetLastError());
963 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
964 CloseHandle(hProcess
);
967 hwnd1
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
968 trace("created window 1: %p\n", hwnd1
);
970 ret
= SetShellWindow(hwnd1
);
971 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
972 shellWindow
= GetShellWindow();
973 ok(shellWindow
==hwnd1
, "wrong shell window: %p\n", shellWindow
);
975 ret
= SetShellWindow(hwnd1
);
976 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
978 ret
= SetShellWindow(0);
979 error
= GetLastError();
980 /* passes on Win XP, but not on Win98
981 ok(!ret, "reset shell window by SetShellWindow(0)\n");
982 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
984 ret
= SetShellWindow(hwnd1
);
985 /* passes on Win XP, but not on Win98
986 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
990 SetWindowLong(hwnd1
, GWL_EXSTYLE
, GetWindowLong(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
991 ret
= GetWindowLong(hwnd1
,GWL_EXSTYLE
)&WS_EX_TOPMOST
? TRUE
: FALSE
;
992 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
995 ret
= DestroyWindow(hwnd1
);
996 ok(ret
, "DestroyWindow(hwnd1)\n");
998 hwnd2
= CreateWindowEx(WS_EX_TOPMOST
, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
999 trace("created window 2: %p\n", hwnd2
);
1000 ret
= SetShellWindow(hwnd2
);
1001 ok(!ret
, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
1003 hwnd3
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
1004 trace("created window 3: %p\n", hwnd3
);
1006 hwnd4
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
1007 trace("created window 4: %p\n", hwnd4
);
1009 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1010 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd
);
1012 ret
= SetShellWindow(hwnd4
);
1013 ok(ret
, "SetShellWindow(hwnd4)\n");
1014 shellWindow
= GetShellWindow();
1015 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1017 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1018 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
1020 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1021 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1023 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1024 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
1026 ret
= SetShellWindow(hwnd3
);
1027 ok(!ret
, "SetShellWindow(hwnd3)\n");
1028 shellWindow
= GetShellWindow();
1029 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1031 hwnd5
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
1032 trace("created window 5: %p\n", hwnd5
);
1033 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1034 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
1038 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1039 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
1042 /* destroy test windows */
1043 DestroyWindow(hwnd2
);
1044 DestroyWindow(hwnd3
);
1045 DestroyWindow(hwnd4
);
1046 DestroyWindow(hwnd5
);
1049 /************** MDI test ****************/
1051 static const char mdi_lParam_test_message
[] = "just a test string";
1053 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT first_id
)
1055 MDICREATESTRUCTA mdi_cs
;
1057 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1058 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
1059 BOOL isWin9x
= FALSE
;
1061 mdi_cs
.szClass
= "MDI_child_Class_1";
1062 mdi_cs
.szTitle
= "MDI child";
1063 mdi_cs
.hOwner
= GetModuleHandle(0);
1064 mdi_cs
.x
= CW_USEDEFAULT
;
1065 mdi_cs
.y
= CW_USEDEFAULT
;
1066 mdi_cs
.cx
= CW_USEDEFAULT
;
1067 mdi_cs
.cy
= CW_USEDEFAULT
;
1069 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1070 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1071 ok(mdi_child
!= 0, "MDI child creation failed\n");
1072 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1073 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1074 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1076 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
1077 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1078 ok(mdi_child
!= 0, "MDI child creation failed\n");
1079 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1080 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1081 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1083 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
1084 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1085 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1087 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1091 ok(mdi_child
!= 0, "MDI child creation failed\n");
1092 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1093 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1094 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1097 /* test MDICREATESTRUCT A<->W mapping */
1098 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1100 mdi_cs
.szClass
= (LPCSTR
)classW
;
1101 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
1102 SetLastError(0xdeadbeef);
1103 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1106 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1109 ok(mdi_child
!= 0, "MDI child creation failed\n");
1113 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1114 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1115 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1118 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1120 CW_USEDEFAULT
, CW_USEDEFAULT
,
1121 CW_USEDEFAULT
, CW_USEDEFAULT
,
1122 mdi_client
, GetModuleHandle(0),
1123 (LPARAM
)mdi_lParam_test_message
);
1124 ok(mdi_child
!= 0, "MDI child creation failed\n");
1125 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1126 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1127 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1129 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1130 0x7fffffff, /* without WS_POPUP */
1131 CW_USEDEFAULT
, CW_USEDEFAULT
,
1132 CW_USEDEFAULT
, CW_USEDEFAULT
,
1133 mdi_client
, GetModuleHandle(0),
1134 (LPARAM
)mdi_lParam_test_message
);
1135 ok(mdi_child
!= 0, "MDI child creation failed\n");
1136 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1137 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1138 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1140 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1141 0xffffffff, /* with WS_POPUP */
1142 CW_USEDEFAULT
, CW_USEDEFAULT
,
1143 CW_USEDEFAULT
, CW_USEDEFAULT
,
1144 mdi_client
, GetModuleHandle(0),
1145 (LPARAM
)mdi_lParam_test_message
);
1146 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1148 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1152 ok(mdi_child
!= 0, "MDI child creation failed\n");
1153 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1154 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1155 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1158 /* test MDICREATESTRUCT A<->W mapping */
1159 SetLastError(0xdeadbeef);
1160 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1162 CW_USEDEFAULT
, CW_USEDEFAULT
,
1163 CW_USEDEFAULT
, CW_USEDEFAULT
,
1164 mdi_client
, GetModuleHandle(0),
1165 (LPARAM
)mdi_lParam_test_message
);
1168 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1171 ok(mdi_child
!= 0, "MDI child creation failed\n");
1175 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1176 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1177 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1180 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1182 CW_USEDEFAULT
, CW_USEDEFAULT
,
1183 CW_USEDEFAULT
, CW_USEDEFAULT
,
1184 mdi_client
, 0, GetModuleHandle(0),
1185 (LPVOID
)mdi_lParam_test_message
);
1186 ok(mdi_child
!= 0, "MDI child creation failed\n");
1187 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1188 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1189 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1191 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1192 0x7fffffff, /* without WS_POPUP */
1193 CW_USEDEFAULT
, CW_USEDEFAULT
,
1194 CW_USEDEFAULT
, CW_USEDEFAULT
,
1195 mdi_client
, 0, GetModuleHandle(0),
1196 (LPVOID
)mdi_lParam_test_message
);
1197 ok(mdi_child
!= 0, "MDI child creation failed\n");
1198 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1199 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1200 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1202 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1203 0xffffffff, /* with WS_POPUP */
1204 CW_USEDEFAULT
, CW_USEDEFAULT
,
1205 CW_USEDEFAULT
, CW_USEDEFAULT
,
1206 mdi_client
, 0, GetModuleHandle(0),
1207 (LPVOID
)mdi_lParam_test_message
);
1208 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1210 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1214 ok(mdi_child
!= 0, "MDI child creation failed\n");
1215 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1216 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1217 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1220 /* test MDICREATESTRUCT A<->W mapping */
1221 SetLastError(0xdeadbeef);
1222 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1224 CW_USEDEFAULT
, CW_USEDEFAULT
,
1225 CW_USEDEFAULT
, CW_USEDEFAULT
,
1226 mdi_client
, 0, GetModuleHandle(0),
1227 (LPVOID
)mdi_lParam_test_message
);
1230 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1233 ok(mdi_child
!= 0, "MDI child creation failed\n");
1237 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1238 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1239 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1242 /* This test fails on Win9x */
1245 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1247 CW_USEDEFAULT
, CW_USEDEFAULT
,
1248 CW_USEDEFAULT
, CW_USEDEFAULT
,
1249 parent
, 0, GetModuleHandle(0),
1250 (LPVOID
)mdi_lParam_test_message
);
1251 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1254 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1255 WS_CHILD
, /* without WS_POPUP */
1256 CW_USEDEFAULT
, CW_USEDEFAULT
,
1257 CW_USEDEFAULT
, CW_USEDEFAULT
,
1258 mdi_client
, 0, GetModuleHandle(0),
1259 (LPVOID
)mdi_lParam_test_message
);
1260 ok(mdi_child
!= 0, "MDI child creation failed\n");
1261 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1262 DestroyWindow(mdi_child
);
1264 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1265 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1266 CW_USEDEFAULT
, CW_USEDEFAULT
,
1267 CW_USEDEFAULT
, CW_USEDEFAULT
,
1268 mdi_client
, 0, GetModuleHandle(0),
1269 (LPVOID
)mdi_lParam_test_message
);
1270 ok(mdi_child
!= 0, "MDI child creation failed\n");
1271 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1272 DestroyWindow(mdi_child
);
1274 /* maximized child */
1275 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1276 WS_CHILD
| WS_MAXIMIZE
,
1277 CW_USEDEFAULT
, CW_USEDEFAULT
,
1278 CW_USEDEFAULT
, CW_USEDEFAULT
,
1279 mdi_client
, 0, GetModuleHandle(0),
1280 (LPVOID
)mdi_lParam_test_message
);
1281 ok(mdi_child
!= 0, "MDI child creation failed\n");
1282 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1283 DestroyWindow(mdi_child
);
1285 trace("Creating maximized child with a caption\n");
1286 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1287 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1288 CW_USEDEFAULT
, CW_USEDEFAULT
,
1289 CW_USEDEFAULT
, CW_USEDEFAULT
,
1290 mdi_client
, 0, GetModuleHandle(0),
1291 (LPVOID
)mdi_lParam_test_message
);
1292 ok(mdi_child
!= 0, "MDI child creation failed\n");
1293 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1294 DestroyWindow(mdi_child
);
1296 trace("Creating maximized child with a caption and a thick frame\n");
1297 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1298 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1299 CW_USEDEFAULT
, CW_USEDEFAULT
,
1300 CW_USEDEFAULT
, CW_USEDEFAULT
,
1301 mdi_client
, 0, GetModuleHandle(0),
1302 (LPVOID
)mdi_lParam_test_message
);
1303 ok(mdi_child
!= 0, "MDI child creation failed\n");
1304 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %ld\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1305 DestroyWindow(mdi_child
);
1308 /**********************************************************************
1309 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1311 * Note: The rule here is that client rect of the maximized MDI child
1312 * is equal to the client rect of the MDI client window.
1314 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1318 GetClientRect( client
, &rect
);
1319 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1320 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1322 rect
.right
-= rect
.left
;
1323 rect
.bottom
-= rect
.top
;
1324 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1325 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1327 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1328 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1330 trace("max rect (%ld,%ld - %ld, %ld)\n",
1331 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1334 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1341 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1342 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs
->lpCreateParams
;
1344 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1345 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1347 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1348 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1349 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1350 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1351 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1353 /* MDICREATESTRUCT should have original values */
1354 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff,
1355 "mdi_cs->style does not match (%08lx)\n", mdi_cs
->style
);
1356 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1357 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1358 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1359 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1361 /* CREATESTRUCT should have fixed values */
1362 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1363 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1365 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1366 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1367 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1369 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1371 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1373 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1374 ok(cs
->style
== style
,
1375 "cs->style does not match (%08lx)\n", cs
->style
);
1379 LONG style
= mdi_cs
->style
;
1381 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1382 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1383 ok(cs
->style
== style
,
1384 "cs->style does not match (%08lx)\n", cs
->style
);
1389 case WM_GETMINMAXINFO
:
1391 HWND client
= GetParent(hwnd
);
1393 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1394 MINMAXINFO my_minmax
;
1395 LONG style
, exstyle
;
1397 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1398 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1400 GetWindowRect(client
, &rc
);
1401 trace("MDI client %p window size = (%ld x %ld)\n", client
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1402 GetClientRect(client
, &rc
);
1403 trace("MDI client %p client size = (%ld x %ld)\n", client
, rc
.right
, rc
.bottom
);
1404 trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN
),
1405 GetSystemMetrics(SM_CYSCREEN
));
1407 GetClientRect(client
, &rc
);
1408 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1409 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1410 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1411 trace("MDI child: calculated max window size = (%ld x %ld)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1413 trace("ptReserved = (%ld,%ld)\n"
1414 "ptMaxSize = (%ld,%ld)\n"
1415 "ptMaxPosition = (%ld,%ld)\n"
1416 "ptMinTrackSize = (%ld,%ld)\n"
1417 "ptMaxTrackSize = (%ld,%ld)\n",
1418 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1419 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1420 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1421 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1422 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1424 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %ld != %ld\n",
1425 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1426 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %ld != %ld\n",
1427 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1429 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1431 trace("DefMDIChildProc returned:\n"
1432 "ptReserved = (%ld,%ld)\n"
1433 "ptMaxSize = (%ld,%ld)\n"
1434 "ptMaxPosition = (%ld,%ld)\n"
1435 "ptMinTrackSize = (%ld,%ld)\n"
1436 "ptMaxTrackSize = (%ld,%ld)\n",
1437 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1438 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1439 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1440 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1441 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1443 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1444 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %ld != %ld\n",
1445 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1446 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %ld != %ld\n",
1447 minmax
->ptMaxSize
.y
, my_minmax
.ptMaxSize
.y
);
1452 case WM_MDIACTIVATE
:
1454 HWND active
, client
= GetParent(hwnd
);
1455 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1456 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
1457 if (hwnd
== (HWND
)lparam
) /* if we are being activated */
1458 ok (active
== (HWND
)lparam
, "new active %p != active %p\n", (HWND
)lparam
, active
);
1460 ok (active
== (HWND
)wparam
, "old active %p != active %p\n", (HWND
)wparam
, active
);
1464 return DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1467 static LRESULT WINAPI
mdi_child_wnd_proc_2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1474 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1476 trace("%s\n", (msg
== WM_NCCREATE
) ? "WM_NCCREATE" : "WM_CREATE");
1477 trace("x %d, y %d, cx %d, cy %d\n", cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1479 ok(!(cs
->dwExStyle
& WS_EX_MDICHILD
), "WS_EX_MDICHILD should not be set\n");
1480 ok(cs
->lpCreateParams
== mdi_lParam_test_message
, "wrong cs->lpCreateParams\n");
1482 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_2"), "wrong class name\n");
1483 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1485 /* CREATESTRUCT should have fixed values */
1486 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1488 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1489 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1491 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1492 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1493 while Win95, Win2k, WinXP do. */
1494 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1495 ok(cs
->cy
== 0, "%d != 0\n", cs
->cy
);
1499 case WM_GETMINMAXINFO
:
1501 HWND parent
= GetParent(hwnd
);
1503 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1504 LONG style
, exstyle
;
1506 trace("WM_GETMINMAXINFO\n");
1508 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1509 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1511 GetClientRect(parent
, &rc
);
1512 trace("parent %p client size = (%ld x %ld)\n", parent
, rc
.right
, rc
.bottom
);
1514 GetClientRect(parent
, &rc
);
1515 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1516 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1517 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1518 trace("calculated max child window size = (%ld x %ld)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1520 trace("ptReserved = (%ld,%ld)\n"
1521 "ptMaxSize = (%ld,%ld)\n"
1522 "ptMaxPosition = (%ld,%ld)\n"
1523 "ptMinTrackSize = (%ld,%ld)\n"
1524 "ptMaxTrackSize = (%ld,%ld)\n",
1525 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
1526 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
1527 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
1528 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
1529 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
1531 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %ld != %ld\n",
1532 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1533 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %ld != %ld\n",
1534 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1538 case WM_WINDOWPOSCHANGED
:
1540 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1543 GetWindowRect(hwnd
, &rc1
);
1544 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1545 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1546 /* note: winpos coordinates are relative to parent */
1547 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1548 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1549 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1551 GetWindowRect(hwnd
, &rc1
);
1552 GetClientRect(hwnd
, &rc2
);
1553 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1554 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1555 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1558 case WM_WINDOWPOSCHANGING
:
1560 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1561 WINDOWPOS my_winpos
= *winpos
;
1563 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1564 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1565 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1566 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1568 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1570 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1571 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1572 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1574 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1575 "DefWindowProc should not change WINDOWPOS values\n");
1580 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1583 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1585 static HWND mdi_client
;
1591 CLIENTCREATESTRUCT client_cs
;
1594 GetClientRect(hwnd
, &rc
);
1596 client_cs
.hWindowMenu
= 0;
1597 client_cs
.idFirstChild
= 1;
1599 /* MDIClient without MDIS_ALLCHILDSTYLES */
1600 mdi_client
= CreateWindowExA(0, "mdiclient",
1602 WS_CHILD
/*| WS_VISIBLE*/,
1603 /* tests depend on a not zero MDIClient size */
1604 0, 0, rc
.right
, rc
.bottom
,
1605 hwnd
, 0, GetModuleHandle(0),
1606 (LPVOID
)&client_cs
);
1608 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1609 DestroyWindow(mdi_client
);
1611 /* MDIClient with MDIS_ALLCHILDSTYLES */
1612 mdi_client
= CreateWindowExA(0, "mdiclient",
1614 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
1615 /* tests depend on a not zero MDIClient size */
1616 0, 0, rc
.right
, rc
.bottom
,
1617 hwnd
, 0, GetModuleHandle(0),
1618 (LPVOID
)&client_cs
);
1620 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1621 DestroyWindow(mdi_client
);
1625 case WM_WINDOWPOSCHANGED
:
1627 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1630 GetWindowRect(hwnd
, &rc1
);
1631 trace("window: (%ld,%ld)-(%ld,%ld)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1632 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1633 /* note: winpos coordinates are relative to parent */
1634 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1635 trace("pos: (%ld,%ld)-(%ld,%ld)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1636 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1638 GetWindowRect(hwnd
, &rc1
);
1639 GetClientRect(hwnd
, &rc2
);
1640 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1641 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1642 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1645 case WM_WINDOWPOSCHANGING
:
1647 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1648 WINDOWPOS my_winpos
= *winpos
;
1650 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1651 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1652 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1653 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1655 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1657 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1658 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1659 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1661 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1662 "DefWindowProc should not change WINDOWPOS values\n");
1671 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
1674 static BOOL
mdi_RegisterWindowClasses(void)
1679 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
1682 cls
.hInstance
= GetModuleHandleA(0);
1684 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1685 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1686 cls
.lpszMenuName
= NULL
;
1687 cls
.lpszClassName
= "MDI_parent_Class";
1688 if(!RegisterClassA(&cls
)) return FALSE
;
1690 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
1691 cls
.lpszClassName
= "MDI_child_Class_1";
1692 if(!RegisterClassA(&cls
)) return FALSE
;
1694 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
1695 cls
.lpszClassName
= "MDI_child_Class_2";
1696 if(!RegisterClassA(&cls
)) return FALSE
;
1701 static void test_mdi(void)
1706 if (!mdi_RegisterWindowClasses()) assert(0);
1708 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
1709 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
1710 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
1711 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1712 GetDesktopWindow(), 0,
1713 GetModuleHandle(0), NULL
);
1714 assert(mdi_hwndMain
);
1716 while(GetMessage(&msg, 0, 0, 0))
1718 TranslateMessage(&msg);
1719 DispatchMessage(&msg);
1724 static void test_icons(void)
1728 HICON icon
= LoadIconA(0, (LPSTR
)IDI_APPLICATION
);
1729 HICON icon2
= LoadIconA(0, (LPSTR
)IDI_QUESTION
);
1730 HICON small_icon
= LoadImageA(0, (LPSTR
)IDI_APPLICATION
, IMAGE_ICON
,
1731 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
1734 cls
.cbSize
= sizeof(cls
);
1736 cls
.lpfnWndProc
= DefWindowProcA
;
1740 cls
.hIcon
= LoadIconA(0, (LPSTR
)IDI_HAND
);
1741 cls
.hIconSm
= small_icon
;
1742 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1743 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1744 cls
.lpszMenuName
= NULL
;
1745 cls
.lpszClassName
= "IconWindowClass";
1747 RegisterClassExA(&cls
);
1749 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
1750 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
1753 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1754 ok( res
== 0, "wrong big icon %p/0\n", res
);
1755 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
1756 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
1757 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1758 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
1759 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
1760 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
1761 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1762 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1764 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1765 ok( res
== 0, "wrong small icon %p/0\n", res
);
1766 /* this test is XP specific */
1767 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1768 ok( res != 0, "wrong small icon %p\n", res );*/
1769 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
1770 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
1771 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1772 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
1773 /* this test is XP specific */
1774 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1775 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
1776 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
1777 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
1778 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1779 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
1780 /* this test is XP specific */
1781 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1782 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
1784 /* make sure the big icon hasn't changed */
1785 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1786 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1789 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1791 if (msg
== WM_NCCALCSIZE
)
1793 RECT
*rect
= (RECT
*)lparam
;
1794 /* first time around increase the rectangle, next time decrease it */
1795 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
1796 else InflateRect( rect
, -10, -10 );
1799 return DefWindowProc( hwnd
, msg
, wparam
, lparam
);
1802 static void test_SetWindowPos(HWND hwnd
)
1804 RECT orig_win_rc
, rect
;
1806 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
1808 SetRect(&rect
, 111, 222, 333, 444);
1809 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
1810 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1811 "wrong window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1813 SetRect(&rect
, 111, 222, 333, 444);
1814 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
1815 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1816 "wrong window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1818 GetWindowRect(hwnd
, &orig_win_rc
);
1820 old_proc
= SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
1821 SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1822 GetWindowRect( hwnd
, &rect
);
1823 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
1824 "invalid window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1825 GetClientRect( hwnd
, &rect
);
1826 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1827 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
1828 "invalid client rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1830 SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1831 GetWindowRect( hwnd
, &rect
);
1832 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
1833 "invalid window rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1834 GetClientRect( hwnd
, &rect
);
1835 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1836 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
1837 "invalid client rect %ld,%ld-%ld,%ld\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1839 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1840 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1841 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, old_proc
);
1843 /* Win9x truncates coordinates to 16-bit irrespectively */
1846 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
1847 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
1849 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
1850 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
1853 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1854 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1857 static void test_SetMenu(HWND parent
)
1861 BOOL is_win9x
= GetWindowLongPtrW(parent
, GWLP_WNDPROC
) == 0;
1865 hMenu
= CreateMenu();
1868 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1870 /* fails on (at least) Wine, NT4, XP SP2 */
1871 test_nonclient_area(parent
);
1873 ret
= GetMenu(parent
);
1874 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1875 /* test whether we can destroy a menu assigned to a window */
1876 retok
= DestroyMenu(hMenu
);
1877 ok( retok
, "DestroyMenu error %ld\n", GetLastError());
1878 ok(!IsMenu(hMenu
), "menu handle should be not valid after DestroyMenu\n");
1879 ret
= GetMenu(parent
);
1880 /* This test fails on Win9x */
1882 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1883 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1884 test_nonclient_area(parent
);
1886 hMenu
= CreateMenu();
1890 ret
= GetMenu(parent
);
1891 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1893 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1894 test_nonclient_area(parent
);
1895 ret
= GetMenu(parent
);
1896 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1898 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1900 /* fails on (at least) Wine, NT4, XP SP2 */
1901 test_nonclient_area(parent
);
1903 ret
= GetMenu(parent
);
1904 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1906 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1907 test_nonclient_area(parent
);
1908 ret
= GetMenu(parent
);
1909 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1912 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
1915 ret
= GetMenu(child
);
1916 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1918 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1919 test_nonclient_area(child
);
1920 ret
= GetMenu(child
);
1921 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1923 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
1924 test_nonclient_area(child
);
1925 ret
= GetMenu(child
);
1926 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1928 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
1929 test_nonclient_area(child
);
1930 ret
= GetMenu(child
);
1931 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1933 style
= GetWindowLong(child
, GWL_STYLE
);
1934 SetWindowLong(child
, GWL_STYLE
, style
| WS_POPUP
);
1935 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
1936 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
1937 SetWindowLong(child
, GWL_STYLE
, style
);
1939 SetWindowLong(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
1940 ok(!SetMenu(child
, hMenu
), "SetMenu on a overlapped child window should fail\n");
1941 SetWindowLong(child
, GWL_STYLE
, style
);
1943 DestroyWindow(child
);
1947 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
1949 HWND child
[5], hwnd
;
1954 hwnd
= GetWindow(parent
, GW_CHILD
);
1955 ok(!hwnd
, "have to start without children to perform the test\n");
1957 for (i
= 0; i
< total
; i
++)
1959 if (style
[i
] & DS_CONTROL
)
1961 child
[i
] = CreateWindowExA(0, MAKEINTATOMA(32770), "", style
[i
] & ~WS_VISIBLE
,
1962 0,0,0,0, parent
, (HMENU
)i
, 0, NULL
);
1963 if (style
[i
] & WS_VISIBLE
)
1964 ShowWindow(child
[i
], SW_SHOW
);
1966 SetWindowPos(child
[i
], HWND_BOTTOM
, 0,0,10,10, SWP_NOACTIVATE
);
1969 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
1970 parent
, (HMENU
)i
, 0, NULL
);
1971 trace("child[%d] = %p\n", i
, child
[i
]);
1972 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
1975 hwnd
= GetWindow(parent
, GW_CHILD
);
1976 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
1977 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
1978 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
1980 for (i
= 0; i
< total
; i
++)
1982 trace("hwnd[%d] = %p\n", i
, hwnd
);
1983 ok(child
[order
[i
]] == hwnd
, "Z order of child #%d is wrong\n", i
);
1985 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
1988 for (i
= 0; i
< total
; i
++)
1989 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
1992 static void test_children_zorder(HWND parent
)
1994 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
1996 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
1998 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
1999 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
2000 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
2001 const int complex_order_1
[1] = { 0 };
2002 const int complex_order_2
[2] = { 1, 0 };
2003 const int complex_order_3
[3] = { 1, 0, 2 };
2004 const int complex_order_4
[4] = { 1, 0, 2, 3 };
2005 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
2006 const DWORD complex_style_6
[3] = { WS_CHILD
| WS_VISIBLE
,
2007 WS_CHILD
| WS_CLIPSIBLINGS
| DS_CONTROL
| WS_VISIBLE
,
2008 WS_CHILD
| WS_VISIBLE
};
2009 const int complex_order_6
[3] = { 0, 1, 2 };
2011 /* simple WS_CHILD */
2012 test_window_tree(parent
, simple_style
, simple_order
, 5);
2014 /* complex children styles */
2015 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
2016 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
2017 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
2018 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
2019 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
2021 /* another set of complex children styles */
2022 test_window_tree(parent
, complex_style_6
, complex_order_6
, 3);
2025 static void test_vis_rgn( HWND hwnd
)
2027 RECT win_rect
, rgn_rect
;
2028 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
2031 ShowWindow(hwnd
,SW_SHOW
);
2032 hdc
= GetDC( hwnd
);
2033 ok( GetRandomRgn( hdc
, hrgn
, SYSRGN
) != 0, "GetRandomRgn failed\n" );
2034 GetWindowRect( hwnd
, &win_rect
);
2035 GetRgnBox( hrgn
, &rgn_rect
);
2036 if (GetVersion() & 0x80000000)
2038 trace("win9x, mapping to screen coords\n");
2039 MapWindowPoints( hwnd
, 0, (POINT
*)&rgn_rect
, 2 );
2041 trace("win: %ld,%ld-%ld,%ld\n", win_rect
.left
, win_rect
.top
, win_rect
.right
, win_rect
.bottom
);
2042 trace("rgn: %ld,%ld-%ld,%ld\n", rgn_rect
.left
, rgn_rect
.top
, rgn_rect
.right
, rgn_rect
.bottom
);
2043 ok( win_rect
.left
<= rgn_rect
.left
, "rgn left %ld not inside win rect %ld\n",
2044 rgn_rect
.left
, win_rect
.left
);
2045 ok( win_rect
.top
<= rgn_rect
.top
, "rgn top %ld not inside win rect %ld\n",
2046 rgn_rect
.top
, win_rect
.top
);
2047 ok( win_rect
.right
>= rgn_rect
.right
, "rgn right %ld not inside win rect %ld\n",
2048 rgn_rect
.right
, win_rect
.right
);
2049 ok( win_rect
.bottom
>= rgn_rect
.bottom
, "rgn bottom %ld not inside win rect %ld\n",
2050 rgn_rect
.bottom
, win_rect
.bottom
);
2051 ReleaseDC( hwnd
, hdc
);
2054 static void test_SetFocus(HWND hwnd
)
2058 /* check if we can set focus to non-visible windows */
2060 ShowWindow(hwnd
, SW_SHOW
);
2063 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2064 ok( GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
2065 ShowWindow(hwnd
, SW_HIDE
);
2068 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
2069 ok( !(GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
2070 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2073 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
2074 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2075 ShowWindow(child
, SW_SHOW
);
2076 ok( GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
2077 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
2078 ShowWindow(child
, SW_HIDE
);
2079 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2080 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2081 ShowWindow(child
, SW_SHOW
);
2083 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2084 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
2085 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2087 ShowWindow(child
, SW_HIDE
);
2089 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2090 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
2091 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2092 ShowWindow(child
, SW_HIDE
);
2093 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2095 ShowWindow(hwnd
, SW_SHOW
);
2096 ShowWindow(child
, SW_SHOW
);
2098 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2099 EnableWindow(hwnd
, FALSE
);
2100 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2101 EnableWindow(hwnd
, TRUE
);
2103 DestroyWindow( child
);
2106 static void test_SetActiveWindow(HWND hwnd
)
2110 ShowWindow(hwnd
, SW_SHOW
);
2112 SetActiveWindow(hwnd
);
2113 ok( GetActiveWindow() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2114 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2115 ok( GetActiveWindow() == hwnd
, "Window %p no longer active\n", hwnd
);
2116 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2117 ShowWindow(hwnd
, SW_HIDE
);
2118 ok( GetActiveWindow() != hwnd
, "Window %p is still active\n", hwnd
);
2120 /* trace("**testing an invisible window now\n"); */
2121 SetActiveWindow(hwnd
);
2122 ok( GetActiveWindow() == hwnd
, "Window %p not active\n", hwnd
);
2123 ok( !(GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p is visible\n", hwnd
);
2125 ShowWindow(hwnd
, SW_SHOW
);
2127 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2128 ok( GetActiveWindow() == hwnd2
, "Window %p is not active\n", hwnd2
);
2129 DestroyWindow(hwnd2
);
2130 ok( GetActiveWindow() != hwnd2
, "Window %p is still active\n", hwnd2
);
2132 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2133 ok( GetActiveWindow() == hwnd2
, "Window %p is not active\n", hwnd2
);
2134 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2135 ok( GetActiveWindow() == hwnd2
, "Window %p no longer active (%p)\n", hwnd2
, GetActiveWindow() );
2136 DestroyWindow(hwnd2
);
2137 ok( GetActiveWindow() != hwnd2
, "Window %p is still active\n", hwnd2
);
2140 static void check_wnd_state(HWND active
, HWND foreground
, HWND focus
, HWND capture
)
2142 ok(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
2144 ok(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
2145 ok(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
2146 ok(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
2149 static WNDPROC old_button_proc
;
2151 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2156 key_state
= GetKeyState(VK_LBUTTON
);
2157 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
2159 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
2161 if (msg
== WM_LBUTTONDOWN
)
2165 check_wnd_state(button
, button
, button
, button
);
2167 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2169 trace("hwnd %p\n", hwnd
);
2171 check_wnd_state(button
, button
, button
, button
);
2173 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2175 check_wnd_state(button
, button
, button
, button
);
2177 DestroyWindow(hwnd
);
2179 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2181 trace("hwnd %p\n", hwnd
);
2183 check_wnd_state(button
, button
, button
, button
);
2185 /* button wnd proc should release capture on WM_KILLFOCUS if it does
2186 * match internal button state.
2188 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2189 check_wnd_state(button
, button
, button
, 0);
2191 ShowWindow(hwnd
, SW_SHOW
);
2192 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2194 capture
= SetCapture(hwnd
);
2195 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2197 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2199 DestroyWindow(hwnd
);
2201 check_wnd_state(button
, 0, button
, 0);
2207 static void test_capture_1(void)
2209 HWND button
, capture
;
2211 capture
= GetCapture();
2212 ok(capture
== 0, "GetCapture() = %p\n", capture
);
2214 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2216 trace("button %p\n", button
);
2218 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
2220 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
2222 capture
= SetCapture(button
);
2223 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2224 check_wnd_state(button
, 0, button
, button
);
2226 DestroyWindow(button
);
2227 check_wnd_state(0, 0, 0, 0);
2230 static void test_capture_2(void)
2232 HWND button
, hwnd
, capture
;
2234 check_wnd_state(0, 0, 0, 0);
2236 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2238 trace("button %p\n", button
);
2240 check_wnd_state(button
, button
, button
, 0);
2242 capture
= SetCapture(button
);
2243 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2245 check_wnd_state(button
, button
, button
, button
);
2247 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
2248 * internal button state.
2250 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2251 check_wnd_state(button
, button
, button
, button
);
2253 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2255 trace("hwnd %p\n", hwnd
);
2257 check_wnd_state(button
, button
, button
, button
);
2259 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2261 check_wnd_state(button
, button
, button
, button
);
2263 DestroyWindow(hwnd
);
2265 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2267 trace("hwnd %p\n", hwnd
);
2269 check_wnd_state(button
, button
, button
, button
);
2271 ShowWindow(hwnd
, SW_SHOW
);
2273 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
2275 capture
= SetCapture(hwnd
);
2276 ok(capture
== button
, "SetCapture() = %p\n", capture
);
2278 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2280 DestroyWindow(hwnd
);
2281 check_wnd_state(button
, button
, button
, 0);
2283 DestroyWindow(button
);
2284 check_wnd_state(0, 0, 0, 0);
2287 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
2291 ShowWindow(hwnd1
, SW_HIDE
);
2292 ShowWindow(hwnd2
, SW_HIDE
);
2294 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
2295 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
2298 check_wnd_state(0, 0, 0, hwnd1
);
2301 check_wnd_state(0, 0, 0, hwnd2
);
2303 ShowWindow(hwnd1
, SW_SHOW
);
2304 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
2306 ret
= ReleaseCapture();
2307 ok (ret
, "releasecapture did not return TRUE.\n");
2308 ret
= ReleaseCapture();
2309 ok (ret
, "releasecapture did not return TRUE after second try.\n");
2312 static void test_keyboard_input(HWND hwnd
)
2317 ShowWindow(hwnd
, SW_SHOW
);
2320 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
2323 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2325 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2327 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2328 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2329 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2330 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2331 ok( !ret
, "message %04x available\n", msg
.message
);
2333 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2335 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2336 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2337 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2338 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2339 ok( !ret
, "message %04x available\n", msg
.message
);
2341 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2343 keybd_event(VK_SPACE
, 0, 0, 0);
2344 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2345 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2346 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2347 ok( !ret
, "message %04x available\n", msg
.message
);
2350 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2352 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
2354 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2355 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2356 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2357 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2358 ok( !ret
, "message %04x available\n", msg
.message
);
2360 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2362 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2363 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2364 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2365 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2366 ok( !ret
, "message %04x available\n", msg
.message
);
2368 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2370 keybd_event(VK_SPACE
, 0, 0, 0);
2371 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2372 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2373 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2374 ok( !ret
, "message %04x available\n", msg
.message
);
2377 static void test_mouse_input(HWND hwnd
)
2387 ShowWindow(hwnd
, SW_SHOW
);
2390 GetWindowRect(hwnd
, &rc
);
2391 trace("main window %p: (%ld,%ld)-(%ld,%ld)\n", hwnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2393 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
2394 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
2397 ShowWindow(popup
, SW_SHOW
);
2398 UpdateWindow(popup
);
2400 GetWindowRect(popup
, &rc
);
2401 trace("popup window %p: (%ld,%ld)-(%ld,%ld)\n", popup
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2403 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
2404 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
2405 trace("setting cursor to (%d,%d)\n", x
, y
);
2409 ok(x
== pt
.x
&& y
== pt
.y
, "wrong cursor pos (%ld,%ld), expected (%d,%d)\n", pt
.x
, pt
.y
, x
, y
);
2411 /* force the system to update its internal queue mouse position,
2412 * otherwise it won't generate relative mouse movements below.
2414 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2415 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2418 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2419 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2420 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2421 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
2422 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
2423 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "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 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2428 ShowWindow(popup
, SW_HIDE
);
2429 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2430 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2431 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2433 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2434 ShowWindow(hwnd
, SW_HIDE
);
2435 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2436 ok( !ret
, "message %04x available\n", msg
.message
);
2438 /* test mouse clicks */
2440 ShowWindow(hwnd
, SW_SHOW
);
2441 ShowWindow(popup
, SW_SHOW
);
2443 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2445 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2446 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2447 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2448 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2450 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2451 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2452 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2453 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2455 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2456 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2457 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2458 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2460 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2461 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2462 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2463 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2465 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2466 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2467 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2468 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2470 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2471 ok(!ret
, "message %04x available\n", msg
.message
);
2473 ShowWindow(popup
, SW_HIDE
);
2474 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2476 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2477 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2478 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2479 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2481 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2482 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2483 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2484 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2486 test_lbuttondown_flag
= TRUE
;
2487 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
2488 test_lbuttondown_flag
= FALSE
;
2490 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2491 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2492 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2493 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2494 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2496 /* Test WM_MOUSEACTIVATE */
2497 #define TEST_MOUSEACTIVATE(A,B) \
2498 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
2499 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
2501 TEST_MOUSEACTIVATE(HTERROR
,MA_ACTIVATE
);
2502 TEST_MOUSEACTIVATE(HTTRANSPARENT
,MA_ACTIVATE
);
2503 TEST_MOUSEACTIVATE(HTNOWHERE
,MA_ACTIVATE
);
2504 TEST_MOUSEACTIVATE(HTCLIENT
,MA_ACTIVATE
);
2505 TEST_MOUSEACTIVATE(HTCAPTION
,MA_ACTIVATE
);
2506 TEST_MOUSEACTIVATE(HTSYSMENU
,MA_ACTIVATE
);
2507 TEST_MOUSEACTIVATE(HTSIZE
,MA_ACTIVATE
);
2508 TEST_MOUSEACTIVATE(HTMENU
,MA_ACTIVATE
);
2509 TEST_MOUSEACTIVATE(HTHSCROLL
,MA_ACTIVATE
);
2510 TEST_MOUSEACTIVATE(HTVSCROLL
,MA_ACTIVATE
);
2511 TEST_MOUSEACTIVATE(HTMINBUTTON
,MA_ACTIVATE
);
2512 TEST_MOUSEACTIVATE(HTMAXBUTTON
,MA_ACTIVATE
);
2513 TEST_MOUSEACTIVATE(HTLEFT
,MA_ACTIVATE
);
2514 TEST_MOUSEACTIVATE(HTRIGHT
,MA_ACTIVATE
);
2515 TEST_MOUSEACTIVATE(HTTOP
,MA_ACTIVATE
);
2516 TEST_MOUSEACTIVATE(HTTOPLEFT
,MA_ACTIVATE
);
2517 TEST_MOUSEACTIVATE(HTTOPRIGHT
,MA_ACTIVATE
);
2518 TEST_MOUSEACTIVATE(HTBOTTOM
,MA_ACTIVATE
);
2519 TEST_MOUSEACTIVATE(HTBOTTOMLEFT
,MA_ACTIVATE
);
2520 TEST_MOUSEACTIVATE(HTBOTTOMRIGHT
,MA_ACTIVATE
);
2521 TEST_MOUSEACTIVATE(HTBORDER
,MA_ACTIVATE
);
2522 TEST_MOUSEACTIVATE(HTOBJECT
,MA_ACTIVATE
);
2523 TEST_MOUSEACTIVATE(HTCLOSE
,MA_ACTIVATE
);
2524 TEST_MOUSEACTIVATE(HTHELP
,MA_ACTIVATE
);
2526 /* Clear any messages left behind by WM_MOUSEACTIVATE tests */
2527 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2529 DestroyWindow(popup
);
2532 static void test_validatergn(HWND hwnd
)
2538 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
2539 ShowWindow(hwnd
, SW_SHOW
);
2540 UpdateWindow( hwnd
);
2541 /* test that ValidateRect validates children*/
2542 InvalidateRect( child
, NULL
, 1);
2543 GetWindowRect( child
, &rc
);
2544 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2545 ret
= GetUpdateRect( child
, &rc2
, 0);
2546 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
2547 "Update rectangle is empty!\n");
2548 ValidateRect( hwnd
, &rc
);
2549 ret
= GetUpdateRect( child
, &rc2
, 0);
2550 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2551 "Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2
.left
, rc2
.top
,
2552 rc2
.right
, rc2
.bottom
);
2554 /* now test ValidateRgn */
2555 InvalidateRect( child
, NULL
, 1);
2556 GetWindowRect( child
, &rc
);
2557 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2558 rgn
= CreateRectRgnIndirect( &rc
);
2559 ValidateRgn( hwnd
, rgn
);
2560 ret
= GetUpdateRect( child
, &rc2
, 0);
2561 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2562 "Update rectangle %ld,%ld-%ld,%ld is not empty!\n", rc2
.left
, rc2
.top
,
2563 rc2
.right
, rc2
.bottom
);
2566 DestroyWindow( child
);
2569 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
2571 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
2572 GetWindowRect( hwnd
, prc
);
2573 trace("window rect is %ld,%ld - %ld,%ld\n",
2574 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2575 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
2576 trace("nccalc rect is %ld,%ld - %ld,%ld\n",
2577 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2580 static void test_nccalcscroll(HWND parent
)
2583 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
2584 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
2585 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
2586 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
2587 10, 10, 200, 200, parent
, 0, 0, NULL
);
2588 ShowWindow( parent
, SW_SHOW
);
2589 UpdateWindow( parent
);
2591 /* test window too low for a horizontal scroll bar */
2592 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
2593 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %ld,%ld - %ld,%ld\n",
2594 sbheight
, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2596 /* test window just high enough for a horizontal scroll bar */
2597 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
2598 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be %d size is %ld,%ld - %ld,%ld\n",
2599 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2601 /* test window too narrow for a vertical scroll bar */
2602 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
2603 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %ld,%ld - %ld,%ld\n",
2604 sbwidth
- 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2606 /* test window just wide enough for a vertical scroll bar */
2607 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2608 ok( rc1
.right
- rc1
.left
== 0, "Width should be %d size is %ld,%ld - %ld,%ld\n",
2609 0, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2611 /* same test, but with client edge: not enough width */
2612 SetWindowLong( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLong( hwnd
, GWL_EXSTYLE
));
2613 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2614 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
2615 "Width should be %d size is %ld,%ld - %ld,%ld\n",
2616 sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
), rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2618 DestroyWindow( hwnd
);
2621 static void test_SetParent(void)
2624 HWND desktop
= GetDesktopWindow();
2626 BOOL is_win9x
= GetWindowLongPtrW(desktop
, GWLP_WNDPROC
) == 0;
2627 HWND parent
, child1
, child2
, child3
, child4
, sibling
;
2629 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
2630 100, 100, 200, 200, 0, 0, 0, NULL
);
2631 assert(parent
!= 0);
2632 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2633 0, 0, 50, 50, parent
, 0, 0, NULL
);
2634 assert(child1
!= 0);
2635 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2636 0, 0, 50, 50, child1
, 0, 0, NULL
);
2637 assert(child2
!= 0);
2638 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2639 0, 0, 50, 50, child2
, 0, 0, NULL
);
2640 assert(child3
!= 0);
2641 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2642 0, 0, 50, 50, child3
, 0, 0, NULL
);
2643 assert(child4
!= 0);
2645 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
2646 parent
, child1
, child2
, child3
, child4
);
2648 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
2649 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
2650 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2651 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2652 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2655 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
2656 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
2657 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2658 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
2659 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2662 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
2664 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2666 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
2667 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
2668 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
2669 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
2670 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
2671 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
2673 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2676 if (!is_win9x
) /* Win9x doesn't survive this test */
2678 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
2679 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
2680 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
2681 ok(SetParent(parent
, child2
) != 0, "SetParent should not fail\n");
2682 ok(SetParent(parent
, child3
) != 0, "SetParent should not fail\n");
2683 ok(!SetParent(child2
, parent
), "SetParent should fail\n");
2684 ok(SetParent(parent
, child4
) != 0, "SetParent should not fail\n");
2686 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
2687 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
2688 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2689 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2690 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2693 hMenu
= CreateMenu();
2694 sibling
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
2695 100, 100, 200, 200, 0, hMenu
, 0, NULL
);
2696 assert(sibling
!= 0);
2698 ok(SetParent(sibling
, parent
) != 0, "SetParent should not fail\n");
2699 ok(GetMenu(sibling
) == hMenu
, "SetParent should not remove menu\n");
2701 ret
= DestroyWindow(parent
);
2702 ok( ret
, "DestroyWindow() error %ld\n", GetLastError());
2704 ok(!IsWindow(parent
), "parent still exists\n");
2705 ok(!IsWindow(sibling
), "sibling still exists\n");
2706 ok(!IsWindow(child1
), "child1 still exists\n");
2707 ok(!IsWindow(child2
), "child2 still exists\n");
2708 ok(!IsWindow(child3
), "child3 still exists\n");
2709 ok(!IsWindow(child4
), "child4 still exists\n");
2712 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2714 LPCREATESTRUCT lpcs
;
2721 lpcs
= (LPCREATESTRUCT
)lparam
;
2722 lpss
= (LPSTYLESTRUCT
)lpcs
->lpCreateParams
;
2725 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
2726 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
2727 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
2728 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
2730 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
2732 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
2733 "Ex style (0x%08lx) should match what the caller passed to CreateWindowEx (0x%08lx)\n",
2734 (lpss
->styleOld
& ~WS_EX_WINDOWEDGE
), (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
));
2736 ok(lpss
->styleNew
== lpcs
->style
,
2737 "Style (0x%08lx) should match what the caller passed to CreateWindowEx (0x%08lx)\n",
2738 lpss
->styleNew
, lpcs
->style
);
2742 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
2745 static ATOM atomStyleCheckClass
;
2747 static void register_style_check_class(void)
2755 GetModuleHandle(NULL
),
2757 LoadCursor(NULL
, IDC_ARROW
),
2758 (HBRUSH
)(COLOR_BTNFACE
+1),
2760 TEXT("WineStyleCheck"),
2763 atomStyleCheckClass
= RegisterClass(&wc
);
2766 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
2768 DWORD dwActualStyle
;
2769 DWORD dwActualExStyle
;
2772 HWND hwndParent
= NULL
;
2775 ss
.styleNew
= dwStyleIn
;
2776 ss
.styleOld
= dwExStyleIn
;
2778 if (dwStyleIn
& WS_CHILD
)
2780 hwndParent
= CreateWindowEx(0, MAKEINTATOM(atomStyleCheckClass
), NULL
,
2781 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
2784 hwnd
= CreateWindowEx(dwExStyleIn
, MAKEINTATOM(atomStyleCheckClass
), NULL
,
2785 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
2788 while (PeekMessage(&msg
, NULL
, 0, 0, PM_REMOVE
))
2790 TranslateMessage(&msg
);
2791 DispatchMessage(&msg
);
2794 dwActualStyle
= GetWindowLong(hwnd
, GWL_STYLE
);
2795 dwActualExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
2796 ok((dwActualStyle
== dwStyleOut
) && (dwActualExStyle
== dwExStyleOut
),
2797 "Style (0x%08lx) should really be 0x%08lx and/or Ex style (0x%08lx) should really be 0x%08lx\n",
2798 dwActualStyle
, dwStyleOut
, dwActualExStyle
, dwExStyleOut
);
2800 DestroyWindow(hwnd
);
2801 if (hwndParent
) DestroyWindow(hwndParent
);
2804 /* tests what window styles the window manager automatically adds */
2805 static void test_window_styles(void)
2807 register_style_check_class();
2809 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
2810 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
2811 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
2812 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
2813 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
2814 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
2815 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
2816 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
2817 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
2818 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
2819 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
2822 static void test_scrollvalidate( HWND parent
)
2825 HRGN hrgn
=CreateRectRgn(0,0,0,0);
2826 HRGN exprgn
, tmprgn
, clipping
;
2827 RECT rc
, rcu
, cliprc
;
2828 /* create two overlapping child windows. The visual region
2829 * of hwnd1 is clipped by the overlapping part of
2830 * hwnd2 because of the WS_CLIPSIBLING style */
2833 clipping
= CreateRectRgn(0,0,0,0);
2834 tmprgn
= CreateRectRgn(0,0,0,0);
2835 exprgn
= CreateRectRgn(0,0,0,0);
2836 hwnd2
= CreateWindowExA(0, "static", NULL
,
2837 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
2838 75, 30, 100, 100, parent
, 0, 0, NULL
);
2839 hwnd1
= CreateWindowExA(0, "static", NULL
,
2840 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
2841 25, 50, 100, 100, parent
, 0, 0, NULL
);
2842 ShowWindow( parent
, SW_SHOW
);
2843 UpdateWindow( parent
);
2844 GetClientRect( hwnd1
, &rc
);
2846 SetRectRgn( clipping
, 10, 10, 90, 90);
2847 hdc
= GetDC( hwnd1
);
2848 /* for a visual touch */
2849 TextOut( hdc
, 0,10, "0123456789", 10);
2850 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
2851 if (winetest_debug
> 0) dump_region(hrgn
);
2852 /* create a region with what is expected */
2853 SetRectRgn( exprgn
, 39,0,49,74);
2854 SetRectRgn( tmprgn
, 88,79,98,93);
2855 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2856 SetRectRgn( tmprgn
, 0,93,98,98);
2857 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2858 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2859 trace("update rect is %ld,%ld - %ld,%ld\n",
2860 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
2861 /* now with clipping region */
2862 SelectClipRgn( hdc
, clipping
);
2863 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
2864 if (winetest_debug
> 0) dump_region(hrgn
);
2865 /* create a region with what is expected */
2866 SetRectRgn( exprgn
, 39,10,49,74);
2867 SetRectRgn( tmprgn
, 80,79,90,85);
2868 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2869 SetRectRgn( tmprgn
, 10,85,90,90);
2870 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2871 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2872 trace("update rect is %ld,%ld - %ld,%ld\n",
2873 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
2874 ReleaseDC( hwnd1
, hdc
);
2876 /* test scrolling a window with an update region */
2877 DestroyWindow( hwnd2
);
2878 ValidateRect( hwnd1
, NULL
);
2879 SetRect( &rc
, 40,40, 50,50);
2880 InvalidateRect( hwnd1
, &rc
, 1);
2881 GetClientRect( hwnd1
, &rc
);
2883 ScrollWindowEx( hwnd1
, -10, 0, &rc
, &cliprc
, hrgn
, &rcu
,
2884 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
2885 if (winetest_debug
> 0) dump_region(hrgn
);
2886 SetRectRgn( exprgn
, 88,0,98,98);
2887 SetRectRgn( tmprgn
, 30, 40, 50, 50);
2888 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2889 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2891 /* now test ScrollWindowEx with a combination of
2892 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
2893 /* make hwnd2 the child of hwnd1 */
2894 hwnd2
= CreateWindowExA(0, "static", NULL
,
2895 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
2896 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
2897 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
2898 GetClientRect( hwnd1
, &rc
);
2901 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
2902 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
2903 ValidateRect( hwnd1
, NULL
);
2904 ValidateRect( hwnd2
, NULL
);
2905 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
2906 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
2907 if (winetest_debug
> 0) dump_region(hrgn
);
2908 SetRectRgn( exprgn
, 88,0,98,88);
2909 SetRectRgn( tmprgn
, 0,88,98,98);
2910 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2911 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2913 /* SW_SCROLLCHILDREN */
2914 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
2915 ValidateRect( hwnd1
, NULL
);
2916 ValidateRect( hwnd2
, NULL
);
2917 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
2918 if (winetest_debug
> 0) dump_region(hrgn
);
2919 /* expected region is the same as in previous test */
2920 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2922 /* no SW_SCROLLCHILDREN */
2923 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
2924 ValidateRect( hwnd1
, NULL
);
2925 ValidateRect( hwnd2
, NULL
);
2926 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
2927 if (winetest_debug
> 0) dump_region(hrgn
);
2928 /* expected region is the same as in previous test */
2929 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2931 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
2932 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
2933 ValidateRect( hwnd1
, NULL
);
2934 ValidateRect( hwnd2
, NULL
);
2935 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
2936 if (winetest_debug
> 0) dump_region(hrgn
);
2937 SetRectRgn( exprgn
, 88,0,98,20);
2938 SetRectRgn( tmprgn
, 20,20,98,30);
2939 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2940 SetRectRgn( tmprgn
, 20,30,30,88);
2941 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2942 SetRectRgn( tmprgn
, 0,88,30,98);
2943 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
2944 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
2947 DeleteObject( hrgn
);
2948 DeleteObject( exprgn
);
2949 DeleteObject( tmprgn
);
2950 DestroyWindow( hwnd1
);
2951 DestroyWindow( hwnd2
);
2954 /* couple of tests of return values of scrollbar functions
2955 * called on a scrollbarless window */
2956 static void test_scroll(void)
2961 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
2962 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
2963 100, 100, 200, 200, 0, 0, 0, NULL
);
2965 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
2966 ok( ret
, "GetScrollRange returns FALSE\n");
2967 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
2968 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
2969 si
.cbSize
= sizeof( si
);
2970 si
.fMask
= SIF_PAGE
;
2971 si
.nPage
= 0xdeadbeef;
2972 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
2973 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
2974 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
2976 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
2977 ok( ret
, "GetScrollRange returns FALSE\n");
2978 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
2979 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
2980 si
.cbSize
= sizeof( si
);
2981 si
.fMask
= SIF_PAGE
;
2982 si
.nPage
= 0xdeadbeef;
2983 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
2984 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
2985 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
2987 DestroyWindow( hwnd
);
2990 static void test_scrolldc( HWND parent
)
2993 HRGN exprgn
, tmprgn
, hrgn
;
2994 RECT rc
, rc2
, rcu
, cliprc
;
2998 hrgn
= CreateRectRgn(0,0,0,0);
2999 tmprgn
= CreateRectRgn(0,0,0,0);
3000 exprgn
= CreateRectRgn(0,0,0,0);
3002 hwnd1
= CreateWindowExA(0, "static", NULL
,
3003 WS_CHILD
| WS_VISIBLE
,
3004 25, 50, 100, 100, parent
, 0, 0, NULL
);
3005 ShowWindow( parent
, SW_SHOW
);
3006 UpdateWindow( parent
);
3007 GetClientRect( hwnd1
, &rc
);
3008 hdc
= GetDC( hwnd1
);
3009 /* paint the upper half of the window black */
3011 rc2
.bottom
= ( rc
.top
+ rc
.bottom
) /2;
3012 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3013 /* clip region is the lower half */
3015 cliprc
.top
= (rc
.top
+ rc
.bottom
) /2;
3016 /* test whether scrolled pixels are properly clipped */
3017 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
3018 ok ( colr
== 0, "pixel should be black, color is %08lx\n", colr
);
3019 /* this scroll should not cause any visible changes */
3020 ScrollDC( hdc
, 5, -20, &rc
, &cliprc
, hrgn
, &rcu
);
3021 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
3022 ok ( colr
== 0, "pixel should be black, color is %08lx\n", colr
);
3023 /* test with NULL clip rect */
3024 ScrollDC( hdc
, 20, -20, &rc
, NULL
, hrgn
, &rcu
);
3025 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
3026 trace("update rect: %ld,%ld - %ld,%ld\n",
3027 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
3028 if (winetest_debug
> 0) dump_region(hrgn
);
3029 SetRect(&rc2
, 0, 0, 100, 100);
3030 ok(EqualRect(&rcu
, &rc2
), "rects do not match (%ld,%ld-%ld,%ld) / (%ld,%ld-%ld,%ld)\n",
3031 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
3033 SetRectRgn( exprgn
, 0, 0, 20, 80);
3034 SetRectRgn( tmprgn
, 0, 80, 100, 100);
3035 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
3036 if (winetest_debug
> 0) dump_region(exprgn
);
3037 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
3038 /* test clip rect > scroll rect */
3039 FillRect( hdc
, &rc
, GetStockObject(WHITE_BRUSH
));
3041 InflateRect( &rc2
, -(rc
.right
-rc
.left
)/4, -(rc
.bottom
-rc
.top
)/4);
3042 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3043 ScrollDC( hdc
, 10, 10, &rc2
, &rc
, hrgn
, &rcu
);
3044 SetRectRgn( exprgn
, 25, 25, 75, 35);
3045 SetRectRgn( tmprgn
, 25, 35, 35, 75);
3046 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
3047 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
3048 colr
= GetPixel( hdc
, 80, 80);
3049 ok ( colr
== 0, "pixel should be black, color is %08lx\n", colr
);
3050 trace("update rect: %ld,%ld - %ld,%ld\n",
3051 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
3052 if (winetest_debug
> 0) dump_region(hrgn
);
3056 DeleteObject(exprgn
);
3057 DeleteObject(tmprgn
);
3058 DestroyWindow(hwnd1
);
3061 static void test_params(void)
3066 /* Just a param check */
3067 SetLastError(0xdeadbeef);
3068 rc
= GetWindowText(hwndMain2
, NULL
, 1024);
3069 ok( rc
==0, "GetWindowText: rc=%d err=%ld\n",rc
,GetLastError());
3071 SetLastError(0xdeadbeef);
3072 hwnd
=CreateWindow("LISTBOX", "TestList",
3073 (LBS_STANDARD
& ~LBS_SORT
),
3075 NULL
, (HMENU
)1, NULL
, 0);
3077 ok(!hwnd
, "CreateWindow with invalid menu handle should fail\n");
3078 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
|| /* NT */
3079 GetLastError() == 0xdeadbeef, /* Win9x */
3080 "wrong last error value %ld\n", GetLastError());
3083 static void test_AWRwindow(LPCSTR
class, LONG style
, LONG exStyle
, BOOL menu
)
3087 hwnd
= CreateWindowEx(exStyle
, class, class, style
,
3094 trace("Failed to create window class=%s, style=0x%08lx, exStyle=0x%08lx\n", class, style
, exStyle
);
3097 ShowWindow(hwnd
, SW_SHOW
);
3099 test_nonclient_area(hwnd
);
3102 DestroyWindow(hwnd
);
3105 static BOOL
AWR_init(void)
3109 class.style
= CS_HREDRAW
| CS_VREDRAW
;
3110 class.lpfnWndProc
= DefWindowProcA
;
3111 class.cbClsExtra
= 0;
3112 class.cbWndExtra
= 0;
3113 class.hInstance
= 0;
3114 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
3115 class.hCursor
= LoadCursor (0, IDC_ARROW
);
3116 class.hbrBackground
= 0;
3117 class.lpszMenuName
= 0;
3118 class.lpszClassName
= szAWRClass
;
3120 if (!RegisterClass (&class)) {
3121 ok(FALSE
, "RegisterClass failed\n");
3125 hmenu
= CreateMenu();
3128 ok(hmenu
!= 0, "Failed to create menu\n");
3129 ok(AppendMenu(hmenu
, MF_STRING
, 1, "Test!"), "Failed to create menu item\n");
3135 static void test_AWR_window_size(BOOL menu
)
3139 WS_MAXIMIZE
, WS_BORDER
, WS_DLGFRAME
,
3142 WS_MINIMIZEBOX
, WS_MAXIMIZEBOX
,
3143 WS_HSCROLL
, WS_VSCROLL
3147 WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
,
3150 /* These styles have problems on (at least) WinXP (SP2) and Wine */
3151 WS_EX_DLGMODALFRAME
,
3158 /* A exhaustive check of all the styles takes too long
3159 * so just do a (hopefully representative) sample
3161 for (i
= 0; i
< COUNTOF(styles
); ++i
)
3162 test_AWRwindow(szAWRClass
, styles
[i
], 0, menu
);
3163 for (i
= 0; i
< COUNTOF(exStyles
); ++i
) {
3164 test_AWRwindow(szAWRClass
, WS_POPUP
, exStyles
[i
], menu
);
3165 test_AWRwindow(szAWRClass
, WS_THICKFRAME
, exStyles
[i
], menu
);
3170 #define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
3172 static void test_AdjustWindowRect(void)
3177 SHOWSYSMETRIC(SM_CYCAPTION
);
3178 SHOWSYSMETRIC(SM_CYSMCAPTION
);
3179 SHOWSYSMETRIC(SM_CYMENU
);
3180 SHOWSYSMETRIC(SM_CXEDGE
);
3181 SHOWSYSMETRIC(SM_CYEDGE
);
3182 SHOWSYSMETRIC(SM_CXVSCROLL
);
3183 SHOWSYSMETRIC(SM_CYHSCROLL
);
3184 SHOWSYSMETRIC(SM_CXFRAME
);
3185 SHOWSYSMETRIC(SM_CYFRAME
);
3186 SHOWSYSMETRIC(SM_CXDLGFRAME
);
3187 SHOWSYSMETRIC(SM_CYDLGFRAME
);
3188 SHOWSYSMETRIC(SM_CXBORDER
);
3189 SHOWSYSMETRIC(SM_CYBORDER
);
3191 test_AWR_window_size(FALSE
);
3192 test_AWR_window_size(TRUE
);
3196 #undef SHOWSYSMETRIC
3199 /* Global variables to trigger exit from loop */
3200 static int redrawComplete
, WMPAINT_count
;
3202 static LRESULT WINAPI
redraw_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3207 trace("doing WM_PAINT %d\n", WMPAINT_count
);
3209 if (WMPAINT_count
> 10 && redrawComplete
== 0) {
3211 BeginPaint(hwnd
, &ps
);
3212 EndPaint(hwnd
, &ps
);
3218 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3221 /* Ensure we exit from RedrawNow regardless of invalidated area */
3222 static void test_redrawnow(void)
3227 cls
.style
= CS_DBLCLKS
;
3228 cls
.lpfnWndProc
= redraw_window_procA
;
3231 cls
.hInstance
= GetModuleHandleA(0);
3233 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3234 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3235 cls
.lpszMenuName
= NULL
;
3236 cls
.lpszClassName
= "RedrawWindowClass";
3238 if(!RegisterClassA(&cls
)) {
3239 trace("Register failed %ld\n", GetLastError());
3243 hwndMain
= CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
3244 CW_USEDEFAULT
, 0, 100, 100, NULL
, NULL
, 0, NULL
);
3246 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3247 ShowWindow(hwndMain
, SW_SHOW
);
3248 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3249 RedrawWindow(hwndMain
, NULL
,NULL
,RDW_UPDATENOW
| RDW_ALLCHILDREN
);
3250 ok( WMPAINT_count
== 1, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3251 redrawComplete
= TRUE
;
3252 ok( WMPAINT_count
< 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count
);
3255 DestroyWindow( hwndMain
);
3258 struct parentdc_stat
{
3264 struct parentdc_test
{
3265 struct parentdc_stat main
, main_todo
;
3266 struct parentdc_stat child1
, child1_todo
;
3267 struct parentdc_stat child2
, child2_todo
;
3270 static LRESULT WINAPI
parentdc_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3275 struct parentdc_stat
*t
= (struct parentdc_stat
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
3280 trace("doing WM_PAINT on %p\n", hwnd
);
3281 GetClientRect(hwnd
, &rc
);
3282 CopyRect(&t
->client
, &rc
);
3283 trace("client rect (%ld, %ld)-(%ld, %ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3284 GetWindowRect(hwnd
, &rc
);
3285 trace("window rect (%ld, %ld)-(%ld, %ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3286 BeginPaint(hwnd
, &ps
);
3287 CopyRect(&t
->paint
, &ps
.rcPaint
);
3288 GetClipBox(ps
.hdc
, &rc
);
3289 CopyRect(&t
->clip
, &rc
);
3290 trace("clip rect (%ld, %ld)-(%ld, %ld)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3291 trace("paint rect (%ld, %ld)-(%ld, %ld)\n", ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
3292 EndPaint(hwnd
, &ps
);
3295 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3298 static void zero_parentdc_stat(struct parentdc_stat
*t
)
3300 SetRectEmpty(&t
->client
);
3301 SetRectEmpty(&t
->clip
);
3302 SetRectEmpty(&t
->paint
);
3305 static void zero_parentdc_test(struct parentdc_test
*t
)
3307 zero_parentdc_stat(&t
->main
);
3308 zero_parentdc_stat(&t
->child1
);
3309 zero_parentdc_stat(&t
->child2
);
3312 #define parentdc_field_ok(t, w, r, f, got) \
3313 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
3314 ": expected %ld, got %ld\n", \
3317 #define parentdc_todo_field_ok(t, w, r, f, got) \
3318 if (t.w##_todo.r.f) todo_wine { parentdc_field_ok(t, w, r, f, got); } \
3319 else parentdc_field_ok(t, w, r, f, got)
3321 #define parentdc_rect_ok(t, w, r, got) \
3322 parentdc_todo_field_ok(t, w, r, left, got); \
3323 parentdc_todo_field_ok(t, w, r, top, got); \
3324 parentdc_todo_field_ok(t, w, r, right, got); \
3325 parentdc_todo_field_ok(t, w, r, bottom, got);
3327 #define parentdc_win_ok(t, w, got) \
3328 parentdc_rect_ok(t, w, client, got); \
3329 parentdc_rect_ok(t, w, clip, got); \
3330 parentdc_rect_ok(t, w, paint, got);
3332 #define parentdc_ok(t, got) \
3333 parentdc_win_ok(t, main, got); \
3334 parentdc_win_ok(t, child1, got); \
3335 parentdc_win_ok(t, child2, got);
3337 static void test_csparentdc(void)
3339 WNDCLASSA clsMain
, cls
;
3340 HWND hwndMain
, hwnd1
, hwnd2
;
3344 struct parentdc_test test_answer
;
3346 #define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
3347 const struct parentdc_test test1
=
3349 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo
,
3350 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3351 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3354 const struct parentdc_test test2
=
3356 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo
,
3357 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3358 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3361 const struct parentdc_test test3
=
3363 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3364 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3365 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3368 const struct parentdc_test test4
=
3370 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo
,
3371 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo
,
3372 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3375 const struct parentdc_test test5
=
3377 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo
,
3378 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3379 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3382 const struct parentdc_test test6
=
3384 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3385 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3386 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3389 const struct parentdc_test test7
=
3391 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3392 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3393 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3397 clsMain
.style
= CS_DBLCLKS
;
3398 clsMain
.lpfnWndProc
= parentdc_window_procA
;
3399 clsMain
.cbClsExtra
= 0;
3400 clsMain
.cbWndExtra
= 0;
3401 clsMain
.hInstance
= GetModuleHandleA(0);
3403 clsMain
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3404 clsMain
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3405 clsMain
.lpszMenuName
= NULL
;
3406 clsMain
.lpszClassName
= "ParentDcMainWindowClass";
3408 if(!RegisterClassA(&clsMain
)) {
3409 trace("Register failed %ld\n", GetLastError());
3413 cls
.style
= CS_DBLCLKS
| CS_PARENTDC
;
3414 cls
.lpfnWndProc
= parentdc_window_procA
;
3417 cls
.hInstance
= GetModuleHandleA(0);
3419 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3420 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3421 cls
.lpszMenuName
= NULL
;
3422 cls
.lpszClassName
= "ParentDcWindowClass";
3424 if(!RegisterClassA(&cls
)) {
3425 trace("Register failed %ld\n", GetLastError());
3429 SetRect(&rc
, 0, 0, 150, 150);
3430 AdjustWindowRectEx(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
, 0);
3431 hwndMain
= CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
3432 CW_USEDEFAULT
, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, NULL
, NULL
, 0, NULL
);
3433 SetWindowLongPtrA(hwndMain
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.main
);
3434 hwnd1
= CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD
,
3435 20, 20, 40, 40, hwndMain
, NULL
, 0, NULL
);
3436 SetWindowLongPtrA(hwnd1
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child1
);
3437 hwnd2
= CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD
,
3438 40, 40, 40, 40, hwndMain
, NULL
, 0, NULL
);
3439 SetWindowLongPtrA(hwnd2
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child2
);
3440 ShowWindow(hwndMain
, SW_SHOW
);
3441 ShowWindow(hwnd1
, SW_SHOW
);
3442 ShowWindow(hwnd2
, SW_SHOW
);
3445 zero_parentdc_test(&test_answer
);
3446 InvalidateRect(hwndMain
, NULL
, TRUE
);
3447 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3448 parentdc_ok(test1
, test_answer
);
3450 zero_parentdc_test(&test_answer
);
3451 SetRect(&rc
, 0, 0, 50, 50);
3452 InvalidateRect(hwndMain
, &rc
, TRUE
);
3453 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3454 parentdc_ok(test2
, test_answer
);
3456 zero_parentdc_test(&test_answer
);
3457 SetRect(&rc
, 0, 0, 10, 10);
3458 InvalidateRect(hwndMain
, &rc
, TRUE
);
3459 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3460 parentdc_ok(test3
, test_answer
);
3462 zero_parentdc_test(&test_answer
);
3463 SetRect(&rc
, 40, 40, 50, 50);
3464 InvalidateRect(hwndMain
, &rc
, TRUE
);
3465 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3466 parentdc_ok(test4
, test_answer
);
3468 zero_parentdc_test(&test_answer
);
3469 SetRect(&rc
, 20, 20, 60, 60);
3470 InvalidateRect(hwndMain
, &rc
, TRUE
);
3471 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3472 parentdc_ok(test5
, test_answer
);
3474 zero_parentdc_test(&test_answer
);
3475 SetRect(&rc
, 0, 0, 10, 10);
3476 InvalidateRect(hwnd1
, &rc
, TRUE
);
3477 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3478 parentdc_ok(test6
, test_answer
);
3480 zero_parentdc_test(&test_answer
);
3481 SetRect(&rc
, -5, -5, 65, 65);
3482 InvalidateRect(hwnd1
, &rc
, TRUE
);
3483 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3484 parentdc_ok(test7
, test_answer
);
3486 DestroyWindow(hwndMain
);
3487 DestroyWindow(hwnd1
);
3488 DestroyWindow(hwnd2
);
3491 static void test_IsWindowUnicode(void)
3493 static const char ansi_class_nameA
[] = "ansi class name";
3494 static const WCHAR ansi_class_nameW
[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
3495 static const char unicode_class_nameA
[] = "unicode class name";
3496 static const WCHAR unicode_class_nameW
[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
3501 memset(&classW
, 0, sizeof(classW
));
3502 classW
.hInstance
= GetModuleHandleA(0);
3503 classW
.lpfnWndProc
= DefWindowProcW
;
3504 classW
.lpszClassName
= unicode_class_nameW
;
3505 if (!RegisterClassW(&classW
)) return;
3507 memset(&classA
, 0, sizeof(classA
));
3508 classA
.hInstance
= GetModuleHandleA(0);
3509 classA
.lpfnWndProc
= DefWindowProcA
;
3510 classA
.lpszClassName
= ansi_class_nameA
;
3511 assert(RegisterClassA(&classA
));
3513 /* unicode class: window proc */
3514 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
3515 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3518 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3519 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3520 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3521 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3522 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3524 DestroyWindow(hwnd
);
3526 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
3527 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3530 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3531 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3532 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3533 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3534 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3536 DestroyWindow(hwnd
);
3538 /* ansi class: window proc */
3539 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
3540 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3543 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3544 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3545 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3546 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3547 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3549 DestroyWindow(hwnd
);
3551 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
3552 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3555 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3556 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3557 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3558 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3559 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3561 DestroyWindow(hwnd
);
3563 /* unicode class: class proc */
3564 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
3565 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3568 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3569 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3570 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3571 /* do not restore class window proc back to unicode */
3573 DestroyWindow(hwnd
);
3575 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
3576 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3579 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3580 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3581 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3583 DestroyWindow(hwnd
);
3585 /* ansi class: class proc */
3586 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
3587 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3590 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3591 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcW
);
3592 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3593 /* do not restore class window proc back to ansi */
3595 DestroyWindow(hwnd
);
3597 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
3598 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3601 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3602 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)DefWindowProcA
);
3603 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3605 DestroyWindow(hwnd
);
3610 pGetAncestor
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
3611 pGetWindowInfo
= (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetWindowInfo" );
3613 hwndMain
= CreateWindowExA(0, "static", NULL
, 0, 0, 0, 0, 0, HWND_MESSAGE
, 0, 0, NULL
);
3616 ok(!GetParent(hwndMain
), "GetParent should return 0 for message only windows\n");
3619 hwndMessage
= pGetAncestor(hwndMain
, GA_PARENT
);
3620 ok(hwndMessage
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message only windows\n");
3621 trace("hwndMessage %p\n", hwndMessage
);
3623 DestroyWindow(hwndMain
);
3626 trace("CreateWindowExA with parent HWND_MESSAGE failed\n");
3628 if (!RegisterWindowClasses()) assert(0);
3630 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
3633 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
3634 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3635 WS_MAXIMIZEBOX
| WS_POPUP
,
3638 test_nonclient_area(hwndMain
);
3640 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
3641 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
3642 WS_MAXIMIZEBOX
| WS_POPUP
,
3646 assert( hwndMain2
);
3648 /* Add the tests below this line */
3653 test_capture_3(hwndMain
, hwndMain2
);
3655 test_parent_owner();
3657 test_shell_window();
3661 test_SetWindowPos(hwndMain
);
3662 test_SetMenu(hwndMain
);
3663 test_SetFocus(hwndMain
);
3664 test_SetActiveWindow(hwndMain
);
3666 test_children_zorder(hwndMain
);
3667 test_keyboard_input(hwndMain
);
3668 test_mouse_input(hwndMain
);
3669 test_validatergn(hwndMain
);
3670 test_nccalcscroll( hwndMain
);
3671 test_scrollvalidate( hwndMain
);
3672 test_scrolldc( hwndMain
);
3674 test_IsWindowUnicode();
3675 test_vis_rgn(hwndMain
);
3677 test_AdjustWindowRect();
3678 test_window_styles();
3682 /* add the tests above this line */
3683 UnhookWindowsHookEx(hhook
);