2 * Unit tests for window handling
4 * Copyright 2002 Bill Medland
5 * Copyright 2002 Alexandre Julliard
6 * Copyright 2003 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 /* To get ICON_SMALL2 with the MSVC headers */
24 #define _WIN32_WINNT 0x0501
36 #include "wine/test.h"
38 #ifndef SPI_GETDESKWALLPAPER
39 #define SPI_GETDESKWALLPAPER 0x0073
42 #define LONG_PTR INT_PTR
43 #define ULONG_PTR UINT_PTR
45 void dump_region(HRGN hrgn
);
47 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
48 static BOOL (WINAPI
*pGetWindowInfo
)(HWND
,WINDOWINFO
*);
49 static UINT (WINAPI
*pGetWindowModuleFileNameA
)(HWND
,LPSTR
,UINT
);
50 static BOOL (WINAPI
*pGetLayeredWindowAttributes
)(HWND
,COLORREF
*,BYTE
*,DWORD
*);
51 static BOOL (WINAPI
*pSetLayeredWindowAttributes
)(HWND
,COLORREF
,BYTE
,DWORD
);
52 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
53 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
55 static BOOL test_lbuttondown_flag
;
56 static HWND hwndMessage
;
57 static HWND hwndMain
, hwndMain2
;
60 static const char* szAWRClass
= "Winsize";
64 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
66 static void dump_minmax_info( const MINMAXINFO
*minmax
)
68 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
69 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
70 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
71 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
72 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
73 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
76 /* try to make sure pending X events have been processed before continuing */
77 static void flush_events( BOOL remove_messages
)
82 DWORD time
= GetTickCount() + diff
;
86 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
88 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
89 diff
= time
- GetTickCount();
94 /* check the values returned by the various parent/owner functions on a given window */
95 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
96 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
102 res
= pGetAncestor( hwnd
, GA_PARENT
);
103 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
105 res
= (HWND
)GetWindowLongPtrA( hwnd
, GWLP_HWNDPARENT
);
106 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
107 res
= GetParent( hwnd
);
108 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
109 res
= GetWindow( hwnd
, GW_OWNER
);
110 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
113 res
= pGetAncestor( hwnd
, GA_ROOT
);
114 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
115 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
116 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
120 static BOOL CALLBACK
EnumChildProc( HWND hwndChild
, LPARAM lParam
)
123 trace("EnumChildProc on %p\n", hwndChild
);
124 if (*(LPINT
)lParam
> 1) return FALSE
;
128 /* will search for the given window */
129 static BOOL CALLBACK
EnumChildProc1( HWND hwndChild
, LPARAM lParam
)
131 trace("EnumChildProc1 on %p\n", hwndChild
);
132 if ((HWND
)lParam
== hwndChild
) return FALSE
;
136 static HWND
create_tool_window( LONG style
, HWND parent
)
138 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
139 0, 0, 100, 100, parent
, 0, 0, NULL
);
140 ok( ret
!= 0, "Creation failed\n" );
144 /* test parent and owner values for various combinations */
145 static void test_parent_owner(void)
148 HWND test
, owner
, ret
;
149 HWND desktop
= GetDesktopWindow();
150 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
153 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
155 /* child without parent, should fail */
156 SetLastError(0xdeadbeef);
157 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
158 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
159 ok( GetLastError() == ERROR_TLW_WITH_WSCHILD
, "CreateWindowExA should call SetLastError\n" );
160 ok( !test
, "WS_CHILD without parent created\n" );
163 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
164 style
= GetWindowLongA( desktop
, GWL_STYLE
);
165 ok( !SetWindowLongA( desktop
, GWL_STYLE
, WS_POPUP
), "Set GWL_STYLE on desktop succeeded\n" );
166 ok( !SetWindowLongA( desktop
, GWL_STYLE
, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
167 ok( GetWindowLongA( desktop
, GWL_STYLE
) == style
, "Desktop style changed\n" );
169 /* normal child window */
170 test
= create_tool_window( WS_CHILD
, hwndMain
);
171 trace( "created child %p\n", test
);
172 check_parents( test
, hwndMain
, hwndMain
, hwndMain
, 0, hwndMain
, hwndMain
);
173 SetWindowLongA( test
, GWL_STYLE
, 0 );
174 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
175 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
176 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
177 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
178 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
179 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
180 DestroyWindow( test
);
182 /* normal child window with WS_MAXIMIZE */
183 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
184 DestroyWindow( test
);
186 /* normal child window with WS_THICKFRAME */
187 test
= create_tool_window( WS_CHILD
| WS_THICKFRAME
, hwndMain
);
188 DestroyWindow( test
);
190 /* popup window with WS_THICKFRAME */
191 test
= create_tool_window( WS_POPUP
| WS_THICKFRAME
, hwndMain
);
192 DestroyWindow( test
);
194 /* child of desktop */
195 test
= create_tool_window( WS_CHILD
, desktop
);
196 trace( "created child of desktop %p\n", test
);
197 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
198 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
199 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
200 SetWindowLongA( test
, GWL_STYLE
, 0 );
201 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
202 DestroyWindow( test
);
204 /* child of desktop with WS_MAXIMIZE */
205 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, desktop
);
206 DestroyWindow( test
);
208 /* child of desktop with WS_MINIMIZE */
209 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, desktop
);
210 DestroyWindow( test
);
213 test
= create_tool_window( WS_CHILD
, child
);
214 trace( "created child of child %p\n", test
);
215 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
216 SetWindowLongA( test
, GWL_STYLE
, 0 );
217 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
218 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
219 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
220 DestroyWindow( test
);
222 /* child of child with WS_MAXIMIZE */
223 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, child
);
224 DestroyWindow( test
);
226 /* child of child with WS_MINIMIZE */
227 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, child
);
228 DestroyWindow( test
);
230 /* not owned top-level window */
231 test
= create_tool_window( 0, 0 );
232 trace( "created top-level %p\n", test
);
233 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
234 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
235 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
236 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
237 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
238 DestroyWindow( test
);
240 /* not owned top-level window with WS_MAXIMIZE */
241 test
= create_tool_window( WS_MAXIMIZE
, 0 );
242 DestroyWindow( test
);
244 /* owned top-level window */
245 test
= create_tool_window( 0, hwndMain
);
246 trace( "created owned top-level %p\n", test
);
247 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
248 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
249 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
250 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
251 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
252 DestroyWindow( test
);
254 /* owned top-level window with WS_MAXIMIZE */
255 test
= create_tool_window( WS_MAXIMIZE
, hwndMain
);
256 DestroyWindow( test
);
258 /* not owned popup */
259 test
= create_tool_window( WS_POPUP
, 0 );
260 trace( "created popup %p\n", test
);
261 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
262 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
263 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
264 SetWindowLongA( test
, GWL_STYLE
, 0 );
265 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
266 DestroyWindow( test
);
268 /* not owned popup with WS_MAXIMIZE */
269 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, 0 );
270 DestroyWindow( test
);
273 test
= create_tool_window( WS_POPUP
, hwndMain
);
274 trace( "created owned popup %p\n", test
);
275 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
276 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
277 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
278 SetWindowLongA( test
, GWL_STYLE
, 0 );
279 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
280 DestroyWindow( test
);
282 /* owned popup with WS_MAXIMIZE */
283 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, hwndMain
);
284 DestroyWindow( test
);
286 /* top-level window owned by child (same as owned by top-level) */
287 test
= create_tool_window( 0, child
);
288 trace( "created top-level owned by child %p\n", test
);
289 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
290 DestroyWindow( test
);
292 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
293 test
= create_tool_window( WS_MAXIMIZE
, child
);
294 DestroyWindow( test
);
296 /* popup owned by desktop (same as not owned) */
297 test
= create_tool_window( WS_POPUP
, desktop
);
298 trace( "created popup owned by desktop %p\n", test
);
299 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
300 DestroyWindow( test
);
302 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
303 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, desktop
);
304 DestroyWindow( test
);
306 /* popup owned by child (same as owned by top-level) */
307 test
= create_tool_window( WS_POPUP
, child
);
308 trace( "created popup owned by child %p\n", test
);
309 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
310 DestroyWindow( test
);
312 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
313 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, child
);
314 DestroyWindow( test
);
316 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
317 test
= create_tool_window( WS_POPUP
| WS_CHILD
, 0 );
318 trace( "created WS_CHILD popup %p\n", test
);
319 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
320 DestroyWindow( test
);
322 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
323 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, 0 );
324 DestroyWindow( test
);
326 /* owned popup with WS_CHILD (same as WS_POPUP only) */
327 test
= create_tool_window( WS_POPUP
| WS_CHILD
, hwndMain
);
328 trace( "created owned WS_CHILD popup %p\n", test
);
329 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
330 DestroyWindow( test
);
332 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
333 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
334 DestroyWindow( test
);
336 /******************** parent changes *************************/
337 trace( "testing parent changes\n" );
340 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
343 /* this test succeeds on NT but crashes on win9x systems */
344 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
345 ok( !ret
, "Set GWL_HWNDPARENT succeeded on desktop\n" );
346 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
347 ok( !SetParent( desktop
, hwndMain
), "SetParent succeeded on desktop\n" );
348 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
350 /* normal child window */
351 test
= create_tool_window( WS_CHILD
, hwndMain
);
352 trace( "created child %p\n", test
);
354 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
355 ok( ret
== hwndMain
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain
);
356 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
358 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
359 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
360 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
362 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)desktop
);
363 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
364 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
366 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
367 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
368 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
369 check_parents( test
, desktop
, child
, desktop
, child
, test
, desktop
);
371 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
372 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
373 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
374 DestroyWindow( test
);
376 /* not owned top-level window */
377 test
= create_tool_window( 0, 0 );
378 trace( "created top-level %p\n", test
);
380 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
381 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
382 check_parents( test
, desktop
, hwndMain2
, 0, hwndMain2
, test
, test
);
384 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
385 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
386 check_parents( test
, desktop
, child
, 0, child
, test
, test
);
388 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
389 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
390 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
391 DestroyWindow( test
);
393 /* not owned popup */
394 test
= create_tool_window( WS_POPUP
, 0 );
395 trace( "created popup %p\n", test
);
397 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
398 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
399 check_parents( test
, desktop
, hwndMain2
, hwndMain2
, hwndMain2
, test
, hwndMain2
);
401 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
402 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
403 check_parents( test
, desktop
, child
, child
, child
, test
, hwndMain
);
405 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
406 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
407 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
408 DestroyWindow( test
);
410 /* normal child window */
411 test
= create_tool_window( WS_CHILD
, hwndMain
);
412 trace( "created child %p\n", test
);
414 ret
= SetParent( test
, desktop
);
415 ok( ret
== hwndMain
, "SetParent return value %p expected %p\n", ret
, hwndMain
);
416 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
418 ret
= SetParent( test
, child
);
419 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
420 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
422 ret
= SetParent( test
, hwndMain2
);
423 ok( ret
== child
, "SetParent return value %p expected %p\n", ret
, child
);
424 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
425 DestroyWindow( test
);
427 /* not owned top-level window */
428 test
= create_tool_window( 0, 0 );
429 trace( "created top-level %p\n", test
);
431 ret
= SetParent( test
, child
);
432 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
433 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
434 DestroyWindow( test
);
437 test
= create_tool_window( WS_POPUP
, hwndMain2
);
438 trace( "created owned popup %p\n", test
);
440 ret
= SetParent( test
, child
);
441 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
442 check_parents( test
, child
, child
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
444 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)hwndMain
);
445 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
446 check_parents( test
, hwndMain
, hwndMain
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
447 DestroyWindow( test
);
449 /**************** test owner destruction *******************/
451 /* owned child popup */
452 owner
= create_tool_window( 0, 0 );
453 test
= create_tool_window( WS_POPUP
, owner
);
454 trace( "created owner %p and popup %p\n", owner
, test
);
455 ret
= SetParent( test
, child
);
456 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
457 check_parents( test
, child
, child
, owner
, owner
, hwndMain
, owner
);
458 /* window is now child of 'child' but owned by 'owner' */
459 DestroyWindow( owner
);
460 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
461 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
462 * while Win95, Win2k, WinXP do.
464 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
465 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
468 /* owned top-level popup */
469 owner
= create_tool_window( 0, 0 );
470 test
= create_tool_window( WS_POPUP
, owner
);
471 trace( "created owner %p and popup %p\n", owner
, test
);
472 check_parents( test
, desktop
, owner
, owner
, owner
, test
, owner
);
473 DestroyWindow( owner
);
474 ok( !IsWindow(test
), "Window %p not destroyed by owner destruction\n", test
);
476 /* top-level popup owned by child */
477 owner
= create_tool_window( WS_CHILD
, hwndMain2
);
478 test
= create_tool_window( WS_POPUP
, 0 );
479 trace( "created owner %p and popup %p\n", owner
, test
);
480 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)owner
);
481 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
482 check_parents( test
, desktop
, owner
, owner
, owner
, test
, hwndMain2
);
483 DestroyWindow( owner
);
484 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
485 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
486 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
487 * while Win95, Win2k, WinXP do.
489 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
493 DestroyWindow(child
);
496 owner
= create_tool_window( WS_OVERLAPPED
, 0 );
497 test
= create_tool_window( WS_POPUP
, desktop
);
499 ok( !GetWindow( test
, GW_OWNER
), "Wrong owner window\n" );
501 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
502 "EnumChildWindows should have returned FALSE\n" );
503 ok( numChildren
== 0, "numChildren should be 0 got %d\n", numChildren
);
505 SetWindowLongA( test
, GWL_STYLE
, (GetWindowLongA( test
, GWL_STYLE
) & ~WS_POPUP
) | WS_CHILD
);
506 ret
= SetParent( test
, owner
);
507 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
510 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
511 "EnumChildWindows should have returned TRUE\n" );
512 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
514 child
= create_tool_window( WS_CHILD
, owner
);
516 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
517 "EnumChildWindows should have returned FALSE\n" );
518 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
519 DestroyWindow( child
);
521 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
522 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
524 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
525 "EnumChildWindows should have returned TRUE\n" );
526 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
528 ret
= SetParent( child
, owner
);
529 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
530 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
532 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
533 "EnumChildWindows should have returned FALSE\n" );
534 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
536 ret
= SetParent( child
, NULL
);
537 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
538 ok( ret
== owner
, "SetParent return value %p expected %p\n", ret
, owner
);
540 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
541 "EnumChildWindows should have returned TRUE\n" );
542 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
544 /* even GW_OWNER == owner it's still a desktop's child */
545 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
546 "EnumChildWindows should have found %p and returned FALSE\n", child
);
548 DestroyWindow( child
);
549 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, NULL
);
551 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
552 "EnumChildWindows should have found %p and returned FALSE\n", child
);
554 DestroyWindow( child
);
555 DestroyWindow( test
);
556 DestroyWindow( owner
);
560 static LRESULT WINAPI
main_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
564 case WM_GETMINMAXINFO
:
566 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
568 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
569 dump_minmax_info( minmax
);
570 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
573 case WM_WINDOWPOSCHANGING
:
575 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
576 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
577 trace("main: WM_WINDOWPOSCHANGING\n");
578 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
579 winpos
->hwnd
, winpos
->hwndInsertAfter
,
580 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
581 if (!(winpos
->flags
& SWP_NOMOVE
))
583 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
584 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
586 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
587 if (!(winpos
->flags
& SWP_NOSIZE
) && !is_win9x
)
589 ok(winpos
->cx
>= 0 && winpos
->cx
<= 32767, "bad winpos->cx %d\n", winpos
->cx
);
590 ok(winpos
->cy
>= 0 && winpos
->cy
<= 32767, "bad winpos->cy %d\n", winpos
->cy
);
594 case WM_WINDOWPOSCHANGED
:
597 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
598 trace("main: WM_WINDOWPOSCHANGED\n");
599 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
600 winpos
->hwnd
, winpos
->hwndInsertAfter
,
601 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
602 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
603 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
605 ok(winpos
->cx
>= 0 && winpos
->cx
<= 32767, "bad winpos->cx %d\n", winpos
->cx
);
606 ok(winpos
->cy
>= 0 && winpos
->cy
<= 32767, "bad winpos->cy %d\n", winpos
->cy
);
608 GetWindowRect(hwnd
, &rc1
);
609 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
610 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
611 /* note: winpos coordinates are relative to parent */
612 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
613 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
616 /* Uncomment this once the test succeeds in all cases */
617 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
620 GetClientRect(hwnd
, &rc2
);
621 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
622 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
623 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
624 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
629 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
630 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
632 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
633 if (got_getminmaxinfo
)
634 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
636 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
637 ok(got_getminmaxinfo
, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
639 ok(!got_getminmaxinfo
, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
643 if (test_lbuttondown_flag
)
645 ShowWindow((HWND
)wparam
, SW_SHOW
);
646 flush_events( FALSE
);
651 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
654 static LRESULT WINAPI
tool_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
658 case WM_GETMINMAXINFO
:
660 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
662 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
663 dump_minmax_info( minmax
);
664 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
669 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
670 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
672 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
673 if (got_getminmaxinfo
)
674 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
676 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
677 ok(got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
679 ok(!got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
684 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
687 static BOOL
RegisterWindowClasses(void)
691 cls
.style
= CS_DBLCLKS
;
692 cls
.lpfnWndProc
= main_window_procA
;
695 cls
.hInstance
= GetModuleHandleA(0);
697 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
698 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
699 cls
.lpszMenuName
= NULL
;
700 cls
.lpszClassName
= "MainWindowClass";
702 if(!RegisterClassA(&cls
)) return FALSE
;
705 cls
.lpfnWndProc
= tool_window_procA
;
708 cls
.hInstance
= GetModuleHandleA(0);
710 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
711 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
712 cls
.lpszMenuName
= NULL
;
713 cls
.lpszClassName
= "ToolWindowClass";
715 if(!RegisterClassA(&cls
)) return FALSE
;
720 static void verify_window_info(HWND hwnd
, const WINDOWINFO
*info
)
722 RECT rcWindow
, rcClient
;
725 ok(IsWindow(hwnd
), "bad window handle\n");
727 GetWindowRect(hwnd
, &rcWindow
);
728 ok(EqualRect(&rcWindow
, &info
->rcWindow
), "wrong rcWindow\n");
730 GetClientRect(hwnd
, &rcClient
);
731 /* translate to screen coordinates */
732 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rcClient
, 2);
733 ok(EqualRect(&rcClient
, &info
->rcClient
), "wrong rcClient\n");
735 ok(info
->dwStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_STYLE
),
736 "wrong dwStyle: %08x != %08x\n", info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
));
737 /* Windows reports some undocumented exstyles in WINDOWINFO, but
738 * doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
740 ok((info
->dwExStyle
& ~0xe0000800) == (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
741 "wrong dwExStyle: %08x != %08x\n", info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
));
742 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
743 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04x != %04x active %p fg %p\n",
744 info
->dwWindowStatus
, status
, GetActiveWindow(), GetForegroundWindow());
746 /* win2k and XP return broken border info in GetWindowInfo most of
747 * the time, so there is no point in testing it.
751 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
752 "wrong cxWindowBorders %d != %d\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
753 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
754 ok(info
->cyWindowBorders
== border
,
755 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
757 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType\n");
758 ok(info
->wCreatorVersion
== 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
759 info
->wCreatorVersion
== 0x0500 /* Vista */,
760 "wrong wCreatorVersion %04x\n", info
->wCreatorVersion
);
763 static void FixedAdjustWindowRectEx(RECT
* rc
, LONG style
, BOOL menu
, LONG exstyle
)
765 AdjustWindowRectEx(rc
, style
, menu
, exstyle
);
766 /* AdjustWindowRectEx does not include scroll bars */
767 if (style
& WS_VSCROLL
)
769 if(exstyle
& WS_EX_LEFTSCROLLBAR
)
770 rc
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
772 rc
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
774 if (style
& WS_HSCROLL
)
775 rc
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
778 static void test_nonclient_area(HWND hwnd
)
780 DWORD style
, exstyle
;
781 RECT rc_window
, rc_client
, rc
;
783 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
786 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
787 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
788 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
790 GetWindowRect(hwnd
, &rc_window
);
791 trace("window: (%d,%d)-(%d,%d)\n", rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
792 GetClientRect(hwnd
, &rc_client
);
793 trace("client: (%d,%d)-(%d,%d)\n", rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
);
795 /* avoid some cases when things go wrong */
796 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
797 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
799 CopyRect(&rc
, &rc_client
);
800 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
801 FixedAdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
803 trace("calc window: (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
804 ok(EqualRect(&rc
, &rc_window
), "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d\n", style
, exstyle
, menu
);
807 CopyRect(&rc
, &rc_window
);
808 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
809 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
810 trace("calc client: (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
811 ok(EqualRect(&rc
, &rc_client
), "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d\n", style
, exstyle
, menu
);
813 /* NULL rectangle shouldn't crash */
814 ret
= DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, 0);
815 ok(ret
== 0, "NULL rectangle returned %ld instead of 0\n", ret
);
817 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
821 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
822 SetRect(&rc_client
, 0, 0, 250, 150);
823 CopyRect(&rc_window
, &rc_client
);
824 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
825 FixedAdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
826 trace("calc window: (%d,%d)-(%d,%d)\n",
827 rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
);
829 CopyRect(&rc
, &rc_window
);
830 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
831 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
832 trace("calc client: (%d,%d)-(%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
833 ok(EqualRect(&rc
, &rc_client
), "synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d\n", style
, exstyle
, menu
);
836 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
838 static const char *CBT_code_name
[10] = {
849 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
851 trace("CBT: %d (%s), %08lx, %08lx\n", nCode
, code_name
, wParam
, lParam
);
853 /* on HCBT_DESTROYWND window state is undefined */
854 if (nCode
!= HCBT_DESTROYWND
&& IsWindow((HWND
)wParam
))
860 /* Win98 actually does check the info.cbSize and doesn't allow
861 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
862 * WinXP do not check it at all.
864 info
.cbSize
= sizeof(WINDOWINFO
);
865 ok(pGetWindowInfo((HWND
)wParam
, &info
), "GetWindowInfo should not fail\n");
866 verify_window_info((HWND
)wParam
, &info
);
874 static const RECT rc_null
;
877 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
878 trace("HCBT_CREATEWND: hwnd %p, parent %p, style %08x\n",
879 (HWND
)wParam
, createwnd
->lpcs
->hwndParent
, createwnd
->lpcs
->style
);
880 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
882 /* WS_VISIBLE should be turned off yet */
883 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
884 ok(style
== GetWindowLongA((HWND
)wParam
, GWL_STYLE
),
885 "style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
886 GetWindowLongA((HWND
)wParam
, GWL_STYLE
), style
);
890 /* Uncomment this once the test succeeds in all cases */
891 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
893 ok(GetParent((HWND
)wParam
) == hwndMessage
,
894 "wrong result from GetParent %p: message window %p\n",
895 GetParent((HWND
)wParam
), hwndMessage
);
898 ok(!GetParent((HWND
)wParam
), "GetParent should return 0 at this point\n");
900 ok(!GetWindow((HWND
)wParam
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
904 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
905 * Win9x still has them set to 0.
907 ok(GetWindow((HWND
)wParam
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
908 ok(GetWindow((HWND
)wParam
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
910 ok(!GetWindow((HWND
)wParam
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
911 ok(!GetWindow((HWND
)wParam
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
915 /* Uncomment this once the test succeeds in all cases */
918 ok(pGetAncestor((HWND
)wParam
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
919 ok(pGetAncestor((HWND
)wParam
, GA_ROOT
) == (HWND
)wParam
,
920 "GA_ROOT is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOT
), (HWND
)wParam
);
922 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
923 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == hwndMessage
,
924 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
926 ok(pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
) == (HWND
)wParam
,
927 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor((HWND
)wParam
, GA_ROOTOWNER
), (HWND
)wParam
);
930 ok(GetWindowRect((HWND
)wParam
, &rc
), "GetWindowRect failed\n");
931 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
932 ok(GetClientRect((HWND
)wParam
, &rc
), "GetClientRect failed\n");
933 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
939 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
942 static void test_shell_window(void)
946 HMODULE hinst
, hUser32
;
947 BOOL (WINAPI
*SetShellWindow
)(HWND
);
948 BOOL (WINAPI
*SetShellWindowEx
)(HWND
, HWND
);
949 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
950 HWND shellWindow
, nextWnd
;
952 if (!GetWindowLongW(GetDesktopWindow(), GWL_STYLE
))
954 trace("Skipping shell window test on Win9x\n");
958 shellWindow
= GetShellWindow();
959 hinst
= GetModuleHandle(0);
960 hUser32
= GetModuleHandleA("user32");
962 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
963 SetShellWindowEx
= (void *)GetProcAddress(hUser32
, "SetShellWindowEx");
965 trace("previous shell window: %p\n", shellWindow
);
971 SetLastError(0xdeadbeef);
972 ret
= DestroyWindow(shellWindow
);
973 error
= GetLastError();
975 ok(!ret
, "DestroyWindow(shellWindow)\n");
976 /* passes on Win XP, but not on Win98 */
977 ok(error
==ERROR_ACCESS_DENIED
|| error
== 0xdeadbeef,
978 "got %u after DestroyWindow(shellWindow)\n", error
);
980 /* close old shell instance */
981 GetWindowThreadProcessId(shellWindow
, &pid
);
982 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
983 ret
= TerminateProcess(hProcess
, 0);
984 ok(ret
, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
985 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
986 CloseHandle(hProcess
);
989 hwnd1
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
990 trace("created window 1: %p\n", hwnd1
);
992 ret
= SetShellWindow(hwnd1
);
993 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
994 shellWindow
= GetShellWindow();
995 ok(shellWindow
==hwnd1
, "wrong shell window: %p\n", shellWindow
);
997 ret
= SetShellWindow(hwnd1
);
998 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
1000 ret
= SetShellWindow(0);
1001 error
= GetLastError();
1002 /* passes on Win XP, but not on Win98
1003 ok(!ret, "reset shell window by SetShellWindow(0)\n");
1004 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
1006 ret
= SetShellWindow(hwnd1
);
1007 /* passes on Win XP, but not on Win98
1008 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
1010 SetWindowLong(hwnd1
, GWL_EXSTYLE
, GetWindowLong(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
1011 ret
= GetWindowLong(hwnd1
,GWL_EXSTYLE
)&WS_EX_TOPMOST
? TRUE
: FALSE
;
1012 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
1014 ret
= DestroyWindow(hwnd1
);
1015 ok(ret
, "DestroyWindow(hwnd1)\n");
1017 hwnd2
= CreateWindowEx(WS_EX_TOPMOST
, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
1018 trace("created window 2: %p\n", hwnd2
);
1019 ret
= SetShellWindow(hwnd2
);
1020 ok(!ret
, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
1022 hwnd3
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
1023 trace("created window 3: %p\n", hwnd3
);
1025 hwnd4
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
1026 trace("created window 4: %p\n", hwnd4
);
1028 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1029 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd
);
1031 ret
= SetShellWindow(hwnd4
);
1032 ok(ret
, "SetShellWindow(hwnd4)\n");
1033 shellWindow
= GetShellWindow();
1034 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1036 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1037 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
1039 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1040 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1042 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1043 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
1045 ret
= SetShellWindow(hwnd3
);
1046 ok(!ret
, "SetShellWindow(hwnd3)\n");
1047 shellWindow
= GetShellWindow();
1048 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1050 hwnd5
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
1051 trace("created window 5: %p\n", hwnd5
);
1052 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1053 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
1057 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1058 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
1061 /* destroy test windows */
1062 DestroyWindow(hwnd2
);
1063 DestroyWindow(hwnd3
);
1064 DestroyWindow(hwnd4
);
1065 DestroyWindow(hwnd5
);
1068 /************** MDI test ****************/
1070 static char mdi_lParam_test_message
[] = "just a test string";
1072 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT first_id
)
1074 MDICREATESTRUCTA mdi_cs
;
1076 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1077 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
1078 BOOL isWin9x
= FALSE
;
1080 mdi_cs
.szClass
= "MDI_child_Class_1";
1081 mdi_cs
.szTitle
= "MDI child";
1082 mdi_cs
.hOwner
= GetModuleHandle(0);
1083 mdi_cs
.x
= CW_USEDEFAULT
;
1084 mdi_cs
.y
= CW_USEDEFAULT
;
1085 mdi_cs
.cx
= CW_USEDEFAULT
;
1086 mdi_cs
.cy
= CW_USEDEFAULT
;
1088 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1089 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1090 ok(mdi_child
!= 0, "MDI child creation failed\n");
1091 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1092 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1093 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1095 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
1096 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1097 ok(mdi_child
!= 0, "MDI child creation failed\n");
1098 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1099 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1100 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1102 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
1103 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1104 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1106 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1110 ok(mdi_child
!= 0, "MDI child creation failed\n");
1111 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1112 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1113 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1116 /* test MDICREATESTRUCT A<->W mapping */
1117 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1119 mdi_cs
.szClass
= (LPCSTR
)classW
;
1120 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
1121 SetLastError(0xdeadbeef);
1122 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1125 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1128 ok(mdi_child
!= 0, "MDI child creation failed\n");
1132 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1133 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1134 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1137 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1139 CW_USEDEFAULT
, CW_USEDEFAULT
,
1140 CW_USEDEFAULT
, CW_USEDEFAULT
,
1141 mdi_client
, GetModuleHandle(0),
1142 (LPARAM
)mdi_lParam_test_message
);
1143 ok(mdi_child
!= 0, "MDI child creation failed\n");
1144 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1145 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1146 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1148 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1149 0x7fffffff, /* without WS_POPUP */
1150 CW_USEDEFAULT
, CW_USEDEFAULT
,
1151 CW_USEDEFAULT
, CW_USEDEFAULT
,
1152 mdi_client
, GetModuleHandle(0),
1153 (LPARAM
)mdi_lParam_test_message
);
1154 ok(mdi_child
!= 0, "MDI child creation failed\n");
1155 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1156 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1157 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1159 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1160 0xffffffff, /* with WS_POPUP */
1161 CW_USEDEFAULT
, CW_USEDEFAULT
,
1162 CW_USEDEFAULT
, CW_USEDEFAULT
,
1163 mdi_client
, GetModuleHandle(0),
1164 (LPARAM
)mdi_lParam_test_message
);
1165 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1167 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1171 ok(mdi_child
!= 0, "MDI child creation failed\n");
1172 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1173 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1174 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1177 /* test MDICREATESTRUCT A<->W mapping */
1178 SetLastError(0xdeadbeef);
1179 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1181 CW_USEDEFAULT
, CW_USEDEFAULT
,
1182 CW_USEDEFAULT
, CW_USEDEFAULT
,
1183 mdi_client
, GetModuleHandle(0),
1184 (LPARAM
)mdi_lParam_test_message
);
1187 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1190 ok(mdi_child
!= 0, "MDI child creation failed\n");
1194 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1195 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1196 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1199 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1201 CW_USEDEFAULT
, CW_USEDEFAULT
,
1202 CW_USEDEFAULT
, CW_USEDEFAULT
,
1203 mdi_client
, 0, GetModuleHandle(0),
1204 (LPVOID
)mdi_lParam_test_message
);
1205 ok(mdi_child
!= 0, "MDI child creation failed\n");
1206 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1207 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1208 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1210 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1211 0x7fffffff, /* without WS_POPUP */
1212 CW_USEDEFAULT
, CW_USEDEFAULT
,
1213 CW_USEDEFAULT
, CW_USEDEFAULT
,
1214 mdi_client
, 0, GetModuleHandle(0),
1215 (LPVOID
)mdi_lParam_test_message
);
1216 ok(mdi_child
!= 0, "MDI child creation failed\n");
1217 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1218 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1219 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1221 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1222 0xffffffff, /* with WS_POPUP */
1223 CW_USEDEFAULT
, CW_USEDEFAULT
,
1224 CW_USEDEFAULT
, CW_USEDEFAULT
,
1225 mdi_client
, 0, GetModuleHandle(0),
1226 (LPVOID
)mdi_lParam_test_message
);
1227 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1229 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1233 ok(mdi_child
!= 0, "MDI child creation failed\n");
1234 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1235 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1236 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1239 /* test MDICREATESTRUCT A<->W mapping */
1240 SetLastError(0xdeadbeef);
1241 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1243 CW_USEDEFAULT
, CW_USEDEFAULT
,
1244 CW_USEDEFAULT
, CW_USEDEFAULT
,
1245 mdi_client
, 0, GetModuleHandle(0),
1246 (LPVOID
)mdi_lParam_test_message
);
1249 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1252 ok(mdi_child
!= 0, "MDI child creation failed\n");
1256 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == first_id
, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1257 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1258 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1261 /* This test fails on Win9x */
1264 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1266 CW_USEDEFAULT
, CW_USEDEFAULT
,
1267 CW_USEDEFAULT
, CW_USEDEFAULT
,
1268 parent
, 0, GetModuleHandle(0),
1269 (LPVOID
)mdi_lParam_test_message
);
1270 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1273 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1274 WS_CHILD
, /* without WS_POPUP */
1275 CW_USEDEFAULT
, CW_USEDEFAULT
,
1276 CW_USEDEFAULT
, CW_USEDEFAULT
,
1277 mdi_client
, 0, GetModuleHandle(0),
1278 (LPVOID
)mdi_lParam_test_message
);
1279 ok(mdi_child
!= 0, "MDI child creation failed\n");
1280 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1281 DestroyWindow(mdi_child
);
1283 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1284 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1285 CW_USEDEFAULT
, CW_USEDEFAULT
,
1286 CW_USEDEFAULT
, CW_USEDEFAULT
,
1287 mdi_client
, 0, GetModuleHandle(0),
1288 (LPVOID
)mdi_lParam_test_message
);
1289 ok(mdi_child
!= 0, "MDI child creation failed\n");
1290 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1291 DestroyWindow(mdi_child
);
1293 /* maximized child */
1294 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1295 WS_CHILD
| WS_MAXIMIZE
,
1296 CW_USEDEFAULT
, CW_USEDEFAULT
,
1297 CW_USEDEFAULT
, CW_USEDEFAULT
,
1298 mdi_client
, 0, GetModuleHandle(0),
1299 (LPVOID
)mdi_lParam_test_message
);
1300 ok(mdi_child
!= 0, "MDI child creation failed\n");
1301 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1302 DestroyWindow(mdi_child
);
1304 trace("Creating maximized child with a caption\n");
1305 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1306 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1307 CW_USEDEFAULT
, CW_USEDEFAULT
,
1308 CW_USEDEFAULT
, CW_USEDEFAULT
,
1309 mdi_client
, 0, GetModuleHandle(0),
1310 (LPVOID
)mdi_lParam_test_message
);
1311 ok(mdi_child
!= 0, "MDI child creation failed\n");
1312 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1313 DestroyWindow(mdi_child
);
1315 trace("Creating maximized child with a caption and a thick frame\n");
1316 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1317 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1318 CW_USEDEFAULT
, CW_USEDEFAULT
,
1319 CW_USEDEFAULT
, CW_USEDEFAULT
,
1320 mdi_client
, 0, GetModuleHandle(0),
1321 (LPVOID
)mdi_lParam_test_message
);
1322 ok(mdi_child
!= 0, "MDI child creation failed\n");
1323 ok(GetWindowLongPtrA(mdi_child
, GWLP_ID
) == 0, "wrong child id %d\n", GetWindowLongPtrA(mdi_child
, GWLP_ID
));
1324 DestroyWindow(mdi_child
);
1327 /**********************************************************************
1328 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1330 * Note: The rule here is that client rect of the maximized MDI child
1331 * is equal to the client rect of the MDI client window.
1333 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1337 GetClientRect( client
, &rect
);
1338 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1339 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1341 rect
.right
-= rect
.left
;
1342 rect
.bottom
-= rect
.top
;
1343 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1344 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1346 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1347 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1349 trace("max rect (%d,%d - %d, %d)\n",
1350 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1353 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1360 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1361 MDICREATESTRUCTA
*mdi_cs
= (MDICREATESTRUCTA
*)cs
->lpCreateParams
;
1363 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1364 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1366 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1367 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1368 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1369 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1370 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1372 /* MDICREATESTRUCT should have original values */
1373 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff,
1374 "mdi_cs->style does not match (%08x)\n", mdi_cs
->style
);
1375 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1376 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1377 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1378 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1380 /* CREATESTRUCT should have fixed values */
1381 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1382 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1384 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1385 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1386 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1388 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1390 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1392 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1393 ok(cs
->style
== style
,
1394 "cs->style does not match (%08x)\n", cs
->style
);
1398 LONG style
= mdi_cs
->style
;
1400 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1401 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1402 ok(cs
->style
== style
,
1403 "cs->style does not match (%08x)\n", cs
->style
);
1408 case WM_GETMINMAXINFO
:
1410 HWND client
= GetParent(hwnd
);
1412 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1413 MINMAXINFO my_minmax
;
1414 LONG style
, exstyle
;
1416 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1417 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1419 GetWindowRect(client
, &rc
);
1420 trace("MDI client %p window size = (%d x %d)\n", client
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1421 GetClientRect(client
, &rc
);
1422 trace("MDI client %p client size = (%d x %d)\n", client
, rc
.right
, rc
.bottom
);
1423 trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN
),
1424 GetSystemMetrics(SM_CYSCREEN
));
1426 GetClientRect(client
, &rc
);
1427 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1428 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1429 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1430 trace("MDI child: calculated max window size = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1431 dump_minmax_info( minmax
);
1433 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1434 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1435 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1436 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1438 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1440 trace("DefMDIChildProc returned:\n");
1441 dump_minmax_info( minmax
);
1443 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1444 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %d != %d\n",
1445 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1446 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %d != %d\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 = (%d x %d)\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 = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1519 dump_minmax_info( minmax
);
1521 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1522 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1523 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1524 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1528 case WM_WINDOWPOSCHANGED
:
1530 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1533 GetWindowRect(hwnd
, &rc1
);
1534 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1535 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1536 /* note: winpos coordinates are relative to parent */
1537 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1538 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1539 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1541 GetWindowRect(hwnd
, &rc1
);
1542 GetClientRect(hwnd
, &rc2
);
1543 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1544 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1545 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1548 case WM_WINDOWPOSCHANGING
:
1550 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1551 WINDOWPOS my_winpos
= *winpos
;
1553 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1554 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1555 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1556 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1558 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1560 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1561 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1562 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1564 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1565 "DefWindowProc should not change WINDOWPOS values\n");
1570 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1573 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1575 static HWND mdi_client
;
1581 CLIENTCREATESTRUCT client_cs
;
1584 GetClientRect(hwnd
, &rc
);
1586 client_cs
.hWindowMenu
= 0;
1587 client_cs
.idFirstChild
= 1;
1589 /* MDIClient without MDIS_ALLCHILDSTYLES */
1590 mdi_client
= CreateWindowExA(0, "mdiclient",
1592 WS_CHILD
/*| WS_VISIBLE*/,
1593 /* tests depend on a not zero MDIClient size */
1594 0, 0, rc
.right
, rc
.bottom
,
1595 hwnd
, 0, GetModuleHandle(0),
1596 (LPVOID
)&client_cs
);
1598 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1599 DestroyWindow(mdi_client
);
1601 /* MDIClient with MDIS_ALLCHILDSTYLES */
1602 mdi_client
= CreateWindowExA(0, "mdiclient",
1604 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
1605 /* tests depend on a not zero MDIClient size */
1606 0, 0, rc
.right
, rc
.bottom
,
1607 hwnd
, 0, GetModuleHandle(0),
1608 (LPVOID
)&client_cs
);
1610 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1611 DestroyWindow(mdi_client
);
1615 case WM_WINDOWPOSCHANGED
:
1617 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1620 GetWindowRect(hwnd
, &rc1
);
1621 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1622 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1623 /* note: winpos coordinates are relative to parent */
1624 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1625 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1626 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1628 GetWindowRect(hwnd
, &rc1
);
1629 GetClientRect(hwnd
, &rc2
);
1630 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1631 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1632 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1635 case WM_WINDOWPOSCHANGING
:
1637 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1638 WINDOWPOS my_winpos
= *winpos
;
1640 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1641 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1642 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1643 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1645 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1647 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1648 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1649 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1651 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1652 "DefWindowProc should not change WINDOWPOS values\n");
1661 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
1664 static BOOL
mdi_RegisterWindowClasses(void)
1669 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
1672 cls
.hInstance
= GetModuleHandleA(0);
1674 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1675 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1676 cls
.lpszMenuName
= NULL
;
1677 cls
.lpszClassName
= "MDI_parent_Class";
1678 if(!RegisterClassA(&cls
)) return FALSE
;
1680 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
1681 cls
.lpszClassName
= "MDI_child_Class_1";
1682 if(!RegisterClassA(&cls
)) return FALSE
;
1684 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
1685 cls
.lpszClassName
= "MDI_child_Class_2";
1686 if(!RegisterClassA(&cls
)) return FALSE
;
1691 static void test_mdi(void)
1696 if (!mdi_RegisterWindowClasses()) assert(0);
1698 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
1699 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
1700 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
1701 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1702 GetDesktopWindow(), 0,
1703 GetModuleHandle(0), NULL
);
1704 assert(mdi_hwndMain
);
1706 while(GetMessage(&msg, 0, 0, 0))
1708 TranslateMessage(&msg);
1709 DispatchMessage(&msg);
1712 DestroyWindow(mdi_hwndMain
);
1715 static void test_icons(void)
1719 HICON icon
= LoadIconA(0, (LPSTR
)IDI_APPLICATION
);
1720 HICON icon2
= LoadIconA(0, (LPSTR
)IDI_QUESTION
);
1721 HICON small_icon
= LoadImageA(0, (LPSTR
)IDI_APPLICATION
, IMAGE_ICON
,
1722 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
1725 cls
.cbSize
= sizeof(cls
);
1727 cls
.lpfnWndProc
= DefWindowProcA
;
1731 cls
.hIcon
= LoadIconA(0, (LPSTR
)IDI_HAND
);
1732 cls
.hIconSm
= small_icon
;
1733 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
1734 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1735 cls
.lpszMenuName
= NULL
;
1736 cls
.lpszClassName
= "IconWindowClass";
1738 RegisterClassExA(&cls
);
1740 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
1741 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
1744 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1745 ok( res
== 0, "wrong big icon %p/0\n", res
);
1746 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
1747 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
1748 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1749 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
1750 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
1751 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
1752 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1753 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1755 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1756 ok( res
== 0, "wrong small icon %p/0\n", res
);
1757 /* this test is XP specific */
1758 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1759 ok( res != 0, "wrong small icon %p\n", res );*/
1760 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
1761 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
1762 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1763 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
1764 /* this test is XP specific */
1765 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1766 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
1767 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
1768 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
1769 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1770 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
1771 /* this test is XP specific */
1772 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1773 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
1775 /* make sure the big icon hasn't changed */
1776 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1777 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1779 DestroyWindow( hwnd
);
1782 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1784 if (msg
== WM_NCCALCSIZE
)
1786 RECT
*rect
= (RECT
*)lparam
;
1787 /* first time around increase the rectangle, next time decrease it */
1788 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
1789 else InflateRect( rect
, -10, -10 );
1792 return DefWindowProc( hwnd
, msg
, wparam
, lparam
);
1795 static void test_SetWindowPos(HWND hwnd
)
1797 RECT orig_win_rc
, rect
;
1799 BOOL is_win9x
= GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == 0;
1801 SetRect(&rect
, 111, 222, 333, 444);
1802 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
1803 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1804 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1806 SetRect(&rect
, 111, 222, 333, 444);
1807 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
1808 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1809 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1811 GetWindowRect(hwnd
, &orig_win_rc
);
1813 old_proc
= SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
1814 SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1815 GetWindowRect( hwnd
, &rect
);
1816 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
1817 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1818 GetClientRect( hwnd
, &rect
);
1819 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1820 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
1821 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1823 SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1824 GetWindowRect( hwnd
, &rect
);
1825 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
1826 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1827 GetClientRect( hwnd
, &rect
);
1828 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
1829 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
1830 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1832 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1833 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1834 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, old_proc
);
1836 /* Win9x truncates coordinates to 16-bit irrespectively */
1839 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
1840 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
1842 SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
1843 SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
1846 SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
1847 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
1849 ok(!(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
1850 SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1851 ok(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
1852 SetWindowPos(hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1853 ok(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
1854 SetWindowPos(hwnd
, HWND_NOTOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1855 ok(!(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
1858 static void test_SetMenu(HWND parent
)
1862 BOOL is_win9x
= GetWindowLongPtrW(parent
, GWLP_WNDPROC
) == 0;
1866 hMenu
= CreateMenu();
1869 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1872 /* fails on (at least) Wine, NT4, XP SP2 */
1873 test_nonclient_area(parent
);
1875 ret
= GetMenu(parent
);
1876 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1877 /* test whether we can destroy a menu assigned to a window */
1878 retok
= DestroyMenu(hMenu
);
1879 ok( retok
, "DestroyMenu error %d\n", GetLastError());
1880 retok
= IsMenu(hMenu
);
1881 ok(!retok
|| broken(retok
) /* nt4 */, "menu handle should be not valid after DestroyMenu\n");
1882 ret
= GetMenu(parent
);
1883 /* This test fails on Win9x */
1885 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1886 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1887 test_nonclient_area(parent
);
1889 hMenu
= CreateMenu();
1893 ret
= GetMenu(parent
);
1894 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1896 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1897 test_nonclient_area(parent
);
1898 ret
= GetMenu(parent
);
1899 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1901 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
1904 /* fails on (at least) Wine, NT4, XP SP2 */
1905 test_nonclient_area(parent
);
1907 ret
= GetMenu(parent
);
1908 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
1910 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
1911 test_nonclient_area(parent
);
1912 ret
= GetMenu(parent
);
1913 ok(ret
== 0, "unexpected menu id %p\n", ret
);
1916 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
1919 ret
= GetMenu(child
);
1920 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1922 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
1923 test_nonclient_area(child
);
1924 ret
= GetMenu(child
);
1925 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1927 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
1928 test_nonclient_area(child
);
1929 ret
= GetMenu(child
);
1930 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1932 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
1933 test_nonclient_area(child
);
1934 ret
= GetMenu(child
);
1935 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
1937 style
= GetWindowLong(child
, GWL_STYLE
);
1938 SetWindowLong(child
, GWL_STYLE
, style
| WS_POPUP
);
1939 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
1940 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
1941 SetWindowLong(child
, GWL_STYLE
, style
);
1943 SetWindowLong(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
1944 ok(!SetMenu(child
, hMenu
), "SetMenu on a overlapped child window should fail\n");
1945 SetWindowLong(child
, GWL_STYLE
, style
);
1947 DestroyWindow(child
);
1951 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
1953 HWND child
[5], hwnd
;
1958 hwnd
= GetWindow(parent
, GW_CHILD
);
1959 ok(!hwnd
, "have to start without children to perform the test\n");
1961 for (i
= 0; i
< total
; i
++)
1963 if (style
[i
] & DS_CONTROL
)
1965 child
[i
] = CreateWindowExA(0, MAKEINTATOM(32770), "", style
[i
] & ~WS_VISIBLE
,
1966 0,0,0,0, parent
, (HMENU
)i
, 0, NULL
);
1967 if (style
[i
] & WS_VISIBLE
)
1968 ShowWindow(child
[i
], SW_SHOW
);
1970 SetWindowPos(child
[i
], HWND_BOTTOM
, 0,0,10,10, SWP_NOACTIVATE
);
1973 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
1974 parent
, (HMENU
)i
, 0, NULL
);
1975 trace("child[%d] = %p\n", i
, child
[i
]);
1976 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
1979 hwnd
= GetWindow(parent
, GW_CHILD
);
1980 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
1981 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
1982 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
1984 for (i
= 0; i
< total
; i
++)
1986 trace("hwnd[%d] = %p\n", i
, hwnd
);
1987 ok(child
[order
[i
]] == hwnd
, "Z order of child #%d is wrong\n", i
);
1989 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
1992 for (i
= 0; i
< total
; i
++)
1993 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
1996 static void test_children_zorder(HWND parent
)
1998 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
2000 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
2002 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
2003 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
2004 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
2005 const int complex_order_1
[1] = { 0 };
2006 const int complex_order_2
[2] = { 1, 0 };
2007 const int complex_order_3
[3] = { 1, 0, 2 };
2008 const int complex_order_4
[4] = { 1, 0, 2, 3 };
2009 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
2010 const DWORD complex_style_6
[3] = { WS_CHILD
| WS_VISIBLE
,
2011 WS_CHILD
| WS_CLIPSIBLINGS
| DS_CONTROL
| WS_VISIBLE
,
2012 WS_CHILD
| WS_VISIBLE
};
2013 const int complex_order_6
[3] = { 0, 1, 2 };
2015 /* simple WS_CHILD */
2016 test_window_tree(parent
, simple_style
, simple_order
, 5);
2018 /* complex children styles */
2019 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
2020 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
2021 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
2022 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
2023 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
2025 /* another set of complex children styles */
2026 test_window_tree(parent
, complex_style_6
, complex_order_6
, 3);
2029 #define check_z_order(hwnd, next, prev, owner, topmost) \
2030 check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
2033 static void check_z_order_debug(HWND hwnd
, HWND next
, HWND prev
, HWND owner
,
2034 BOOL topmost
, const char *file
, int line
)
2039 test
= GetWindow(hwnd
, GW_HWNDNEXT
);
2040 /* skip foreign windows */
2041 while (test
&& (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2042 UlongToHandle(GetWindowLongPtr(test
, GWLP_HINSTANCE
)) != GetModuleHandle(0)))
2044 /*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2045 test
= GetWindow(test
, GW_HWNDNEXT
);
2047 ok_(file
, line
)(next
== test
, "expected next %p, got %p\n", next
, test
);
2049 test
= GetWindow(hwnd
, GW_HWNDPREV
);
2050 /* skip foreign windows */
2051 while (test
&& (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2052 UlongToHandle(GetWindowLongPtr(test
, GWLP_HINSTANCE
)) != GetModuleHandle(0)))
2054 /*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2055 test
= GetWindow(test
, GW_HWNDPREV
);
2057 ok_(file
, line
)(prev
== test
, "expected prev %p, got %p\n", prev
, test
);
2059 test
= GetWindow(hwnd
, GW_OWNER
);
2060 ok_(file
, line
)(owner
== test
, "expected owner %p, got %p\n", owner
, test
);
2062 ex_style
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
2063 ok_(file
, line
)(!(ex_style
& WS_EX_TOPMOST
) == !topmost
, "expected %stopmost\n", topmost
? "" : "NOT ");
2066 static void test_popup_zorder(HWND hwnd_D
, HWND hwnd_E
)
2068 HWND hwnd_A
, hwnd_B
, hwnd_C
, hwnd_F
;
2070 trace("hwnd_D %p, hwnd_E %p\n", hwnd_D
, hwnd_E
);
2072 SetWindowPos(hwnd_E
, hwnd_D
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2074 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2075 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2077 hwnd_F
= CreateWindowEx(0, "MainWindowClass", "Owner window",
2078 WS_OVERLAPPED
| WS_CAPTION
,
2080 0, 0, GetModuleHandle(0), NULL
);
2081 trace("hwnd_F %p\n", hwnd_F
);
2082 check_z_order(hwnd_F
, hwnd_D
, 0, 0, FALSE
);
2084 SetWindowPos(hwnd_F
, hwnd_E
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2085 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2086 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2087 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2089 hwnd_C
= CreateWindowEx(0, "MainWindowClass", NULL
,
2092 hwnd_F
, 0, GetModuleHandle(0), NULL
);
2093 trace("hwnd_C %p\n", hwnd_C
);
2094 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2095 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2096 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2097 check_z_order(hwnd_C
, hwnd_D
, 0, hwnd_F
, FALSE
);
2099 hwnd_B
= CreateWindowEx(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2102 hwnd_F
, 0, GetModuleHandle(0), NULL
);
2103 trace("hwnd_B %p\n", hwnd_B
);
2104 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2105 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2106 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2107 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2108 check_z_order(hwnd_B
, hwnd_C
, 0, hwnd_F
, TRUE
);
2110 hwnd_A
= CreateWindowEx(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2113 0, 0, GetModuleHandle(0), NULL
);
2114 trace("hwnd_A %p\n", hwnd_A
);
2115 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2116 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2117 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2118 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2119 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2120 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2122 trace("A %p B %p C %p D %p E %p F %p\n", hwnd_A
, hwnd_B
, hwnd_C
, hwnd_D
, hwnd_E
, hwnd_F
);
2124 /* move hwnd_F and its popups up */
2125 SetWindowPos(hwnd_F
, HWND_TOP
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2126 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2127 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2128 check_z_order(hwnd_F
, hwnd_D
, hwnd_C
, 0, FALSE
);
2129 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2130 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2131 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2133 /* move hwnd_F and its popups down */
2134 #if 0 /* enable once Wine is fixed to pass this test */
2135 SetWindowPos(hwnd_F
, HWND_BOTTOM
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2136 check_z_order(hwnd_F
, 0, hwnd_C
, 0, FALSE
);
2137 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2138 check_z_order(hwnd_B
, hwnd_C
, hwnd_E
, hwnd_F
, FALSE
);
2139 check_z_order(hwnd_E
, hwnd_B
, hwnd_D
, 0, FALSE
);
2140 check_z_order(hwnd_D
, hwnd_E
, hwnd_A
, 0, FALSE
);
2141 check_z_order(hwnd_A
, hwnd_D
, 0, 0, TRUE
);
2144 DestroyWindow(hwnd_A
);
2145 DestroyWindow(hwnd_B
);
2146 DestroyWindow(hwnd_C
);
2147 DestroyWindow(hwnd_F
);
2150 static void test_vis_rgn( HWND hwnd
)
2152 RECT win_rect
, rgn_rect
;
2153 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
2156 ShowWindow(hwnd
,SW_SHOW
);
2157 hdc
= GetDC( hwnd
);
2158 ok( GetRandomRgn( hdc
, hrgn
, SYSRGN
) != 0, "GetRandomRgn failed\n" );
2159 GetWindowRect( hwnd
, &win_rect
);
2160 GetRgnBox( hrgn
, &rgn_rect
);
2161 if (GetVersion() & 0x80000000)
2163 trace("win9x, mapping to screen coords\n");
2164 MapWindowPoints( hwnd
, 0, (POINT
*)&rgn_rect
, 2 );
2166 trace("win: %d,%d-%d,%d\n", win_rect
.left
, win_rect
.top
, win_rect
.right
, win_rect
.bottom
);
2167 trace("rgn: %d,%d-%d,%d\n", rgn_rect
.left
, rgn_rect
.top
, rgn_rect
.right
, rgn_rect
.bottom
);
2168 ok( win_rect
.left
<= rgn_rect
.left
, "rgn left %d not inside win rect %d\n",
2169 rgn_rect
.left
, win_rect
.left
);
2170 ok( win_rect
.top
<= rgn_rect
.top
, "rgn top %d not inside win rect %d\n",
2171 rgn_rect
.top
, win_rect
.top
);
2172 ok( win_rect
.right
>= rgn_rect
.right
, "rgn right %d not inside win rect %d\n",
2173 rgn_rect
.right
, win_rect
.right
);
2174 ok( win_rect
.bottom
>= rgn_rect
.bottom
, "rgn bottom %d not inside win rect %d\n",
2175 rgn_rect
.bottom
, win_rect
.bottom
);
2176 ReleaseDC( hwnd
, hdc
);
2179 static LRESULT WINAPI
set_focus_on_activate_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
2181 if (msg
== WM_ACTIVATE
&& LOWORD(wp
) == WA_ACTIVE
)
2183 HWND child
= GetWindow(hwnd
, GW_CHILD
);
2184 ok(child
!= 0, "couldn't find child window\n");
2186 ok(GetFocus() == child
, "Focus should be on child %p\n", child
);
2189 return DefWindowProc(hwnd
, msg
, wp
, lp
);
2192 static void test_SetFocus(HWND hwnd
)
2195 WNDPROC old_wnd_proc
;
2197 /* check if we can set focus to non-visible windows */
2199 ShowWindow(hwnd
, SW_SHOW
);
2202 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2203 ok( GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
2204 ShowWindow(hwnd
, SW_HIDE
);
2207 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
2208 ok( !(GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
2209 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2212 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
2213 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2214 ShowWindow(child
, SW_SHOW
);
2215 ok( GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
2216 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
2217 ShowWindow(child
, SW_HIDE
);
2218 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2219 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2220 ShowWindow(child
, SW_SHOW
);
2222 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2223 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
2224 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2226 ShowWindow(child
, SW_HIDE
);
2228 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2229 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
2230 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2231 ShowWindow(child
, SW_HIDE
);
2232 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2234 ShowWindow(hwnd
, SW_SHOW
);
2235 ShowWindow(child
, SW_SHOW
);
2237 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2238 EnableWindow(hwnd
, FALSE
);
2239 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2240 EnableWindow(hwnd
, TRUE
);
2242 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2243 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2244 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2246 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2247 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2248 ShowWindow(hwnd
, SW_RESTORE
);
2249 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2250 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2251 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2252 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2253 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2255 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2256 old_wnd_proc
= (WNDPROC
)SetWindowLongPtr(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)set_focus_on_activate_proc
);
2257 ShowWindow(hwnd
, SW_RESTORE
);
2258 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2260 ok( GetFocus() == child
, "Focus should be on child %p, not %p\n", child
, GetFocus() );
2262 SetWindowLongPtr(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)old_wnd_proc
);
2264 DestroyWindow( child
);
2267 #define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
2268 static void check_wnd_state_(const char *file
, int line
,
2269 HWND active
, HWND foreground
, HWND focus
, HWND capture
)
2271 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
2273 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
2274 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
2275 ok_(file
, line
)(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
2278 static void test_SetActiveWindow(HWND hwnd
)
2282 flush_events( TRUE
);
2283 ShowWindow(hwnd
, SW_HIDE
);
2286 check_wnd_state(0, 0, 0, 0);
2288 /*trace("testing SetActiveWindow %p\n", hwnd);*/
2290 ShowWindow(hwnd
, SW_SHOW
);
2291 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2293 hwnd2
= SetActiveWindow(0);
2294 ok(hwnd2
== hwnd
, "SetActiveWindow returned %p instead of %p\n", hwnd2
, hwnd
);
2295 check_wnd_state(0, 0, 0, 0);
2297 hwnd2
= SetActiveWindow(hwnd
);
2298 ok(hwnd2
== 0, "SetActiveWindow returned %p instead of 0\n", hwnd2
);
2299 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2301 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2302 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2304 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2305 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2307 ShowWindow(hwnd
, SW_HIDE
);
2308 check_wnd_state(0, 0, 0, 0);
2310 /*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/
2311 SetActiveWindow(hwnd
);
2312 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2314 ShowWindow(hwnd
, SW_SHOW
);
2315 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2317 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2318 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2320 DestroyWindow(hwnd2
);
2321 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2323 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2324 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2326 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2327 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2329 DestroyWindow(hwnd2
);
2330 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2333 static void test_SetForegroundWindow(HWND hwnd
)
2338 flush_events( TRUE
);
2339 ShowWindow(hwnd
, SW_HIDE
);
2342 check_wnd_state(0, 0, 0, 0);
2344 /*trace("testing SetForegroundWindow %p\n", hwnd);*/
2346 ShowWindow(hwnd
, SW_SHOW
);
2347 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2349 hwnd2
= SetActiveWindow(0);
2350 ok(hwnd2
== hwnd
, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2
, hwnd
);
2351 check_wnd_state(0, 0, 0, 0);
2353 ret
= SetForegroundWindow(hwnd
);
2354 ok(ret
, "SetForegroundWindow returned FALSE instead of TRUE\n");
2355 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2357 SetLastError(0xdeadbeef);
2358 ret
= SetForegroundWindow(0);
2359 ok(!ret
, "SetForegroundWindow returned TRUE instead of FALSE\n");
2360 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
2361 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2363 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2364 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2366 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2367 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2369 hwnd2
= GetForegroundWindow();
2370 ok(hwnd2
== hwnd
, "Wrong foreground window %p\n", hwnd2
);
2371 ok(SetForegroundWindow( GetDesktopWindow() ), "SetForegroundWindow(desktop) error: %d\n", GetLastError());
2372 hwnd2
= GetForegroundWindow();
2373 ok(hwnd2
!= hwnd
, "Wrong foreground window %p\n", hwnd2
);
2375 ShowWindow(hwnd
, SW_HIDE
);
2376 check_wnd_state(0, 0, 0, 0);
2378 /*trace("testing SetForegroundWindow on an invisible window %p\n", hwnd);*/
2379 ret
= SetForegroundWindow(hwnd
);
2380 ok(ret
, "SetForegroundWindow returned FALSE instead of TRUE\n");
2381 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2383 ShowWindow(hwnd
, SW_SHOW
);
2384 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2386 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2387 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2389 DestroyWindow(hwnd2
);
2390 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2392 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2393 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2395 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2396 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2398 DestroyWindow(hwnd2
);
2399 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2402 static WNDPROC old_button_proc
;
2404 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2409 key_state
= GetKeyState(VK_LBUTTON
);
2410 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
2412 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
2414 if (msg
== WM_LBUTTONDOWN
)
2418 check_wnd_state(button
, button
, button
, button
);
2420 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2422 trace("hwnd %p\n", hwnd
);
2424 check_wnd_state(button
, button
, button
, button
);
2426 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2428 check_wnd_state(button
, button
, button
, button
);
2430 DestroyWindow(hwnd
);
2432 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2434 trace("hwnd %p\n", hwnd
);
2436 check_wnd_state(button
, button
, button
, button
);
2438 /* button wnd proc should release capture on WM_KILLFOCUS if it does
2439 * match internal button state.
2441 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2442 check_wnd_state(button
, button
, button
, 0);
2444 ShowWindow(hwnd
, SW_SHOW
);
2445 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2447 capture
= SetCapture(hwnd
);
2448 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2450 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2452 DestroyWindow(hwnd
);
2454 check_wnd_state(button
, 0, button
, 0);
2460 static void test_capture_1(void)
2462 HWND button
, capture
, oldFocus
, oldActive
;
2464 oldFocus
= GetFocus();
2465 oldActive
= GetActiveWindow();
2467 capture
= GetCapture();
2468 ok(capture
== 0, "GetCapture() = %p\n", capture
);
2470 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2472 trace("button %p\n", button
);
2474 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
2476 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
2478 capture
= SetCapture(button
);
2479 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2480 check_wnd_state(button
, 0, button
, button
);
2482 DestroyWindow(button
);
2483 check_wnd_state(oldActive
, 0, oldFocus
, 0);
2486 static void test_capture_2(void)
2488 HWND button
, hwnd
, capture
, oldFocus
, oldActive
;
2490 oldFocus
= GetFocus();
2491 oldActive
= GetActiveWindow();
2492 check_wnd_state(oldActive
, 0, oldFocus
, 0);
2494 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2496 trace("button %p\n", button
);
2498 check_wnd_state(button
, button
, button
, 0);
2500 capture
= SetCapture(button
);
2501 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2503 check_wnd_state(button
, button
, button
, button
);
2505 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
2506 * internal button state.
2508 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2509 check_wnd_state(button
, button
, button
, button
);
2511 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2513 trace("hwnd %p\n", hwnd
);
2515 check_wnd_state(button
, button
, button
, button
);
2517 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2519 check_wnd_state(button
, button
, button
, button
);
2521 DestroyWindow(hwnd
);
2523 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2525 trace("hwnd %p\n", hwnd
);
2527 check_wnd_state(button
, button
, button
, button
);
2529 ShowWindow(hwnd
, SW_SHOW
);
2531 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
2533 capture
= SetCapture(hwnd
);
2534 ok(capture
== button
, "SetCapture() = %p\n", capture
);
2536 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2538 DestroyWindow(hwnd
);
2539 check_wnd_state(button
, button
, button
, 0);
2541 DestroyWindow(button
);
2542 check_wnd_state(oldActive
, 0, oldFocus
, 0);
2545 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
2549 ShowWindow(hwnd1
, SW_HIDE
);
2550 ShowWindow(hwnd2
, SW_HIDE
);
2552 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
2553 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
2556 check_wnd_state(0, 0, 0, hwnd1
);
2559 check_wnd_state(0, 0, 0, hwnd2
);
2561 ShowWindow(hwnd1
, SW_SHOW
);
2562 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
2564 ret
= ReleaseCapture();
2565 ok (ret
, "releasecapture did not return TRUE.\n");
2566 ret
= ReleaseCapture();
2567 ok (ret
, "releasecapture did not return TRUE after second try.\n");
2570 static void test_keyboard_input(HWND hwnd
)
2575 flush_events( TRUE
);
2576 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_SHOWWINDOW
);
2578 flush_events( TRUE
);
2580 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
2583 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2585 flush_events( TRUE
);
2587 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2588 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2589 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2590 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2591 ok( !ret
, "message %04x available\n", msg
.message
);
2593 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2595 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2596 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2597 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2598 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2599 ok( !ret
, "message %04x available\n", msg
.message
);
2601 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
2603 keybd_event(VK_SPACE
, 0, 0, 0);
2604 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2605 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2606 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2607 ok( !ret
, "message %04x available\n", msg
.message
);
2610 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2612 flush_events( TRUE
);
2614 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
2615 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2616 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2617 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2618 ok( !ret
, "message %04x available\n", msg
.message
);
2620 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2622 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
2623 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2624 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2625 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2626 ok( !ret
, "message %04x available\n", msg
.message
);
2628 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
2630 keybd_event(VK_SPACE
, 0, 0, 0);
2631 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2632 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2633 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2634 ok( !ret
, "message %04x available\n", msg
.message
);
2637 static void test_mouse_input(HWND hwnd
)
2647 ShowWindow(hwnd
, SW_SHOW
);
2650 GetWindowRect(hwnd
, &rc
);
2651 trace("main window %p: (%d,%d)-(%d,%d)\n", hwnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2653 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
2654 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
2657 ShowWindow(popup
, SW_SHOW
);
2658 UpdateWindow(popup
);
2660 GetWindowRect(popup
, &rc
);
2661 trace("popup window %p: (%d,%d)-(%d,%d)\n", popup
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
2663 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
2664 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
2665 trace("setting cursor to (%d,%d)\n", x
, y
);
2669 ok(x
== pt
.x
&& y
== pt
.y
, "wrong cursor pos (%d,%d), expected (%d,%d)\n", pt
.x
, pt
.y
, x
, y
);
2671 flush_events( TRUE
);
2673 /* Check that setting the same position may generate WM_MOUSEMOVE */
2677 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2678 while (ret
&& msg
.message
>= 0xc000); /* skip registered messages */
2681 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n",
2682 msg
.hwnd
, msg
.message
);
2683 ok(msg
.pt
.x
== x
&& msg
.pt
.y
== y
, "wrong message coords (%d,%d)/(%d,%d)\n",
2684 x
, y
, msg
.pt
.x
, msg
.pt
.y
);
2687 /* force the system to update its internal queue mouse position,
2688 * otherwise it won't generate relative mouse movements below.
2690 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2691 flush_events( TRUE
);
2694 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2695 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
2696 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
2698 if (msg
.message
>= 0xc000) continue; /* skip registered messages */
2699 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
,
2700 "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2702 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2703 ok( !ret
, "message %04x available\n", msg
.message
);
2705 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
2706 ShowWindow(popup
, SW_HIDE
);
2708 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2709 while (msg
.message
>= 0xc000); /* skip registered messages */
2710 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
2711 flush_events( TRUE
);
2713 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
2714 ShowWindow(hwnd
, SW_HIDE
);
2716 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2717 while (ret
&& msg
.message
>= 0xc000); /* skip registered messages */
2718 ok( !ret
, "message %04x available\n", msg
.message
);
2719 flush_events( TRUE
);
2721 /* test mouse clicks */
2723 ShowWindow(hwnd
, SW_SHOW
);
2724 flush_events( TRUE
);
2725 ShowWindow(popup
, SW_SHOW
);
2726 flush_events( TRUE
);
2728 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2729 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2730 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2731 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2733 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2734 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
2735 msg
.hwnd
, popup
, msg
.message
);
2736 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2737 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
2738 msg
.hwnd
, popup
, msg
.message
);
2740 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2741 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
2742 msg
.hwnd
, popup
, msg
.message
);
2743 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2744 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
2745 msg
.hwnd
, popup
, msg
.message
);
2747 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2748 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p/%p message %04x\n",
2749 msg
.hwnd
, popup
, msg
.message
);
2750 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2751 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p/%p message %04x\n",
2752 msg
.hwnd
, popup
, msg
.message
);
2754 ok(PeekMessageA(&msg
, 0, 0, 0, 0), "no message available\n");
2755 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
2756 msg
.hwnd
, popup
, msg
.message
);
2757 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2758 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
2759 msg
.hwnd
, popup
, msg
.message
);
2761 ret
= PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
);
2762 ok(!ret
, "message %04x available\n", msg
.message
);
2764 ShowWindow(popup
, SW_HIDE
);
2765 flush_events( TRUE
);
2767 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2768 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2769 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
2770 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
2772 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2773 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
2774 msg
.hwnd
, hwnd
, msg
.message
);
2775 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2776 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
2777 msg
.hwnd
, hwnd
, msg
.message
);
2779 test_lbuttondown_flag
= TRUE
;
2780 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
2781 test_lbuttondown_flag
= FALSE
;
2784 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2785 while (msg
.message
>= 0xc000); /* skip registered messages */
2786 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
2787 msg
.hwnd
, popup
, msg
.message
);
2788 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2789 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
2790 msg
.hwnd
, popup
, msg
.message
);
2791 ok(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
), "no message available\n");
2793 /* Test WM_MOUSEACTIVATE */
2794 #define TEST_MOUSEACTIVATE(A,B) \
2795 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
2796 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
2798 TEST_MOUSEACTIVATE(HTERROR
,MA_ACTIVATE
);
2799 TEST_MOUSEACTIVATE(HTTRANSPARENT
,MA_ACTIVATE
);
2800 TEST_MOUSEACTIVATE(HTNOWHERE
,MA_ACTIVATE
);
2801 TEST_MOUSEACTIVATE(HTCLIENT
,MA_ACTIVATE
);
2802 TEST_MOUSEACTIVATE(HTCAPTION
,MA_ACTIVATE
);
2803 TEST_MOUSEACTIVATE(HTSYSMENU
,MA_ACTIVATE
);
2804 TEST_MOUSEACTIVATE(HTSIZE
,MA_ACTIVATE
);
2805 TEST_MOUSEACTIVATE(HTMENU
,MA_ACTIVATE
);
2806 TEST_MOUSEACTIVATE(HTHSCROLL
,MA_ACTIVATE
);
2807 TEST_MOUSEACTIVATE(HTVSCROLL
,MA_ACTIVATE
);
2808 TEST_MOUSEACTIVATE(HTMINBUTTON
,MA_ACTIVATE
);
2809 TEST_MOUSEACTIVATE(HTMAXBUTTON
,MA_ACTIVATE
);
2810 TEST_MOUSEACTIVATE(HTLEFT
,MA_ACTIVATE
);
2811 TEST_MOUSEACTIVATE(HTRIGHT
,MA_ACTIVATE
);
2812 TEST_MOUSEACTIVATE(HTTOP
,MA_ACTIVATE
);
2813 TEST_MOUSEACTIVATE(HTTOPLEFT
,MA_ACTIVATE
);
2814 TEST_MOUSEACTIVATE(HTTOPRIGHT
,MA_ACTIVATE
);
2815 TEST_MOUSEACTIVATE(HTBOTTOM
,MA_ACTIVATE
);
2816 TEST_MOUSEACTIVATE(HTBOTTOMLEFT
,MA_ACTIVATE
);
2817 TEST_MOUSEACTIVATE(HTBOTTOMRIGHT
,MA_ACTIVATE
);
2818 TEST_MOUSEACTIVATE(HTBORDER
,MA_ACTIVATE
);
2819 TEST_MOUSEACTIVATE(HTOBJECT
,MA_ACTIVATE
);
2820 TEST_MOUSEACTIVATE(HTCLOSE
,MA_ACTIVATE
);
2821 TEST_MOUSEACTIVATE(HTHELP
,MA_ACTIVATE
);
2823 /* Clear any messages left behind by WM_MOUSEACTIVATE tests */
2824 flush_events( TRUE
);
2826 DestroyWindow(popup
);
2829 static void test_validatergn(HWND hwnd
)
2835 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
2836 ShowWindow(hwnd
, SW_SHOW
);
2837 UpdateWindow( hwnd
);
2838 /* test that ValidateRect validates children*/
2839 InvalidateRect( child
, NULL
, 1);
2840 GetWindowRect( child
, &rc
);
2841 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2842 ret
= GetUpdateRect( child
, &rc2
, 0);
2843 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
2844 "Update rectangle is empty!\n");
2845 ValidateRect( hwnd
, &rc
);
2846 ret
= GetUpdateRect( child
, &rc2
, 0);
2847 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2848 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
2849 rc2
.right
, rc2
.bottom
);
2851 /* now test ValidateRgn */
2852 InvalidateRect( child
, NULL
, 1);
2853 GetWindowRect( child
, &rc
);
2854 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
2855 rgn
= CreateRectRgnIndirect( &rc
);
2856 ValidateRgn( hwnd
, rgn
);
2857 ret
= GetUpdateRect( child
, &rc2
, 0);
2858 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
2859 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
2860 rc2
.right
, rc2
.bottom
);
2863 DestroyWindow( child
);
2866 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
2868 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
2869 GetWindowRect( hwnd
, prc
);
2870 trace("window rect is %d,%d - %d,%d\n",
2871 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2872 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
2873 trace("nccalc rect is %d,%d - %d,%d\n",
2874 prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
2877 static void test_nccalcscroll(HWND parent
)
2880 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
2881 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
2882 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
2883 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
2884 10, 10, 200, 200, parent
, 0, 0, NULL
);
2885 ShowWindow( parent
, SW_SHOW
);
2886 UpdateWindow( parent
);
2888 /* test window too low for a horizontal scroll bar */
2889 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
2890 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %d,%d - %d,%d\n",
2891 sbheight
, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2893 /* test window just high enough for a horizontal scroll bar */
2894 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
2895 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be %d size is %d,%d - %d,%d\n",
2896 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2898 /* test window too narrow for a vertical scroll bar */
2899 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
2900 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %d,%d - %d,%d\n",
2901 sbwidth
- 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2903 /* test window just wide enough for a vertical scroll bar */
2904 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2905 ok( rc1
.right
- rc1
.left
== 0, "Width should be %d size is %d,%d - %d,%d\n",
2906 0, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2908 /* same test, but with client edge: not enough width */
2909 SetWindowLong( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLong( hwnd
, GWL_EXSTYLE
));
2910 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
2911 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
2912 "Width should be %d size is %d,%d - %d,%d\n",
2913 sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
), rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
2915 DestroyWindow( hwnd
);
2918 static void test_SetParent(void)
2921 HWND desktop
= GetDesktopWindow();
2923 BOOL is_win9x
= GetWindowLongPtrW(desktop
, GWLP_WNDPROC
) == 0;
2924 HWND parent
, child1
, child2
, child3
, child4
, sibling
;
2926 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
2927 100, 100, 200, 200, 0, 0, 0, NULL
);
2928 assert(parent
!= 0);
2929 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2930 0, 0, 50, 50, parent
, 0, 0, NULL
);
2931 assert(child1
!= 0);
2932 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2933 0, 0, 50, 50, child1
, 0, 0, NULL
);
2934 assert(child2
!= 0);
2935 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
2936 0, 0, 50, 50, child2
, 0, 0, NULL
);
2937 assert(child3
!= 0);
2938 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
2939 0, 0, 50, 50, child3
, 0, 0, NULL
);
2940 assert(child4
!= 0);
2942 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
2943 parent
, child1
, child2
, child3
, child4
);
2945 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
2946 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
2947 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2948 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2949 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2951 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
2952 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
2953 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2954 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
2955 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2957 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
2958 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
2959 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
2960 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
2961 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
2962 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
2963 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
2964 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
2965 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
2967 if (!is_win9x
) /* Win9x doesn't survive this test */
2969 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
2970 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
2971 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
2972 ok(SetParent(parent
, child2
) != 0, "SetParent should not fail\n");
2973 ok(SetParent(parent
, child3
) != 0, "SetParent should not fail\n");
2974 ok(!SetParent(child2
, parent
), "SetParent should fail\n");
2975 ok(SetParent(parent
, child4
) != 0, "SetParent should not fail\n");
2977 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
2978 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
2979 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
2980 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
2981 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
2984 hMenu
= CreateMenu();
2985 sibling
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
2986 100, 100, 200, 200, 0, hMenu
, 0, NULL
);
2987 assert(sibling
!= 0);
2989 ok(SetParent(sibling
, parent
) != 0, "SetParent should not fail\n");
2990 ok(GetMenu(sibling
) == hMenu
, "SetParent should not remove menu\n");
2992 ret
= DestroyWindow(parent
);
2993 ok( ret
, "DestroyWindow() error %d\n", GetLastError());
2995 ok(!IsWindow(parent
), "parent still exists\n");
2996 ok(!IsWindow(sibling
), "sibling still exists\n");
2997 ok(!IsWindow(child1
), "child1 still exists\n");
2998 ok(!IsWindow(child2
), "child2 still exists\n");
2999 ok(!IsWindow(child3
), "child3 still exists\n");
3000 ok(!IsWindow(child4
), "child4 still exists\n");
3003 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3005 LPCREATESTRUCT lpcs
;
3012 lpcs
= (LPCREATESTRUCT
)lparam
;
3013 lpss
= (LPSTYLESTRUCT
)lpcs
->lpCreateParams
;
3016 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
3017 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
3018 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
3019 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
3021 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
3023 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
3024 "Ex style (0x%08lx) should match what the caller passed to CreateWindowEx (0x%08lx)\n",
3025 (lpss
->styleOld
& ~WS_EX_WINDOWEDGE
), (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
));
3027 ok(lpss
->styleNew
== lpcs
->style
,
3028 "Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
3029 lpss
->styleNew
, lpcs
->style
);
3033 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3036 static ATOM atomStyleCheckClass
;
3038 static void register_style_check_class(void)
3046 GetModuleHandle(NULL
),
3048 LoadCursor(NULL
, IDC_ARROW
),
3049 (HBRUSH
)(COLOR_BTNFACE
+1),
3051 TEXT("WineStyleCheck"),
3054 atomStyleCheckClass
= RegisterClass(&wc
);
3057 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
3059 DWORD dwActualStyle
;
3060 DWORD dwActualExStyle
;
3063 HWND hwndParent
= NULL
;
3065 ss
.styleNew
= dwStyleIn
;
3066 ss
.styleOld
= dwExStyleIn
;
3068 if (dwStyleIn
& WS_CHILD
)
3070 hwndParent
= CreateWindowEx(0, MAKEINTATOM(atomStyleCheckClass
), NULL
,
3071 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
3074 hwnd
= CreateWindowEx(dwExStyleIn
, MAKEINTATOM(atomStyleCheckClass
), NULL
,
3075 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
3078 flush_events( TRUE
);
3080 dwActualStyle
= GetWindowLong(hwnd
, GWL_STYLE
);
3081 dwActualExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
3082 ok((dwActualStyle
== dwStyleOut
) && (dwActualExStyle
== dwExStyleOut
),
3083 "Style (0x%08x) should really be 0x%08x and/or Ex style (0x%08x) should really be 0x%08x\n",
3084 dwActualStyle
, dwStyleOut
, dwActualExStyle
, dwExStyleOut
);
3086 DestroyWindow(hwnd
);
3087 if (hwndParent
) DestroyWindow(hwndParent
);
3090 /* tests what window styles the window manager automatically adds */
3091 static void test_window_styles(void)
3093 register_style_check_class();
3095 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3096 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
3097 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
3098 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3099 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
3100 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3101 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3102 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3103 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3104 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
3105 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
3108 static void test_scrollvalidate( HWND parent
)
3111 HRGN hrgn
=CreateRectRgn(0,0,0,0);
3112 HRGN exprgn
, tmprgn
, clipping
;
3113 RECT rc
, rcu
, cliprc
;
3114 /* create two overlapping child windows. The visual region
3115 * of hwnd1 is clipped by the overlapping part of
3116 * hwnd2 because of the WS_CLIPSIBLING style */
3119 clipping
= CreateRectRgn(0,0,0,0);
3120 tmprgn
= CreateRectRgn(0,0,0,0);
3121 exprgn
= CreateRectRgn(0,0,0,0);
3122 hwnd2
= CreateWindowExA(0, "static", NULL
,
3123 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
3124 75, 30, 100, 100, parent
, 0, 0, NULL
);
3125 hwnd1
= CreateWindowExA(0, "static", NULL
,
3126 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
3127 25, 50, 100, 100, parent
, 0, 0, NULL
);
3128 ShowWindow( parent
, SW_SHOW
);
3129 UpdateWindow( parent
);
3130 GetClientRect( hwnd1
, &rc
);
3132 SetRectRgn( clipping
, 10, 10, 90, 90);
3133 hdc
= GetDC( hwnd1
);
3134 /* for a visual touch */
3135 TextOut( hdc
, 0,10, "0123456789", 10);
3136 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
3137 if (winetest_debug
> 0) dump_region(hrgn
);
3138 /* create a region with what is expected */
3139 SetRectRgn( exprgn
, 39,0,49,74);
3140 SetRectRgn( tmprgn
, 88,79,98,93);
3141 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3142 SetRectRgn( tmprgn
, 0,93,98,98);
3143 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3144 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3145 trace("update rect is %d,%d - %d,%d\n",
3146 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
3147 /* now with clipping region */
3148 SelectClipRgn( hdc
, clipping
);
3149 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
3150 if (winetest_debug
> 0) dump_region(hrgn
);
3151 /* create a region with what is expected */
3152 SetRectRgn( exprgn
, 39,10,49,74);
3153 SetRectRgn( tmprgn
, 80,79,90,85);
3154 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3155 SetRectRgn( tmprgn
, 10,85,90,90);
3156 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3157 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3158 trace("update rect is %d,%d - %d,%d\n",
3159 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
3160 ReleaseDC( hwnd1
, hdc
);
3162 /* test scrolling a window with an update region */
3163 DestroyWindow( hwnd2
);
3164 ValidateRect( hwnd1
, NULL
);
3165 SetRect( &rc
, 40,40, 50,50);
3166 InvalidateRect( hwnd1
, &rc
, 1);
3167 GetClientRect( hwnd1
, &rc
);
3169 ScrollWindowEx( hwnd1
, -10, 0, &rc
, &cliprc
, hrgn
, &rcu
,
3170 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
3171 if (winetest_debug
> 0) dump_region(hrgn
);
3172 SetRectRgn( exprgn
, 88,0,98,98);
3173 SetRectRgn( tmprgn
, 30, 40, 50, 50);
3174 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3175 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3177 /* clear an update region */
3178 UpdateWindow( hwnd1
);
3180 SetRect( &rc
, 0,40, 100,60);
3181 SetRect( &cliprc
, 0,0, 100,100);
3182 ScrollWindowEx( hwnd1
, 0, -25, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
3183 if (winetest_debug
> 0) dump_region( hrgn
);
3184 SetRectRgn( exprgn
, 0, 40, 98, 60 );
3185 ok( EqualRgn( exprgn
, hrgn
), "wrong update region in excessive scroll\n");
3187 /* now test ScrollWindowEx with a combination of
3188 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
3189 /* make hwnd2 the child of hwnd1 */
3190 hwnd2
= CreateWindowExA(0, "static", NULL
,
3191 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
3192 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
3193 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
3194 GetClientRect( hwnd1
, &rc
);
3197 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
3198 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
3199 ValidateRect( hwnd1
, NULL
);
3200 ValidateRect( hwnd2
, NULL
);
3201 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
3202 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
3203 if (winetest_debug
> 0) dump_region(hrgn
);
3204 SetRectRgn( exprgn
, 88,0,98,88);
3205 SetRectRgn( tmprgn
, 0,88,98,98);
3206 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3207 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3209 /* SW_SCROLLCHILDREN */
3210 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
3211 ValidateRect( hwnd1
, NULL
);
3212 ValidateRect( hwnd2
, NULL
);
3213 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
3214 if (winetest_debug
> 0) dump_region(hrgn
);
3215 /* expected region is the same as in previous test */
3216 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3218 /* no SW_SCROLLCHILDREN */
3219 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
3220 ValidateRect( hwnd1
, NULL
);
3221 ValidateRect( hwnd2
, NULL
);
3222 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
3223 if (winetest_debug
> 0) dump_region(hrgn
);
3224 /* expected region is the same as in previous test */
3225 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3227 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
3228 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
3229 ValidateRect( hwnd1
, NULL
);
3230 ValidateRect( hwnd2
, NULL
);
3231 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
3232 if (winetest_debug
> 0) dump_region(hrgn
);
3233 SetRectRgn( exprgn
, 88,0,98,20);
3234 SetRectRgn( tmprgn
, 20,20,98,30);
3235 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3236 SetRectRgn( tmprgn
, 20,30,30,88);
3237 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3238 SetRectRgn( tmprgn
, 0,88,30,98);
3239 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
3240 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
3243 DeleteObject( hrgn
);
3244 DeleteObject( exprgn
);
3245 DeleteObject( tmprgn
);
3246 DestroyWindow( hwnd1
);
3247 DestroyWindow( hwnd2
);
3250 /* couple of tests of return values of scrollbar functions
3251 * called on a scrollbarless window */
3252 static void test_scroll(void)
3257 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
3258 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
3259 100, 100, 200, 200, 0, 0, 0, NULL
);
3261 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
3262 ok( ret
, "GetScrollRange returns FALSE\n");
3263 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
3264 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
3265 si
.cbSize
= sizeof( si
);
3266 si
.fMask
= SIF_PAGE
;
3267 si
.nPage
= 0xdeadbeef;
3268 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
3269 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
3270 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
3272 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
3273 ok( ret
, "GetScrollRange returns FALSE\n");
3274 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
3275 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
3276 si
.cbSize
= sizeof( si
);
3277 si
.fMask
= SIF_PAGE
;
3278 si
.nPage
= 0xdeadbeef;
3279 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
3280 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
3281 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
3283 DestroyWindow( hwnd
);
3286 static void test_scrolldc( HWND parent
)
3289 HRGN exprgn
, tmprgn
, hrgn
;
3290 RECT rc
, rc2
, rcu
, cliprc
;
3294 hrgn
= CreateRectRgn(0,0,0,0);
3295 tmprgn
= CreateRectRgn(0,0,0,0);
3296 exprgn
= CreateRectRgn(0,0,0,0);
3298 hwnd1
= CreateWindowExA(0, "static", NULL
,
3299 WS_CHILD
| WS_VISIBLE
,
3300 25, 50, 100, 100, parent
, 0, 0, NULL
);
3301 ShowWindow( parent
, SW_SHOW
);
3302 UpdateWindow( parent
);
3303 flush_events( TRUE
);
3304 GetClientRect( hwnd1
, &rc
);
3305 hdc
= GetDC( hwnd1
);
3306 /* paint the upper half of the window black */
3308 rc2
.bottom
= ( rc
.top
+ rc
.bottom
) /2;
3309 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3310 /* clip region is the lower half */
3312 cliprc
.top
= (rc
.top
+ rc
.bottom
) /2;
3313 /* test whether scrolled pixels are properly clipped */
3314 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
3315 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3316 /* this scroll should not cause any visible changes */
3317 ScrollDC( hdc
, 5, -20, &rc
, &cliprc
, hrgn
, &rcu
);
3318 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
3319 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3320 /* test with NULL clip rect */
3321 ScrollDC( hdc
, 20, -20, &rc
, NULL
, hrgn
, &rcu
);
3322 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
3323 trace("update rect: %d,%d - %d,%d\n",
3324 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
3325 if (winetest_debug
> 0) dump_region(hrgn
);
3326 SetRect(&rc2
, 0, 0, 100, 100);
3327 ok(EqualRect(&rcu
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
3328 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
3330 SetRectRgn( exprgn
, 0, 0, 20, 80);
3331 SetRectRgn( tmprgn
, 0, 80, 100, 100);
3332 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
3333 if (winetest_debug
> 0) dump_region(exprgn
);
3334 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
3335 /* test clip rect > scroll rect */
3336 FillRect( hdc
, &rc
, GetStockObject(WHITE_BRUSH
));
3338 InflateRect( &rc2
, -(rc
.right
-rc
.left
)/4, -(rc
.bottom
-rc
.top
)/4);
3339 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3340 ScrollDC( hdc
, 10, 10, &rc2
, &rc
, hrgn
, &rcu
);
3341 SetRectRgn( exprgn
, 25, 25, 75, 35);
3342 SetRectRgn( tmprgn
, 25, 35, 35, 75);
3343 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
3344 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
3345 colr
= GetPixel( hdc
, 80, 80);
3346 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3347 trace("update rect: %d,%d - %d,%d\n",
3348 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
3349 if (winetest_debug
> 0) dump_region(hrgn
);
3353 DeleteObject(exprgn
);
3354 DeleteObject(tmprgn
);
3355 DestroyWindow(hwnd1
);
3358 static void test_params(void)
3363 /* Just a param check */
3364 SetLastError(0xdeadbeef);
3365 rc
= GetWindowText(hwndMain2
, NULL
, 1024);
3366 ok( rc
==0, "GetWindowText: rc=%d err=%d\n",rc
,GetLastError());
3368 SetLastError(0xdeadbeef);
3369 hwnd
=CreateWindow("LISTBOX", "TestList",
3370 (LBS_STANDARD
& ~LBS_SORT
),
3372 NULL
, (HMENU
)1, NULL
, 0);
3374 ok(!hwnd
, "CreateWindow with invalid menu handle should fail\n");
3375 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
|| /* NT */
3376 GetLastError() == 0xdeadbeef, /* Win9x */
3377 "wrong last error value %d\n", GetLastError());
3380 static void test_AWRwindow(LPCSTR
class, LONG style
, LONG exStyle
, BOOL menu
)
3384 hwnd
= CreateWindowEx(exStyle
, class, class, style
,
3391 trace("Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style
, exStyle
);
3394 ShowWindow(hwnd
, SW_SHOW
);
3396 test_nonclient_area(hwnd
);
3399 DestroyWindow(hwnd
);
3402 static BOOL
AWR_init(void)
3406 class.style
= CS_HREDRAW
| CS_VREDRAW
;
3407 class.lpfnWndProc
= DefWindowProcA
;
3408 class.cbClsExtra
= 0;
3409 class.cbWndExtra
= 0;
3410 class.hInstance
= 0;
3411 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
3412 class.hCursor
= LoadCursor (0, IDC_ARROW
);
3413 class.hbrBackground
= 0;
3414 class.lpszMenuName
= 0;
3415 class.lpszClassName
= szAWRClass
;
3417 if (!RegisterClass (&class)) {
3418 ok(FALSE
, "RegisterClass failed\n");
3422 hmenu
= CreateMenu();
3425 ok(hmenu
!= 0, "Failed to create menu\n");
3426 ok(AppendMenu(hmenu
, MF_STRING
, 1, "Test!"), "Failed to create menu item\n");
3432 static void test_AWR_window_size(BOOL menu
)
3436 WS_MAXIMIZE
, WS_BORDER
, WS_DLGFRAME
,
3439 WS_MINIMIZEBOX
, WS_MAXIMIZEBOX
,
3440 WS_HSCROLL
, WS_VSCROLL
3444 WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
,
3447 /* These styles have problems on (at least) WinXP (SP2) and Wine */
3448 WS_EX_DLGMODALFRAME
,
3455 /* A exhaustive check of all the styles takes too long
3456 * so just do a (hopefully representative) sample
3458 for (i
= 0; i
< COUNTOF(styles
); ++i
)
3459 test_AWRwindow(szAWRClass
, styles
[i
], 0, menu
);
3460 for (i
= 0; i
< COUNTOF(exStyles
); ++i
) {
3461 test_AWRwindow(szAWRClass
, WS_POPUP
, exStyles
[i
], menu
);
3462 test_AWRwindow(szAWRClass
, WS_THICKFRAME
, exStyles
[i
], menu
);
3467 #define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
3469 static void test_AdjustWindowRect(void)
3474 SHOWSYSMETRIC(SM_CYCAPTION
);
3475 SHOWSYSMETRIC(SM_CYSMCAPTION
);
3476 SHOWSYSMETRIC(SM_CYMENU
);
3477 SHOWSYSMETRIC(SM_CXEDGE
);
3478 SHOWSYSMETRIC(SM_CYEDGE
);
3479 SHOWSYSMETRIC(SM_CXVSCROLL
);
3480 SHOWSYSMETRIC(SM_CYHSCROLL
);
3481 SHOWSYSMETRIC(SM_CXFRAME
);
3482 SHOWSYSMETRIC(SM_CYFRAME
);
3483 SHOWSYSMETRIC(SM_CXDLGFRAME
);
3484 SHOWSYSMETRIC(SM_CYDLGFRAME
);
3485 SHOWSYSMETRIC(SM_CXBORDER
);
3486 SHOWSYSMETRIC(SM_CYBORDER
);
3488 test_AWR_window_size(FALSE
);
3489 test_AWR_window_size(TRUE
);
3493 #undef SHOWSYSMETRIC
3496 /* Global variables to trigger exit from loop */
3497 static int redrawComplete
, WMPAINT_count
;
3499 static LRESULT WINAPI
redraw_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3504 trace("doing WM_PAINT %d\n", WMPAINT_count
);
3506 if (WMPAINT_count
> 10 && redrawComplete
== 0) {
3508 BeginPaint(hwnd
, &ps
);
3509 EndPaint(hwnd
, &ps
);
3514 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3517 /* Ensure we exit from RedrawNow regardless of invalidated area */
3518 static void test_redrawnow(void)
3523 cls
.style
= CS_DBLCLKS
;
3524 cls
.lpfnWndProc
= redraw_window_procA
;
3527 cls
.hInstance
= GetModuleHandleA(0);
3529 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3530 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3531 cls
.lpszMenuName
= NULL
;
3532 cls
.lpszClassName
= "RedrawWindowClass";
3534 if(!RegisterClassA(&cls
)) {
3535 trace("Register failed %d\n", GetLastError());
3539 hwndMain
= CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
3540 CW_USEDEFAULT
, 0, 100, 100, NULL
, NULL
, 0, NULL
);
3542 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3543 ShowWindow(hwndMain
, SW_SHOW
);
3544 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3545 RedrawWindow(hwndMain
, NULL
,NULL
,RDW_UPDATENOW
| RDW_ALLCHILDREN
);
3546 ok( WMPAINT_count
== 1, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
3547 redrawComplete
= TRUE
;
3548 ok( WMPAINT_count
< 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count
);
3551 DestroyWindow( hwndMain
);
3554 struct parentdc_stat
{
3560 struct parentdc_test
{
3561 struct parentdc_stat main
, main_todo
;
3562 struct parentdc_stat child1
, child1_todo
;
3563 struct parentdc_stat child2
, child2_todo
;
3566 static LRESULT WINAPI
parentdc_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3571 struct parentdc_stat
*t
= (struct parentdc_stat
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
3576 trace("doing WM_PAINT on %p\n", hwnd
);
3577 GetClientRect(hwnd
, &rc
);
3578 CopyRect(&t
->client
, &rc
);
3579 trace("client rect (%d, %d)-(%d, %d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3580 GetWindowRect(hwnd
, &rc
);
3581 trace("window rect (%d, %d)-(%d, %d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3582 BeginPaint(hwnd
, &ps
);
3583 CopyRect(&t
->paint
, &ps
.rcPaint
);
3584 GetClipBox(ps
.hdc
, &rc
);
3585 CopyRect(&t
->clip
, &rc
);
3586 trace("clip rect (%d, %d)-(%d, %d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3587 trace("paint rect (%d, %d)-(%d, %d)\n", ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
3588 EndPaint(hwnd
, &ps
);
3591 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3594 static void zero_parentdc_stat(struct parentdc_stat
*t
)
3596 SetRectEmpty(&t
->client
);
3597 SetRectEmpty(&t
->clip
);
3598 SetRectEmpty(&t
->paint
);
3601 static void zero_parentdc_test(struct parentdc_test
*t
)
3603 zero_parentdc_stat(&t
->main
);
3604 zero_parentdc_stat(&t
->child1
);
3605 zero_parentdc_stat(&t
->child2
);
3608 #define parentdc_field_ok(t, w, r, f, got) \
3609 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
3610 ": expected %d, got %d\n", \
3613 #define parentdc_todo_field_ok(t, w, r, f, got) \
3614 if (t.w##_todo.r.f) todo_wine { parentdc_field_ok(t, w, r, f, got); } \
3615 else parentdc_field_ok(t, w, r, f, got)
3617 #define parentdc_rect_ok(t, w, r, got) \
3618 parentdc_todo_field_ok(t, w, r, left, got); \
3619 parentdc_todo_field_ok(t, w, r, top, got); \
3620 parentdc_todo_field_ok(t, w, r, right, got); \
3621 parentdc_todo_field_ok(t, w, r, bottom, got);
3623 #define parentdc_win_ok(t, w, got) \
3624 parentdc_rect_ok(t, w, client, got); \
3625 parentdc_rect_ok(t, w, clip, got); \
3626 parentdc_rect_ok(t, w, paint, got);
3628 #define parentdc_ok(t, got) \
3629 parentdc_win_ok(t, main, got); \
3630 parentdc_win_ok(t, child1, got); \
3631 parentdc_win_ok(t, child2, got);
3633 static void test_csparentdc(void)
3635 WNDCLASSA clsMain
, cls
;
3636 HWND hwndMain
, hwnd1
, hwnd2
;
3639 struct parentdc_test test_answer
;
3641 #define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
3642 const struct parentdc_test test1
=
3644 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo
,
3645 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3646 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3649 const struct parentdc_test test2
=
3651 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo
,
3652 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3653 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3656 const struct parentdc_test test3
=
3658 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3659 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3660 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3663 const struct parentdc_test test4
=
3665 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo
,
3666 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo
,
3667 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3670 const struct parentdc_test test5
=
3672 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo
,
3673 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3674 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
3677 const struct parentdc_test test6
=
3679 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3680 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
3681 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3684 const struct parentdc_test test7
=
3686 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3687 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
3688 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
3692 clsMain
.style
= CS_DBLCLKS
;
3693 clsMain
.lpfnWndProc
= parentdc_window_procA
;
3694 clsMain
.cbClsExtra
= 0;
3695 clsMain
.cbWndExtra
= 0;
3696 clsMain
.hInstance
= GetModuleHandleA(0);
3698 clsMain
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3699 clsMain
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3700 clsMain
.lpszMenuName
= NULL
;
3701 clsMain
.lpszClassName
= "ParentDcMainWindowClass";
3703 if(!RegisterClassA(&clsMain
)) {
3704 trace("Register failed %d\n", GetLastError());
3708 cls
.style
= CS_DBLCLKS
| CS_PARENTDC
;
3709 cls
.lpfnWndProc
= parentdc_window_procA
;
3712 cls
.hInstance
= GetModuleHandleA(0);
3714 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
3715 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
3716 cls
.lpszMenuName
= NULL
;
3717 cls
.lpszClassName
= "ParentDcWindowClass";
3719 if(!RegisterClassA(&cls
)) {
3720 trace("Register failed %d\n", GetLastError());
3724 SetRect(&rc
, 0, 0, 150, 150);
3725 AdjustWindowRectEx(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
, 0);
3726 hwndMain
= CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
3727 CW_USEDEFAULT
, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, NULL
, NULL
, 0, NULL
);
3728 SetWindowLongPtrA(hwndMain
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.main
);
3729 hwnd1
= CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD
,
3730 20, 20, 40, 40, hwndMain
, NULL
, 0, NULL
);
3731 SetWindowLongPtrA(hwnd1
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child1
);
3732 hwnd2
= CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD
,
3733 40, 40, 40, 40, hwndMain
, NULL
, 0, NULL
);
3734 SetWindowLongPtrA(hwnd2
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child2
);
3735 ShowWindow(hwndMain
, SW_SHOW
);
3736 ShowWindow(hwnd1
, SW_SHOW
);
3737 ShowWindow(hwnd2
, SW_SHOW
);
3738 flush_events( TRUE
);
3740 zero_parentdc_test(&test_answer
);
3741 InvalidateRect(hwndMain
, NULL
, TRUE
);
3742 flush_events( TRUE
);
3743 parentdc_ok(test1
, test_answer
);
3745 zero_parentdc_test(&test_answer
);
3746 SetRect(&rc
, 0, 0, 50, 50);
3747 InvalidateRect(hwndMain
, &rc
, TRUE
);
3748 flush_events( TRUE
);
3749 parentdc_ok(test2
, test_answer
);
3751 zero_parentdc_test(&test_answer
);
3752 SetRect(&rc
, 0, 0, 10, 10);
3753 InvalidateRect(hwndMain
, &rc
, TRUE
);
3754 flush_events( TRUE
);
3755 parentdc_ok(test3
, test_answer
);
3757 zero_parentdc_test(&test_answer
);
3758 SetRect(&rc
, 40, 40, 50, 50);
3759 InvalidateRect(hwndMain
, &rc
, TRUE
);
3760 flush_events( TRUE
);
3761 parentdc_ok(test4
, test_answer
);
3763 zero_parentdc_test(&test_answer
);
3764 SetRect(&rc
, 20, 20, 60, 60);
3765 InvalidateRect(hwndMain
, &rc
, TRUE
);
3766 flush_events( TRUE
);
3767 parentdc_ok(test5
, test_answer
);
3769 zero_parentdc_test(&test_answer
);
3770 SetRect(&rc
, 0, 0, 10, 10);
3771 InvalidateRect(hwnd1
, &rc
, TRUE
);
3772 flush_events( TRUE
);
3773 parentdc_ok(test6
, test_answer
);
3775 zero_parentdc_test(&test_answer
);
3776 SetRect(&rc
, -5, -5, 65, 65);
3777 InvalidateRect(hwnd1
, &rc
, TRUE
);
3778 flush_events( TRUE
);
3779 parentdc_ok(test7
, test_answer
);
3781 DestroyWindow(hwndMain
);
3782 DestroyWindow(hwnd1
);
3783 DestroyWindow(hwnd2
);
3786 static LRESULT WINAPI
def_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3788 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
3791 static LRESULT WINAPI
def_window_procW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3793 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
3796 static void test_IsWindowUnicode(void)
3798 static const char ansi_class_nameA
[] = "ansi class name";
3799 static const WCHAR ansi_class_nameW
[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
3800 static const char unicode_class_nameA
[] = "unicode class name";
3801 static const WCHAR unicode_class_nameW
[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
3806 memset(&classW
, 0, sizeof(classW
));
3807 classW
.hInstance
= GetModuleHandleA(0);
3808 classW
.lpfnWndProc
= def_window_procW
;
3809 classW
.lpszClassName
= unicode_class_nameW
;
3810 if (!RegisterClassW(&classW
)) return; /* this catches Win9x as well */
3812 memset(&classA
, 0, sizeof(classA
));
3813 classA
.hInstance
= GetModuleHandleA(0);
3814 classA
.lpfnWndProc
= def_window_procA
;
3815 classA
.lpszClassName
= ansi_class_nameA
;
3816 assert(RegisterClassA(&classA
));
3818 /* unicode class: window proc */
3819 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
3820 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3823 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3824 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
3825 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3826 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
3827 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3829 DestroyWindow(hwnd
);
3831 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
3832 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3835 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3836 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
3837 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3838 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
3839 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3841 DestroyWindow(hwnd
);
3843 /* ansi class: window proc */
3844 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
3845 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3848 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3849 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
3850 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3851 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
3852 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3854 DestroyWindow(hwnd
);
3856 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
3857 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3860 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3861 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
3862 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3863 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
3864 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3866 DestroyWindow(hwnd
);
3868 /* unicode class: class proc */
3869 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
3870 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3873 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3874 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
3875 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3876 /* do not restore class window proc back to unicode */
3878 DestroyWindow(hwnd
);
3880 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
3881 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3884 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3885 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
3886 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3888 DestroyWindow(hwnd
);
3890 /* ansi class: class proc */
3891 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
3892 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3895 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3896 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
3897 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
3898 /* do not restore class window proc back to ansi */
3900 DestroyWindow(hwnd
);
3902 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
3903 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
3906 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3907 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
3908 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
3910 DestroyWindow(hwnd
);
3913 static LRESULT CALLBACK
minmax_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
3917 if (msg
!= WM_GETMINMAXINFO
)
3918 return DefWindowProc(hwnd
, msg
, wp
, lp
);
3920 minmax
= (MINMAXINFO
*)lp
;
3922 if ((GetWindowLong(hwnd
, GWL_STYLE
) & WS_CHILD
))
3924 minmax
->ptReserved
.x
= 0;
3925 minmax
->ptReserved
.y
= 0;
3926 minmax
->ptMaxSize
.x
= 400;
3927 minmax
->ptMaxSize
.y
= 400;
3928 minmax
->ptMaxPosition
.x
= 300;
3929 minmax
->ptMaxPosition
.y
= 300;
3930 minmax
->ptMaxTrackSize
.x
= 200;
3931 minmax
->ptMaxTrackSize
.y
= 200;
3932 minmax
->ptMinTrackSize
.x
= 100;
3933 minmax
->ptMinTrackSize
.y
= 100;
3936 DefWindowProc(hwnd
, msg
, wp
, lp
);
3940 static int expected_cx
, expected_cy
;
3941 static RECT expected_rect
, broken_rect
;
3943 static LRESULT CALLBACK
winsizes_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
3947 case WM_GETMINMAXINFO
:
3950 GetWindowRect( hwnd
, &rect
);
3951 ok( !rect
.left
&& !rect
.top
&& !rect
.right
&& !rect
.bottom
,
3952 "wrong rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
3953 return DefWindowProc(hwnd
, msg
, wp
, lp
);
3958 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
3960 GetWindowRect( hwnd
, &rect
);
3961 trace( "hwnd %p msg %x size %dx%d rect %d,%d-%d,%d\n",
3962 hwnd
, msg
, cs
->cx
, cs
->cy
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
3963 ok( cs
->cx
== expected_cx
, "wrong x size %d/%d\n", cs
->cx
, expected_cx
);
3964 ok( cs
->cy
== expected_cy
, "wrong y size %d/%d\n", cs
->cy
, expected_cy
);
3965 ok( (rect
.right
- rect
.left
== expected_rect
.right
- expected_rect
.left
&&
3966 rect
.bottom
- rect
.top
== expected_rect
.bottom
- expected_rect
.top
) ||
3967 broken( rect
.right
- rect
.left
== broken_rect
.right
- broken_rect
.left
&&
3968 rect
.bottom
- rect
.top
== broken_rect
.bottom
- broken_rect
.top
),
3969 "wrong rect %d,%d-%d,%d / %d,%d-%d,%d\n",
3970 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
3971 expected_rect
.left
, expected_rect
.top
, expected_rect
.right
, expected_rect
.bottom
);
3972 return DefWindowProc(hwnd
, msg
, wp
, lp
);
3976 RECT rect
, *r
= (RECT
*)lp
;
3977 GetWindowRect( hwnd
, &rect
);
3978 ok( !memcmp( &rect
, r
, sizeof(rect
) ),
3979 "passed rect %d,%d-%d,%d doesn't match window rect %d,%d-%d,%d\n",
3980 r
->left
, r
->top
, r
->right
, r
->bottom
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
3981 return DefWindowProc(hwnd
, msg
, wp
, lp
);
3984 return DefWindowProc(hwnd
, msg
, wp
, lp
);
3988 static void test_CreateWindow(void)
3996 #define expect_menu(window, menu) \
3997 SetLastError(0xdeadbeef); \
3998 ok(GetMenu(window) == (HMENU)menu, "GetMenu error %d\n", GetLastError())
4000 #define expect_style(window, style)\
4001 ok(GetWindowLong(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLong(window, GWL_STYLE))
4003 #define expect_ex_style(window, ex_style)\
4004 ok(GetWindowLong(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLong(window, GWL_EXSTYLE))
4006 hmenu
= CreateMenu();
4008 parent
= GetDesktopWindow();
4009 assert(parent
!= 0);
4011 SetLastError(0xdeadbeef);
4012 ok(IsMenu(hmenu
), "IsMenu error %d\n", GetLastError());
4015 SetLastError(0xdeadbeef);
4016 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
,
4017 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4018 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4019 expect_menu(hwnd
, 1);
4020 expect_style(hwnd
, WS_CHILD
);
4021 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
4022 DestroyWindow(hwnd
);
4024 SetLastError(0xdeadbeef);
4025 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_CAPTION
,
4026 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4027 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4028 expect_menu(hwnd
, 1);
4029 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
4030 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
4031 DestroyWindow(hwnd
);
4033 SetLastError(0xdeadbeef);
4034 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
,
4035 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4036 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4037 expect_menu(hwnd
, 1);
4038 expect_style(hwnd
, WS_CHILD
);
4039 expect_ex_style(hwnd
, 0);
4040 DestroyWindow(hwnd
);
4042 SetLastError(0xdeadbeef);
4043 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_CAPTION
,
4044 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4045 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4046 expect_menu(hwnd
, 1);
4047 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
4048 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
4049 DestroyWindow(hwnd
);
4052 SetLastError(0xdeadbeef);
4053 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
4054 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4055 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4056 expect_menu(hwnd
, hmenu
);
4057 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
4058 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
4059 DestroyWindow(hwnd
);
4060 SetLastError(0xdeadbeef);
4061 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4062 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4064 hmenu
= CreateMenu();
4066 SetLastError(0xdeadbeef);
4067 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
| WS_CAPTION
,
4068 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4069 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4070 expect_menu(hwnd
, hmenu
);
4071 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
4072 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
4073 DestroyWindow(hwnd
);
4074 SetLastError(0xdeadbeef);
4075 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4076 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4078 hmenu
= CreateMenu();
4080 SetLastError(0xdeadbeef);
4081 hwnd
= CreateWindowEx(0, "static", NULL
, WS_POPUP
,
4082 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4083 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4084 expect_menu(hwnd
, hmenu
);
4085 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
4086 expect_ex_style(hwnd
, 0);
4087 DestroyWindow(hwnd
);
4088 SetLastError(0xdeadbeef);
4089 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4090 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4092 hmenu
= CreateMenu();
4094 SetLastError(0xdeadbeef);
4095 hwnd
= CreateWindowEx(0, "static", NULL
, WS_POPUP
| WS_CAPTION
,
4096 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4097 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4098 expect_menu(hwnd
, hmenu
);
4099 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
4100 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
4101 DestroyWindow(hwnd
);
4102 SetLastError(0xdeadbeef);
4103 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4104 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4106 /* WS_CHILD | WS_POPUP */
4107 SetLastError(0xdeadbeef);
4108 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
4109 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4110 ok(!hwnd
, "CreateWindowEx should fail\n");
4111 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4113 hmenu
= CreateMenu();
4115 SetLastError(0xdeadbeef);
4116 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
4117 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4118 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4119 expect_menu(hwnd
, hmenu
);
4120 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
4121 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
4122 DestroyWindow(hwnd
);
4123 SetLastError(0xdeadbeef);
4124 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4125 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4127 SetLastError(0xdeadbeef);
4128 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
4129 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4130 ok(!hwnd
, "CreateWindowEx should fail\n");
4131 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4133 hmenu
= CreateMenu();
4135 SetLastError(0xdeadbeef);
4136 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
4137 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4138 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4139 expect_menu(hwnd
, hmenu
);
4140 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
4141 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
4142 DestroyWindow(hwnd
);
4143 SetLastError(0xdeadbeef);
4144 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4145 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4147 SetLastError(0xdeadbeef);
4148 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
4149 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4150 ok(!hwnd
, "CreateWindowEx should fail\n");
4151 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4153 hmenu
= CreateMenu();
4155 SetLastError(0xdeadbeef);
4156 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
4157 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4158 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4159 expect_menu(hwnd
, hmenu
);
4160 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
4161 expect_ex_style(hwnd
, 0);
4162 DestroyWindow(hwnd
);
4163 SetLastError(0xdeadbeef);
4164 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4165 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4167 SetLastError(0xdeadbeef);
4168 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
4169 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4170 ok(!hwnd
, "CreateWindowEx should fail\n");
4171 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4173 hmenu
= CreateMenu();
4175 SetLastError(0xdeadbeef);
4176 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
4177 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4178 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4179 expect_menu(hwnd
, hmenu
);
4180 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
4181 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
4182 DestroyWindow(hwnd
);
4183 SetLastError(0xdeadbeef);
4184 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4185 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
4187 /* test child window sizing */
4189 cls
.lpfnWndProc
= minmax_wnd_proc
;
4192 cls
.hInstance
= GetModuleHandle(0);
4194 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
4195 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4196 cls
.lpszMenuName
= NULL
;
4197 cls
.lpszClassName
= "MinMax_WndClass";
4198 RegisterClass(&cls
);
4200 SetLastError(0xdeadbeef);
4201 parent
= CreateWindowEx(0, "MinMax_WndClass", NULL
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
4202 0, 0, 100, 100, 0, 0, 0, NULL
);
4203 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
4204 expect_menu(parent
, 0);
4205 expect_style(parent
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
| WS_CLIPSIBLINGS
);
4206 expect_ex_style(parent
, WS_EX_WINDOWEDGE
);
4208 memset(&minmax
, 0, sizeof(minmax
));
4209 SendMessage(parent
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
4210 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxSize
.x
, minmax
.ptMaxSize
.y
);
4211 ok(IsRectEmpty(&rc_minmax
), "ptMaxSize is not empty\n");
4212 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
4213 ok(IsRectEmpty(&rc_minmax
), "ptMaxTrackSize is not empty\n");
4215 GetWindowRect(parent
, &rc
);
4216 ok(!IsRectEmpty(&rc
), "parent window rect is empty\n");
4217 GetClientRect(parent
, &rc
);
4218 ok(!IsRectEmpty(&rc
), "parent client rect is empty\n");
4220 InflateRect(&rc
, 200, 200);
4221 trace("creating child with rect (%d,%d-%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4223 SetLastError(0xdeadbeef);
4224 hwnd
= CreateWindowEx(0, "MinMax_WndClass", NULL
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
4225 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
4226 parent
, (HMENU
)1, 0, NULL
);
4227 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4228 expect_menu(hwnd
, 1);
4229 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
);
4230 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
4232 memset(&minmax
, 0, sizeof(minmax
));
4233 SendMessage(hwnd
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
4234 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
4236 GetWindowRect(hwnd
, &rc
);
4237 OffsetRect(&rc
, -rc
.left
, -rc
.top
);
4238 ok(EqualRect(&rc
, &rc_minmax
), "rects don't match: (%d,%d-%d,%d) and (%d,%d-%d,%d)\n",
4239 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
4240 rc_minmax
.left
, rc_minmax
.top
, rc_minmax
.right
, rc_minmax
.bottom
);
4241 DestroyWindow(hwnd
);
4243 cls
.lpfnWndProc
= winsizes_wnd_proc
;
4244 cls
.lpszClassName
= "Sizes_WndClass";
4245 RegisterClass(&cls
);
4247 expected_cx
= expected_cy
= 200000;
4248 SetRect( &expected_rect
, 0, 0, 200000, 200000 );
4249 broken_rect
= expected_rect
;
4250 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 300000, 300000, 200000, 200000, parent
, 0, 0, NULL
);
4251 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
4252 GetClientRect( hwnd
, &rc
);
4253 ok( rc
.right
== 200000, "invalid rect right %u\n", rc
.right
);
4254 ok( rc
.bottom
== 200000, "invalid rect bottom %u\n", rc
.bottom
);
4255 DestroyWindow(hwnd
);
4257 expected_cx
= expected_cy
= -10;
4258 SetRect( &expected_rect
, 0, 0, 0, 0 );
4259 SetRect( &broken_rect
, 0, 0, -10, -10 );
4260 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -20, -20, -10, -10, parent
, 0, 0, NULL
);
4261 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
4262 GetClientRect( hwnd
, &rc
);
4263 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
4264 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
4265 DestroyWindow(hwnd
);
4267 expected_cx
= expected_cy
= -200000;
4268 SetRect( &expected_rect
, 0, 0, 0, 0 );
4269 SetRect( &broken_rect
, 0, 0, -200000, -200000 );
4270 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -300000, -300000, -200000, -200000, parent
, 0, 0, NULL
);
4271 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
4272 GetClientRect( hwnd
, &rc
);
4273 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
4274 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
4275 DestroyWindow(hwnd
);
4277 /* we need a parent at 0,0 so that child coordinates match */
4278 DestroyWindow(parent
);
4279 parent
= CreateWindowEx(0, "MinMax_WndClass", NULL
, WS_POPUP
, 0, 0, 100, 100, 0, 0, 0, NULL
);
4280 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
4283 expected_cy
= 0x7fffffff;
4284 SetRect( &expected_rect
, 10, 10, 110, 0x7fffffff );
4285 SetRect( &broken_rect
, 10, 10, 110, 0x7fffffffU
+ 10 );
4286 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 10, 10, 100, 0x7fffffff, parent
, 0, 0, NULL
);
4287 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
4288 GetClientRect( hwnd
, &rc
);
4289 ok( rc
.right
== 100, "invalid rect right %u\n", rc
.right
);
4290 ok( rc
.bottom
== 0x7fffffff - 10 || broken(rc
.bottom
== 0), "invalid rect bottom %u\n", rc
.bottom
);
4291 DestroyWindow(hwnd
);
4293 expected_cx
= 0x7fffffff;
4294 expected_cy
= 0x7fffffff;
4295 SetRect( &expected_rect
, 20, 10, 0x7fffffff, 0x7fffffff );
4296 SetRect( &broken_rect
, 20, 10, 0x7fffffffU
+ 20, 0x7fffffffU
+ 10 );
4297 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 20, 10, 0x7fffffff, 0x7fffffff, parent
, 0, 0, NULL
);
4298 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
4299 GetClientRect( hwnd
, &rc
);
4300 ok( rc
.right
== 0x7fffffff - 20 || broken(rc
.right
== 0), "invalid rect right %u\n", rc
.right
);
4301 ok( rc
.bottom
== 0x7fffffff - 10 || broken(rc
.bottom
== 0), "invalid rect bottom %u\n", rc
.bottom
);
4302 DestroyWindow(hwnd
);
4304 /* top level window */
4305 expected_cx
= expected_cy
= 200000;
4306 SetRect( &expected_rect
, 0, 0, GetSystemMetrics(SM_CXMAXTRACK
), GetSystemMetrics(SM_CYMAXTRACK
) );
4307 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_OVERLAPPEDWINDOW
, 300000, 300000, 200000, 200000, 0, 0, 0, NULL
);
4308 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
4309 GetClientRect( hwnd
, &rc
);
4310 ok( rc
.right
<= expected_cx
, "invalid rect right %u\n", rc
.right
);
4311 ok( rc
.bottom
<= expected_cy
, "invalid rect bottom %u\n", rc
.bottom
);
4312 DestroyWindow(hwnd
);
4314 DestroyWindow(parent
);
4316 UnregisterClass("MinMax_WndClass", GetModuleHandle(0));
4317 UnregisterClass("Sizes_WndClass", GetModuleHandle(0));
4321 #undef expect_ex_style
4324 /* function that remembers whether the system the test is running on sets the
4325 * last error for user32 functions to make the tests stricter */
4326 static int check_error(DWORD actual
, DWORD expected
)
4328 static int sets_last_error
= -1;
4329 if (sets_last_error
== -1)
4330 sets_last_error
= (actual
!= 0xdeadbeef);
4331 return (!sets_last_error
&& (actual
== 0xdeadbeef)) || (actual
== expected
);
4334 static void test_SetWindowLong(void)
4337 WNDPROC old_window_procW
;
4339 SetLastError(0xdeadbeef);
4340 retval
= SetWindowLongPtr(NULL
, GWLP_WNDPROC
, 0);
4341 ok(!retval
, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval
);
4342 ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE
),
4343 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instad of %d\n", GetLastError());
4345 SetLastError(0xdeadbeef);
4346 retval
= SetWindowLongPtr(hwndMain
, 0xdeadbeef, 0);
4347 ok(!retval
, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval
);
4348 ok(check_error(GetLastError(), ERROR_INVALID_INDEX
),
4349 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instad of %d\n", GetLastError());
4351 SetLastError(0xdeadbeef);
4352 retval
= SetWindowLongPtr(hwndMain
, GWLP_WNDPROC
, 0);
4353 ok((WNDPROC
)retval
== main_window_procA
,
4354 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval
);
4355 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
4356 retval
= GetWindowLongPtr(hwndMain
, GWLP_WNDPROC
);
4357 ok((WNDPROC
)retval
== main_window_procA
,
4358 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
4359 ok(!IsWindowUnicode(hwndMain
), "hwndMain shouldn't be Unicode\n");
4361 old_window_procW
= (WNDPROC
)GetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
);
4362 SetLastError(0xdeadbeef);
4363 retval
= SetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
, 0);
4364 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED
)
4366 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
4367 ok(retval
!= 0, "SetWindowLongPtr error %d\n", GetLastError());
4368 ok((WNDPROC
)retval
== old_window_procW
,
4369 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
4370 ok(IsWindowUnicode(hwndMain
), "hwndMain should now be Unicode\n");
4372 /* set it back to ANSI */
4373 SetWindowLongPtr(hwndMain
, GWLP_WNDPROC
, 0);
4377 static void test_ShowWindow(void)
4384 SetRect(&rcMain
, 120, 120, 210, 210);
4386 hwnd
= CreateWindowEx(0, "MainWindowClass", NULL
,
4387 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
4388 WS_MAXIMIZEBOX
| WS_POPUP
,
4389 rcMain
.left
, rcMain
.top
,
4390 rcMain
.right
- rcMain
.left
, rcMain
.bottom
- rcMain
.top
,
4394 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4395 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
4396 ok(!(style
& WS_VISIBLE
), "window should not be visible\n");
4397 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
4398 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4399 GetWindowRect(hwnd
, &rc
);
4400 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
4401 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
4402 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4404 ret
= ShowWindow(hwnd
, SW_SHOW
);
4405 ok(!ret
, "not expected ret: %lu\n", ret
);
4406 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4407 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
4408 ok(style
& WS_VISIBLE
, "window should be visible\n");
4409 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
4410 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4411 GetWindowRect(hwnd
, &rc
);
4412 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
4413 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
4414 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4416 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
4417 ok(ret
, "not expected ret: %lu\n", ret
);
4418 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4419 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
4420 ok(style
& WS_VISIBLE
, "window should be visible\n");
4421 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
4422 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4423 GetWindowRect(hwnd
, &rc
);
4424 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
4426 ShowWindow(hwnd
, SW_RESTORE
);
4427 ok(ret
, "not expected ret: %lu\n", ret
);
4428 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4429 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
4430 ok(style
& WS_VISIBLE
, "window should be visible\n");
4431 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
4432 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4433 GetWindowRect(hwnd
, &rc
);
4434 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
4435 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
4436 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4438 ret
= EnableWindow(hwnd
, FALSE
);
4439 ok(!ret
, "not expected ret: %lu\n", ret
);
4440 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4441 ok(style
& WS_DISABLED
, "window should be disabled\n");
4443 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
4444 ok(!ret
, "not expected ret: %lu\n", ret
);
4445 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4446 ok(style
& WS_DISABLED
, "window should be disabled\n");
4447 ok(style
& WS_VISIBLE
, "window should be visible\n");
4448 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
4449 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4450 GetWindowRect(hwnd
, &rc
);
4451 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
4452 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
4453 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4455 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_MAXIMIZE
, 0);
4456 ok(!ret
, "not expected ret: %lu\n", ret
);
4457 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4458 ok(style
& WS_DISABLED
, "window should be disabled\n");
4459 ok(style
& WS_VISIBLE
, "window should be visible\n");
4460 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
4461 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4462 GetWindowRect(hwnd
, &rc
);
4463 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
4464 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
4465 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4467 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
4468 ok(ret
, "not expected ret: %lu\n", ret
);
4469 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4470 ok(style
& WS_DISABLED
, "window should be disabled\n");
4471 ok(style
& WS_VISIBLE
, "window should be visible\n");
4472 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
4473 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4474 GetWindowRect(hwnd
, &rc
);
4475 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
4477 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0);
4478 ok(!ret
, "not expected ret: %lu\n", ret
);
4479 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4480 ok(style
& WS_DISABLED
, "window should be disabled\n");
4481 ok(style
& WS_VISIBLE
, "window should be visible\n");
4482 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
4483 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4484 GetWindowRect(hwnd
, &rc
);
4485 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
4487 ret
= ShowWindow(hwnd
, SW_RESTORE
);
4488 ok(ret
, "not expected ret: %lu\n", ret
);
4489 style
= GetWindowLong(hwnd
, GWL_STYLE
);
4490 ok(style
& WS_DISABLED
, "window should be disabled\n");
4491 ok(style
& WS_VISIBLE
, "window should be visible\n");
4492 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
4493 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
4494 GetWindowRect(hwnd
, &rc
);
4495 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
4496 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
4497 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4499 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
4500 ok(!ret
, "not expected ret: %lu\n", ret
);
4501 ok(IsWindow(hwnd
), "window should exist\n");
4503 ret
= EnableWindow(hwnd
, TRUE
);
4504 ok(ret
, "not expected ret: %lu\n", ret
);
4506 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
4507 ok(!ret
, "not expected ret: %lu\n", ret
);
4508 ok(!IsWindow(hwnd
), "window should not exist\n");
4511 static void test_gettext(void)
4514 LPCSTR clsname
= "gettexttest";
4518 memset( &cls
, 0, sizeof cls
);
4519 cls
.lpfnWndProc
= DefWindowProc
;
4520 cls
.lpszClassName
= clsname
;
4521 cls
.hInstance
= GetModuleHandle(NULL
);
4523 if (!RegisterClass( &cls
)) return;
4525 hwnd
= CreateWindow( clsname
, "test text", WS_OVERLAPPED
, 0, 0, 10, 10, 0, NULL
, NULL
, NULL
);
4526 ok( hwnd
!= NULL
, "window was null\n");
4528 r
= SendMessage( hwnd
, WM_GETTEXT
, 0x10, 0x1000);
4529 ok( r
== 0, "settext should return zero\n");
4531 r
= SendMessage( hwnd
, WM_GETTEXT
, 0x10000, 0);
4532 ok( r
== 0, "settext should return zero (%ld)\n", r
);
4534 r
= SendMessage( hwnd
, WM_GETTEXT
, 0xff000000, 0x1000);
4535 ok( r
== 0, "settext should return zero (%ld)\n", r
);
4537 r
= SendMessage( hwnd
, WM_GETTEXT
, 0x1000, 0xff000000);
4538 ok( r
== 0, "settext should return zero (%ld)\n", r
);
4540 DestroyWindow(hwnd
);
4541 UnregisterClass( clsname
, NULL
);
4545 static void test_GetUpdateRect(void)
4548 BOOL ret
, parent_wm_paint
, grandparent_wm_paint
;
4550 HWND hgrandparent
, hparent
, hchild
;
4552 static const char classNameA
[] = "GetUpdateRectClass";
4554 hgrandparent
= CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW
,
4555 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
4557 hparent
= CreateWindowA("static", "parent", WS_CHILD
|WS_VISIBLE
,
4558 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
4560 hchild
= CreateWindowA("static", "child", WS_CHILD
|WS_VISIBLE
,
4561 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
4563 ShowWindow(hgrandparent
, SW_SHOW
);
4564 UpdateWindow(hgrandparent
);
4565 flush_events( TRUE
);
4567 ShowWindow(hchild
, SW_HIDE
);
4568 SetRect(&rc2
, 0, 0, 0, 0);
4569 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
4570 ok(!ret
, "GetUpdateRect returned not empty region\n");
4571 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
4572 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
4573 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
4575 SetRect(&rc2
, 10, 10, 40, 40);
4576 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
4577 ok(ret
, "GetUpdateRect returned empty region\n");
4578 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
4579 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
4580 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
4582 parent_wm_paint
= FALSE
;
4583 grandparent_wm_paint
= FALSE
;
4584 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
4586 if (msg
.message
== WM_PAINT
)
4588 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
4589 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
4591 DispatchMessage(&msg
);
4593 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
4594 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
4596 DestroyWindow(hgrandparent
);
4599 cls
.lpfnWndProc
= DefWindowProcA
;
4602 cls
.hInstance
= GetModuleHandleA(0);
4604 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
4605 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4606 cls
.lpszMenuName
= NULL
;
4607 cls
.lpszClassName
= classNameA
;
4609 if(!RegisterClassA(&cls
)) {
4610 trace("Register failed %d\n", GetLastError());
4614 hgrandparent
= CreateWindowA(classNameA
, "grandparent", WS_OVERLAPPEDWINDOW
,
4615 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
4617 hparent
= CreateWindowA(classNameA
, "parent", WS_CHILD
|WS_VISIBLE
,
4618 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
4620 hchild
= CreateWindowA(classNameA
, "child", WS_CHILD
|WS_VISIBLE
,
4621 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
4623 ShowWindow(hgrandparent
, SW_SHOW
);
4624 UpdateWindow(hgrandparent
);
4625 flush_events( TRUE
);
4627 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
4628 ok(!ret
, "GetUpdateRect returned not empty region\n");
4630 ShowWindow(hchild
, SW_HIDE
);
4632 SetRect(&rc2
, 0, 0, 0, 0);
4633 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
4634 ok(!ret
, "GetUpdateRect returned not empty region\n");
4635 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
4636 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
4637 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
4639 SetRect(&rc2
, 10, 10, 40, 40);
4640 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
4641 ok(ret
, "GetUpdateRect returned empty region\n");
4642 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
4643 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
4644 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
4646 parent_wm_paint
= FALSE
;
4647 grandparent_wm_paint
= FALSE
;
4648 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
4650 if (msg
.message
== WM_PAINT
)
4652 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
4653 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
4655 DispatchMessage(&msg
);
4657 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
4658 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
4660 DestroyWindow(hgrandparent
);
4664 static LRESULT CALLBACK
TestExposedRegion_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
4672 const int waitTime
= 2000;
4674 BeginPaint(hwnd
, &ps
);
4676 /* create and destroy window to create an exposed region on this window */
4677 win
= CreateWindowA("static", "win", WS_VISIBLE
,
4678 10,10,50,50, NULL
, NULL
, 0, NULL
);
4681 waitResult
= MsgWaitForMultipleObjects( 0, NULL
, FALSE
, waitTime
, QS_PAINT
);
4683 ValidateRect(hwnd
, NULL
);
4684 EndPaint(hwnd
, &ps
);
4686 if(waitResult
!= WAIT_TIMEOUT
)
4688 GetUpdateRect(hwnd
, &updateRect
, FALSE
);
4689 ok(IsRectEmpty(&updateRect
), "Exposed rect should be empty\n");
4694 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
4697 static void test_Expose(void)
4702 memset(&cls
, 0, sizeof(WNDCLASSA
));
4703 cls
.lpfnWndProc
= TestExposedRegion_WndProc
;
4704 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4705 cls
.lpszClassName
= "TestExposeClass";
4706 atom
= RegisterClassA(&cls
);
4708 mw
= CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
4709 0, 0, 200, 100, NULL
, NULL
, 0, NULL
);
4715 static void test_GetWindowModuleFileName(void)
4720 char buf1
[MAX_PATH
], buf2
[MAX_PATH
];
4722 if (!pGetWindowModuleFileNameA
)
4724 skip("GetWindowModuleFileNameA is not available\n");
4728 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
4731 hinst
= (HINSTANCE
)GetWindowLongPtr(hwnd
, GWLP_HINSTANCE
);
4732 ok(hinst
== 0, "expected 0, got %p\n", hinst
);
4735 SetLastError(0xdeadbeef);
4736 ret1
= GetModuleFileName(hinst
, buf1
, sizeof(buf1
));
4737 ok(ret1
, "GetModuleFileName error %u\n", GetLastError());
4740 SetLastError(0xdeadbeef);
4741 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
4742 ok(ret2
, "GetWindowModuleFileNameA error %u\n", GetLastError());
4744 ok(ret1
== ret2
, "%u != %u\n", ret1
, ret2
);
4745 ok(!strcmp(buf1
, buf2
), "%s != %s\n", buf1
, buf2
);
4747 hinst
= GetModuleHandle(0);
4749 SetLastError(0xdeadbeef);
4750 ret2
= GetModuleFileName(hinst
, buf2
, ret1
- 2);
4751 ok(ret2
== ret1
- 2, "expected %u, got %u\n", ret1
- 2, ret2
);
4752 ok(GetLastError() == 0xdeadbeef /* XP */ ||
4753 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
4754 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
4756 SetLastError(0xdeadbeef);
4757 ret2
= GetModuleFileName(hinst
, buf2
, 0);
4758 ok(!ret2
, "GetModuleFileName should return 0\n");
4759 ok(GetLastError() == 0xdeadbeef /* XP */ ||
4760 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
4761 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
4763 SetLastError(0xdeadbeef);
4764 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, ret1
- 2);
4765 ok(ret2
== ret1
- 2, "expected %u, got %u\n", ret1
- 2, ret2
);
4766 ok(GetLastError() == 0xdeadbeef /* XP */ ||
4767 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
4768 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
4770 SetLastError(0xdeadbeef);
4771 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, 0);
4772 ok(!ret2
, "expected 0, got %u\n", ret2
);
4773 ok(GetLastError() == 0xdeadbeef /* XP */ ||
4774 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
4775 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
4777 DestroyWindow(hwnd
);
4780 hwnd
= (HWND
)0xdeadbeef;
4781 SetLastError(0xdeadbeef);
4782 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
4783 ok(!ret1
, "expected 0, got %u\n", ret1
);
4784 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
4786 ret1
= GetModuleFileName(0, buf1
, sizeof(buf1
));
4787 hwnd
= GetDesktopWindow();
4788 ok(IsWindow(hwnd
), "got invalid desktop window %p\n", hwnd
);
4789 SetLastError(0xdeadbeef);
4790 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
4791 ok(!ret2
|| ret1
== ret2
/* vista */, "expected 0, got %u\n", ret2
);
4793 hwnd
= FindWindow("Shell_TrayWnd", NULL
);
4794 ok(IsWindow(hwnd
), "got invalid tray window %p\n", hwnd
);
4795 SetLastError(0xdeadbeef);
4796 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
4797 ok(!ret1
, "expected 0, got %u\n", ret1
);
4800 static void test_hwnd_message(void)
4802 static const WCHAR mainwindowclassW
[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
4803 static const WCHAR message_windowW
[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
4805 HWND parent
= 0, hwnd
, found
;
4808 /* HWND_MESSAGE is not supported below w2k, but win9x return != 0
4809 on CreateWindowExA and crash later in the test.
4810 Use UNICODE here to fail on win9x */
4811 hwnd
= CreateWindowExW(0, mainwindowclassW
, message_windowW
, WS_CAPTION
| WS_VISIBLE
,
4812 100, 100, 200, 200, HWND_MESSAGE
, 0, 0, NULL
);
4815 win_skip("CreateWindowExW with parent HWND_MESSAGE failed\n");
4819 ok( !GetParent(hwnd
), "GetParent should return 0 for message only windows\n" );
4823 HWND root
, desktop
= GetDesktopWindow();
4825 parent
= pGetAncestor(hwnd
, GA_PARENT
);
4826 ok(parent
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
4827 ok(parent
!= desktop
, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
4828 root
= pGetAncestor(hwnd
, GA_ROOT
);
4829 ok(root
== hwnd
, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
4830 ok( !pGetAncestor(parent
, GA_PARENT
), "parent shouldn't have a parent\n" );
4831 trace("parent %p root %p desktop %p\n", parent
, root
, desktop
);
4832 if (!GetClassNameA( parent
, buffer
, sizeof(buffer
) )) buffer
[0] = 0;
4833 ok( !lstrcmpi( buffer
, "Message" ), "wrong parent class '%s'\n", buffer
);
4834 GetWindowRect( parent
, &rect
);
4835 ok( rect
.left
== 0 && rect
.right
== 100 && rect
.top
== 0 && rect
.bottom
== 100,
4836 "wrong parent rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
4838 GetWindowRect( hwnd
, &rect
);
4839 ok( rect
.left
== 100 && rect
.right
== 300 && rect
.top
== 100 && rect
.bottom
== 300,
4840 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
4842 /* test FindWindow behavior */
4844 found
= FindWindowExA( 0, 0, 0, "message window" );
4845 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
4846 SetLastError(0xdeadbeef);
4847 found
= FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
4848 ok( found
== 0, "found message window %p/%p\n", found
, hwnd
);
4849 ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %d\n", GetLastError() );
4852 found
= FindWindowExA( parent
, 0, 0, "message window" );
4853 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
4856 /* test IsChild behavior */
4858 if (parent
) ok( !IsChild( parent
, hwnd
), "HWND_MESSAGE is child of top window\n" );
4860 /* test IsWindowVisible behavior */
4862 ok( !IsWindowVisible( hwnd
), "HWND_MESSAGE window is visible\n" );
4863 if (parent
) ok( !IsWindowVisible( parent
), "HWND_MESSAGE parent is visible\n" );
4865 DestroyWindow(hwnd
);
4868 static void test_layered_window(void)
4876 if (!pGetLayeredWindowAttributes
|| !pSetLayeredWindowAttributes
)
4878 win_skip( "layered windows not supported\n" );
4881 hwnd
= CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION
,
4882 100, 100, 200, 200, 0, 0, 0, NULL
);
4884 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4885 ok( !ret
, "GetLayeredWindowAttributes should fail on non-layered window\n" );
4886 ret
= pSetLayeredWindowAttributes( hwnd
, 0, 0, LWA_ALPHA
);
4887 ok( !ret
, "SetLayeredWindowAttributes should fail on non-layered window\n" );
4888 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
4889 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4890 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
4891 ret
= pSetLayeredWindowAttributes( hwnd
, 0x123456, 44, LWA_ALPHA
);
4892 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
4893 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4894 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
4895 ok( key
== 0x123456, "wrong color key %x\n", key
);
4896 ok( alpha
== 44, "wrong alpha %u\n", alpha
);
4897 ok( flags
== LWA_ALPHA
, "wrong flags %x\n", flags
);
4899 /* clearing WS_EX_LAYERED resets attributes */
4900 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
4901 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4902 ok( !ret
, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
4903 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
4904 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4905 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
4906 ret
= pSetLayeredWindowAttributes( hwnd
, 0x654321, 22, LWA_COLORKEY
| LWA_ALPHA
);
4907 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
4908 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4909 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
4910 ok( key
== 0x654321, "wrong color key %x\n", key
);
4911 ok( alpha
== 22, "wrong alpha %u\n", alpha
);
4912 ok( flags
== (LWA_COLORKEY
| LWA_ALPHA
), "wrong flags %x\n", flags
);
4914 ret
= pSetLayeredWindowAttributes( hwnd
, 0x888888, 33, LWA_COLORKEY
);
4915 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
4917 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4918 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
4919 ok( key
== 0x888888, "wrong color key %x\n", key
);
4920 /* alpha not changed on vista if LWA_ALPHA is not set */
4921 ok( alpha
== 22 || alpha
== 33, "wrong alpha %u\n", alpha
);
4922 ok( flags
== LWA_COLORKEY
, "wrong flags %x\n", flags
);
4924 /* color key always changed */
4925 ret
= pSetLayeredWindowAttributes( hwnd
, 0x999999, 44, 0 );
4926 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
4928 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4929 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
4930 ok( key
== 0x999999, "wrong color key %x\n", key
);
4931 ok( alpha
== 22 || alpha
== 44, "wrong alpha %u\n", alpha
);
4932 ok( flags
== 0, "wrong flags %x\n", flags
);
4934 /* default alpha is 0 */
4935 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
4936 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
4937 ret
= pSetLayeredWindowAttributes( hwnd
, 0x222222, 55, 0 );
4938 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
4939 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
4940 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
4941 ok( key
== 0x222222, "wrong color key %x\n", key
);
4942 ok( alpha
== 0 || alpha
== 55, "wrong alpha %u\n", alpha
);
4943 ok( flags
== 0, "wrong flags %x\n", flags
);
4945 DestroyWindow( hwnd
);
4948 static MONITORINFO mi
;
4950 static LRESULT CALLBACK
fullscreen_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
4956 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
4957 trace("WM_NCCREATE: rect %d,%d-%d,%d\n", cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
4958 ok(cs
->x
== mi
.rcMonitor
.left
&& cs
->y
== mi
.rcMonitor
.top
&&
4959 cs
->cx
== mi
.rcMonitor
.right
&& cs
->cy
== mi
.rcMonitor
.bottom
,
4960 "expected %d,%d-%d,%d, got %d,%d-%d,%d\n",
4961 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
4962 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
4965 case WM_GETMINMAXINFO
:
4967 MINMAXINFO
*minmax
= (MINMAXINFO
*)lp
;
4968 dump_minmax_info(minmax
);
4969 ok(minmax
->ptMaxPosition
.x
<= mi
.rcMonitor
.left
, "%d <= %d\n", minmax
->ptMaxPosition
.x
, mi
.rcMonitor
.left
);
4970 ok(minmax
->ptMaxPosition
.y
<= mi
.rcMonitor
.top
, "%d <= %d\n", minmax
->ptMaxPosition
.y
, mi
.rcMonitor
.top
);
4971 ok(minmax
->ptMaxSize
.x
>= mi
.rcMonitor
.right
, "%d >= %d\n", minmax
->ptMaxSize
.x
, mi
.rcMonitor
.right
);
4972 ok(minmax
->ptMaxSize
.y
>= mi
.rcMonitor
.bottom
, "%d >= %d\n", minmax
->ptMaxSize
.y
, mi
.rcMonitor
.bottom
);
4976 return DefWindowProc(hwnd
, msg
, wp
, lp
);
4979 static void test_fullscreen(void)
4981 static const DWORD t_style
[] = {
4982 WS_OVERLAPPED
, WS_POPUP
, WS_CHILD
, WS_THICKFRAME
, WS_DLGFRAME
4984 static const DWORD t_ex_style
[] = {
4985 0, WS_EX_APPWINDOW
, WS_EX_TOOLWINDOW
4995 if (!pGetMonitorInfoA
|| !pMonitorFromPoint
)
4997 win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
5002 SetLastError(0xdeadbeef);
5003 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
5004 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
5006 mi
.cbSize
= sizeof(mi
);
5007 SetLastError(0xdeadbeef);
5008 ret
= pGetMonitorInfoA(hmon
, &mi
);
5009 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
5010 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
5011 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
5012 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
5015 cls
.lpfnWndProc
= fullscreen_wnd_proc
;
5018 cls
.hInstance
= GetModuleHandle(0);
5020 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
5021 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5022 cls
.lpszMenuName
= NULL
;
5023 cls
.lpszClassName
= "fullscreen_class";
5024 RegisterClass(&cls
);
5026 for (i
= 0; i
< sizeof(t_style
)/sizeof(t_style
[0]); i
++)
5028 DWORD style
, ex_style
;
5030 /* avoid a WM interaction */
5031 assert(!(t_style
[i
] & WS_VISIBLE
));
5033 for (j
= 0; j
< sizeof(t_ex_style
)/sizeof(t_ex_style
[0]); j
++)
5038 ex_style
= t_ex_style
[j
];
5040 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
5041 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
5042 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
5043 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
5044 GetWindowRect(hwnd
, &rc
);
5045 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5046 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
5047 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
5048 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5049 DestroyWindow(hwnd
);
5051 style
= t_style
[i
] | WS_MAXIMIZE
;
5052 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
5053 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
5054 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
5055 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
5056 GetWindowRect(hwnd
, &rc
);
5057 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5058 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
5059 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
5060 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5061 DestroyWindow(hwnd
);
5063 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
;
5064 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
5065 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
5066 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
5067 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
5068 GetWindowRect(hwnd
, &rc
);
5069 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5070 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
5071 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
5072 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5073 DestroyWindow(hwnd
);
5075 style
= t_style
[i
] | WS_CAPTION
| WS_MAXIMIZEBOX
;
5076 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
5077 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
5078 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
5079 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
5080 GetWindowRect(hwnd
, &rc
);
5081 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5082 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
5083 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
5084 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5085 DestroyWindow(hwnd
);
5087 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
| WS_MAXIMIZEBOX
;
5088 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
5089 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
5090 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
5091 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
5092 GetWindowRect(hwnd
, &rc
);
5093 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5094 /* Windows makes a maximized window slightly larger (to hide the borders?) */
5095 fixup
= min(abs(rc
.left
), abs(rc
.top
));
5096 InflateRect(&rc
, -fixup
, -fixup
);
5097 /* FIXME: this doesn't work correctly in Wine for child windows yet */
5098 if (style
& WS_CHILD
)
5100 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
5101 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
5102 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5104 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
5105 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
5106 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5107 DestroyWindow(hwnd
);
5109 style
= t_style
[i
] | WS_MAXIMIZE
| WS_MAXIMIZEBOX
;
5110 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
5111 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
5112 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
5113 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
5114 GetWindowRect(hwnd
, &rc
);
5115 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5116 /* Windows makes a maximized window slightly larger (to hide the borders?) */
5117 fixup
= min(abs(rc
.left
), abs(rc
.top
));
5118 InflateRect(&rc
, -fixup
, -fixup
);
5119 if (style
& (WS_CHILD
| WS_POPUP
))
5120 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
5121 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
5122 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5124 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
5125 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
5126 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5127 DestroyWindow(hwnd
);
5131 UnregisterClass("fullscreen_class", GetModuleHandle(0));
5134 static BOOL test_thick_child_got_minmax
;
5136 static int getExpectedThickChildInc(void)
5138 const int outer
= 2;
5139 int resizeBorder
= GetSystemMetrics(SM_CXFRAME
) - GetSystemMetrics(SM_CXDLGFRAME
);
5140 return (outer
+ resizeBorder
);
5143 static LRESULT WINAPI
test_thick_child_size_winproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
5146 int expectedMinTrack
;
5147 int actualMinTrackX
;
5148 int actualMinTrackY
;
5149 int expectedMaxTrackX
;
5150 int expectedMaxTrackY
;
5151 int actualMaxTrackX
;
5152 int actualMaxTrackY
;
5153 int expectedMaxSizeX
;
5154 int expectedMaxSizeY
;
5164 case WM_GETMINMAXINFO
:
5166 minmax
= (MINMAXINFO
*)lparam
;
5167 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
5168 dump_minmax_info( minmax
);
5170 test_thick_child_got_minmax
= TRUE
;
5172 expectedMinTrack
= 2* getExpectedThickChildInc();
5173 actualMinTrackX
= minmax
->ptMinTrackSize
.x
;
5174 actualMinTrackY
= minmax
->ptMinTrackSize
.y
;
5176 ok(actualMinTrackX
== expectedMinTrack
&& actualMinTrackY
== expectedMinTrack
,
5177 "expected minTrack %dx%d, actual minTrack %dx%d\n",
5178 expectedMinTrack
, expectedMinTrack
, actualMinTrackX
, actualMinTrackY
);
5180 actualMaxTrackX
= minmax
->ptMaxTrackSize
.x
;
5181 actualMaxTrackY
= minmax
->ptMaxTrackSize
.y
;
5182 expectedMaxTrackX
= GetSystemMetrics(SM_CXMAXTRACK
);
5183 expectedMaxTrackY
= GetSystemMetrics(SM_CYMAXTRACK
);
5184 ok(actualMaxTrackX
== expectedMaxTrackX
&& actualMaxTrackY
== expectedMaxTrackY
,
5185 "expected maxTrack %dx%d, actual maxTrack %dx%d\n",
5186 expectedMaxTrackX
, expectedMaxTrackY
, actualMaxTrackX
, actualMaxTrackY
);
5188 GetClientRect(GetParent(hwnd
), &rect
);
5189 AdjustWindowRectEx(&rect
, WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
, FALSE
, 0);
5190 expectedMaxSizeX
= rect
.right
- rect
.left
;
5191 expectedMaxSizeY
= rect
.bottom
- rect
.top
;
5192 actualMaxSizeX
= minmax
->ptMaxSize
.x
;
5193 actualMaxSizeY
= minmax
->ptMaxSize
.y
;
5194 ok(actualMaxSizeX
== expectedMaxSizeX
&& actualMaxSizeY
== expectedMaxSizeY
,
5195 "expected maxTrack %dx%d, actual maxTrack %dx%d\n",
5196 expectedMaxSizeX
, expectedMaxSizeY
, actualMaxSizeX
, actualMaxSizeY
);
5198 expectedPosX
= - getExpectedThickChildInc();
5199 expectedPosY
= expectedPosX
;
5200 actualPosX
= minmax
->ptMaxPosition
.x
;
5201 actualPosY
= minmax
->ptMaxPosition
.y
;
5203 ok(actualPosX
== expectedPosX
&& actualPosY
== expectedPosY
,
5204 "expected maxPosition (%d/%d), actual maxPosition (%d/%d)\n",
5205 expectedPosX
, expectedPosY
, actualPosX
, actualPosY
);
5210 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
5213 static void test_thick_child_size(HWND parentWindow
)
5221 LPCTSTR className
= "THICK_CHILD_CLASS";
5222 LONG style
= WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
;
5224 int expectedSize
= 2*getExpectedThickChildInc();
5228 cls
.lpfnWndProc
= test_thick_child_size_winproc
;
5231 cls
.hInstance
= GetModuleHandleA(0);
5233 cls
.hCursor
= LoadCursorA(0, (LPSTR
)IDC_ARROW
);
5234 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5235 cls
.lpszMenuName
= NULL
;
5236 cls
.lpszClassName
= className
;
5237 SetLastError(0xdeadbeef);
5238 ok(RegisterClassA(&cls
),"RegisterClassA failed, error: %u\n", GetLastError());
5240 test_thick_child_got_minmax
= FALSE
;
5242 SetLastError(0xdeadbeef);
5243 childWindow
= CreateWindowEx( exStyle
, className
, "", style
, 0, 0, 0, 0, parentWindow
, 0, GetModuleHandleA(0), NULL
);
5244 ok(childWindow
!= NULL
, "Failed to create child window, error: %u\n", GetLastError());
5246 ok(test_thick_child_got_minmax
, "Got no WM_GETMINMAXINFO\n");
5248 SetLastError(0xdeadbeef);
5249 success
= GetWindowRect(childWindow
, &childRect
);
5250 ok(success
,"GetWindowRect call failed, error: %u\n", GetLastError());
5251 childWidth
= childRect
.right
- childRect
.left
;
5252 childHeight
= childRect
.bottom
- childRect
.top
;
5255 ok( (childWidth
== expectedSize
) && (childHeight
== expectedSize
),
5256 "size of window with style WS_CHILD | WS_VISIBLE | WS_THICKFRAME is wrong: expected size %dx%d != actual size %dx%d\n",
5257 expectedSize
, expectedSize
, childWidth
, childHeight
);
5260 SetLastError(0xdeadbeef);
5261 success
= DestroyWindow(childWindow
);
5262 ok(success
,"DestroyWindow call failed, error: %u\n", GetLastError());
5263 ok(UnregisterClass(className
, GetModuleHandleA(0)),"UnregisterClass call failed\n");
5269 HMODULE user32
= GetModuleHandleA( "user32.dll" );
5270 pGetAncestor
= (void *)GetProcAddress( user32
, "GetAncestor" );
5271 pGetWindowInfo
= (void *)GetProcAddress( user32
, "GetWindowInfo" );
5272 pGetWindowModuleFileNameA
= (void *)GetProcAddress( user32
, "GetWindowModuleFileNameA" );
5273 pGetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "GetLayeredWindowAttributes" );
5274 pSetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "SetLayeredWindowAttributes" );
5275 pGetMonitorInfoA
= (void *)GetProcAddress( user32
, "GetMonitorInfoA" );
5276 pMonitorFromPoint
= (void *)GetProcAddress( user32
, "MonitorFromPoint" );
5278 if (!RegisterWindowClasses()) assert(0);
5280 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
5283 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
5284 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
5285 WS_MAXIMIZEBOX
| WS_POPUP
,
5287 0, 0, GetModuleHandle(0), NULL
);
5288 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
5289 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
5290 WS_MAXIMIZEBOX
| WS_POPUP
,
5292 0, 0, GetModuleHandle(0), NULL
);
5294 assert( hwndMain2
);
5296 our_pid
= GetWindowThreadProcessId(hwndMain
, NULL
);
5298 /* Add the tests below this line */
5299 test_thick_child_size(hwndMain
);
5301 test_hwnd_message();
5302 test_nonclient_area(hwndMain
);
5304 test_GetWindowModuleFileName();
5307 test_capture_3(hwndMain
, hwndMain2
);
5309 test_CreateWindow();
5310 test_parent_owner();
5315 test_SetWindowPos(hwndMain
);
5316 test_SetMenu(hwndMain
);
5317 test_SetFocus(hwndMain
);
5318 test_SetActiveWindow(hwndMain
);
5320 test_children_zorder(hwndMain
);
5321 test_popup_zorder(hwndMain2
, hwndMain
);
5322 test_keyboard_input(hwndMain
);
5323 test_mouse_input(hwndMain
);
5324 test_validatergn(hwndMain
);
5325 test_nccalcscroll( hwndMain
);
5326 test_scrollvalidate( hwndMain
);
5327 test_scrolldc( hwndMain
);
5329 test_IsWindowUnicode();
5330 test_vis_rgn(hwndMain
);
5332 test_AdjustWindowRect();
5333 test_window_styles();
5336 test_SetWindowLong();
5338 if (0) test_gettext(); /* crashes on NT4 */
5339 test_GetUpdateRect();
5341 test_layered_window();
5343 test_SetForegroundWindow(hwndMain
);
5344 test_shell_window();
5346 /* add the tests above this line */
5347 UnhookWindowsHookEx(hhook
);