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
*pUpdateLayeredWindow
)(HWND
,HDC
,POINT
*,SIZE
*,HDC
,POINT
*,COLORREF
,BLENDFUNCTION
*,DWORD
);
53 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
54 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
55 static int (WINAPI
*pGetWindowRgnBox
)(HWND
,LPRECT
);
56 static BOOL (WINAPI
*pGetGUIThreadInfo
)(DWORD
, GUITHREADINFO
*);
57 static BOOL (WINAPI
*pGetProcessDefaultLayout
)( DWORD
*layout
);
58 static BOOL (WINAPI
*pSetProcessDefaultLayout
)( DWORD layout
);
59 static BOOL (WINAPI
*pFlashWindowEx
)( PFLASHWINFO pfwi
);
60 static DWORD (WINAPI
*pSetLayout
)(HDC hdc
, DWORD layout
);
61 static DWORD (WINAPI
*pGetLayout
)(HDC hdc
);
62 static BOOL (WINAPI
*pMirrorRgn
)(HWND hwnd
, HRGN hrgn
);
64 static BOOL test_lbuttondown_flag
;
65 static HWND hwndMessage
;
66 static HWND hwndMain
, hwndMain2
;
69 static const char* szAWRClass
= "Winsize";
73 static BOOL is_win9x
= FALSE
;
75 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
77 static void dump_minmax_info( const MINMAXINFO
*minmax
)
79 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
80 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
81 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
82 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
83 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
84 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
87 /* try to make sure pending X events have been processed before continuing */
88 static void flush_events( BOOL remove_messages
)
92 int min_timeout
= 100;
93 DWORD time
= GetTickCount() + diff
;
97 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
99 while (PeekMessage( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage( &msg
);
100 diff
= time
- GetTickCount();
105 /* check the values returned by the various parent/owner functions on a given window */
106 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
107 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
113 res
= pGetAncestor( hwnd
, GA_PARENT
);
114 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
116 res
= (HWND
)GetWindowLongPtrA( hwnd
, GWLP_HWNDPARENT
);
117 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
118 res
= GetParent( hwnd
);
119 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
120 res
= GetWindow( hwnd
, GW_OWNER
);
121 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
124 res
= pGetAncestor( hwnd
, GA_ROOT
);
125 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
126 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
127 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
131 #define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
132 static void check_wnd_state_(const char *file
, int line
,
133 HWND active
, HWND foreground
, HWND focus
, HWND capture
)
135 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
136 /* only check foreground if it belongs to the current thread */
137 /* foreground can be moved to a different app pretty much at any time */
138 if (foreground
&& GetForegroundWindow() &&
139 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
140 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
141 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
142 ok_(file
, line
)(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
145 /* same as above but without capture test */
146 #define check_active_state(a,b,c) check_active_state_(__FILE__,__LINE__,a,b,c)
147 static void check_active_state_(const char *file
, int line
,
148 HWND active
, HWND foreground
, HWND focus
)
150 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
151 /* only check foreground if it belongs to the current thread */
152 /* foreground can be moved to a different app pretty much at any time */
153 if (foreground
&& GetForegroundWindow() &&
154 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
155 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
156 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
159 static BOOL
ignore_message( UINT message
)
161 /* these are always ignored */
162 return (message
>= 0xc000 ||
163 message
== WM_GETICON
||
164 message
== WM_GETOBJECT
||
165 message
== WM_TIMECHANGE
||
166 message
== WM_DEVICECHANGE
);
169 static BOOL CALLBACK
EnumChildProc( HWND hwndChild
, LPARAM lParam
)
172 trace("EnumChildProc on %p\n", hwndChild
);
173 if (*(LPINT
)lParam
> 1) return FALSE
;
177 /* will search for the given window */
178 static BOOL CALLBACK
EnumChildProc1( HWND hwndChild
, LPARAM lParam
)
180 trace("EnumChildProc1 on %p\n", hwndChild
);
181 if ((HWND
)lParam
== hwndChild
) return FALSE
;
185 static HWND
create_tool_window( LONG style
, HWND parent
)
187 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
188 0, 0, 100, 100, parent
, 0, 0, NULL
);
189 ok( ret
!= 0, "Creation failed\n" );
193 /* test parent and owner values for various combinations */
194 static void test_parent_owner(void)
197 HWND test
, owner
, ret
;
198 HWND desktop
= GetDesktopWindow();
199 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
202 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
204 /* child without parent, should fail */
205 SetLastError(0xdeadbeef);
206 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
207 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
208 ok( !test
, "WS_CHILD without parent created\n" );
209 ok( GetLastError() == ERROR_TLW_WITH_WSCHILD
||
210 broken(GetLastError() == 0xdeadbeef), /* win9x */
211 "CreateWindowExA error %u\n", GetLastError() );
214 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
215 style
= GetWindowLongA( desktop
, GWL_STYLE
);
216 ok( !SetWindowLongA( desktop
, GWL_STYLE
, WS_POPUP
), "Set GWL_STYLE on desktop succeeded\n" );
217 ok( !SetWindowLongA( desktop
, GWL_STYLE
, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
218 ok( GetWindowLongA( desktop
, GWL_STYLE
) == style
, "Desktop style changed\n" );
220 /* normal child window */
221 test
= create_tool_window( WS_CHILD
, hwndMain
);
222 trace( "created child %p\n", test
);
223 check_parents( test
, hwndMain
, hwndMain
, hwndMain
, 0, hwndMain
, hwndMain
);
224 SetWindowLongA( test
, GWL_STYLE
, 0 );
225 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
226 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
227 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
228 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
229 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
230 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
231 DestroyWindow( test
);
233 /* normal child window with WS_MAXIMIZE */
234 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
235 DestroyWindow( test
);
237 /* normal child window with WS_THICKFRAME */
238 test
= create_tool_window( WS_CHILD
| WS_THICKFRAME
, hwndMain
);
239 DestroyWindow( test
);
241 /* popup window with WS_THICKFRAME */
242 test
= create_tool_window( WS_POPUP
| WS_THICKFRAME
, hwndMain
);
243 DestroyWindow( test
);
245 /* child of desktop */
246 test
= create_tool_window( WS_CHILD
, desktop
);
247 trace( "created child of desktop %p\n", test
);
248 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
249 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
250 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
251 SetWindowLongA( test
, GWL_STYLE
, 0 );
252 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
253 DestroyWindow( test
);
255 /* child of desktop with WS_MAXIMIZE */
256 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, desktop
);
257 DestroyWindow( test
);
259 /* child of desktop with WS_MINIMIZE */
260 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, desktop
);
261 DestroyWindow( test
);
264 test
= create_tool_window( WS_CHILD
, child
);
265 trace( "created child of child %p\n", test
);
266 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
267 SetWindowLongA( test
, GWL_STYLE
, 0 );
268 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
269 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
270 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
271 DestroyWindow( test
);
273 /* child of child with WS_MAXIMIZE */
274 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, child
);
275 DestroyWindow( test
);
277 /* child of child with WS_MINIMIZE */
278 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, child
);
279 DestroyWindow( test
);
281 /* not owned top-level window */
282 test
= create_tool_window( 0, 0 );
283 trace( "created top-level %p\n", test
);
284 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
285 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
286 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
287 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
288 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
289 DestroyWindow( test
);
291 /* not owned top-level window with WS_MAXIMIZE */
292 test
= create_tool_window( WS_MAXIMIZE
, 0 );
293 DestroyWindow( test
);
295 /* owned top-level window */
296 test
= create_tool_window( 0, hwndMain
);
297 trace( "created owned top-level %p\n", test
);
298 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
299 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
300 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
301 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
302 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
303 DestroyWindow( test
);
305 /* owned top-level window with WS_MAXIMIZE */
306 test
= create_tool_window( WS_MAXIMIZE
, hwndMain
);
307 DestroyWindow( test
);
309 /* not owned popup */
310 test
= create_tool_window( WS_POPUP
, 0 );
311 trace( "created popup %p\n", test
);
312 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
313 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
314 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
315 SetWindowLongA( test
, GWL_STYLE
, 0 );
316 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
317 DestroyWindow( test
);
319 /* not owned popup with WS_MAXIMIZE */
320 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, 0 );
321 DestroyWindow( test
);
324 test
= create_tool_window( WS_POPUP
, hwndMain
);
325 trace( "created owned popup %p\n", test
);
326 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
327 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
328 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
329 SetWindowLongA( test
, GWL_STYLE
, 0 );
330 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
331 DestroyWindow( test
);
333 /* owned popup with WS_MAXIMIZE */
334 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, hwndMain
);
335 DestroyWindow( test
);
337 /* top-level window owned by child (same as owned by top-level) */
338 test
= create_tool_window( 0, child
);
339 trace( "created top-level owned by child %p\n", test
);
340 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
341 DestroyWindow( test
);
343 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
344 test
= create_tool_window( WS_MAXIMIZE
, child
);
345 DestroyWindow( test
);
347 /* popup owned by desktop (same as not owned) */
348 test
= create_tool_window( WS_POPUP
, desktop
);
349 trace( "created popup owned by desktop %p\n", test
);
350 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
351 DestroyWindow( test
);
353 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
354 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, desktop
);
355 DestroyWindow( test
);
357 /* popup owned by child (same as owned by top-level) */
358 test
= create_tool_window( WS_POPUP
, child
);
359 trace( "created popup owned by child %p\n", test
);
360 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
361 DestroyWindow( test
);
363 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
364 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, child
);
365 DestroyWindow( test
);
367 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
368 test
= create_tool_window( WS_POPUP
| WS_CHILD
, 0 );
369 trace( "created WS_CHILD popup %p\n", test
);
370 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
371 DestroyWindow( test
);
373 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
374 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, 0 );
375 DestroyWindow( test
);
377 /* owned popup with WS_CHILD (same as WS_POPUP only) */
378 test
= create_tool_window( WS_POPUP
| WS_CHILD
, hwndMain
);
379 trace( "created owned WS_CHILD popup %p\n", test
);
380 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
381 DestroyWindow( test
);
383 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
384 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
385 DestroyWindow( test
);
387 /******************** parent changes *************************/
388 trace( "testing parent changes\n" );
391 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
394 /* this test succeeds on NT but crashes on win9x systems */
395 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
396 ok( !ret
, "Set GWL_HWNDPARENT succeeded on desktop\n" );
397 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
398 ok( !SetParent( desktop
, hwndMain
), "SetParent succeeded on desktop\n" );
399 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
401 /* normal child window */
402 test
= create_tool_window( WS_CHILD
, hwndMain
);
403 trace( "created child %p\n", test
);
405 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
406 ok( ret
== hwndMain
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain
);
407 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
409 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
410 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
411 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
413 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)desktop
);
414 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
415 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
417 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
420 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)test
);
421 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
422 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
425 win_skip("Test creates circular window tree under Win9x/WinMe\n" );
427 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
428 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
429 check_parents( test
, desktop
, child
, desktop
, child
, test
, desktop
);
431 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
432 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
433 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
434 DestroyWindow( test
);
436 /* not owned top-level window */
437 test
= create_tool_window( 0, 0 );
438 trace( "created top-level %p\n", test
);
440 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
441 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
442 check_parents( test
, desktop
, hwndMain2
, 0, hwndMain2
, test
, test
);
444 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
445 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
446 check_parents( test
, desktop
, child
, 0, child
, test
, test
);
448 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
449 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
450 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
451 DestroyWindow( test
);
453 /* not owned popup */
454 test
= create_tool_window( WS_POPUP
, 0 );
455 trace( "created popup %p\n", test
);
457 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
458 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
459 check_parents( test
, desktop
, hwndMain2
, hwndMain2
, hwndMain2
, test
, hwndMain2
);
461 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
462 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
463 check_parents( test
, desktop
, child
, child
, child
, test
, hwndMain
);
465 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
466 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
467 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
468 DestroyWindow( test
);
470 /* normal child window */
471 test
= create_tool_window( WS_CHILD
, hwndMain
);
472 trace( "created child %p\n", test
);
474 ret
= SetParent( test
, desktop
);
475 ok( ret
== hwndMain
, "SetParent return value %p expected %p\n", ret
, hwndMain
);
476 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
478 ret
= SetParent( test
, child
);
479 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
480 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
482 ret
= SetParent( test
, hwndMain2
);
483 ok( ret
== child
, "SetParent return value %p expected %p\n", ret
, child
);
484 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
485 DestroyWindow( test
);
487 /* not owned top-level window */
488 test
= create_tool_window( 0, 0 );
489 trace( "created top-level %p\n", test
);
491 ret
= SetParent( test
, child
);
492 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
493 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
497 ShowWindow( test
, SW_SHOW
);
498 ret
= SetParent( test
, test
);
499 ok( ret
== NULL
, "SetParent return value %p expected %p\n", ret
, NULL
);
500 ok( GetWindowLongA( test
, GWL_STYLE
) & WS_VISIBLE
, "window is not visible after SetParent\n" );
501 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
504 win_skip( "Test crashes on Win9x/WinMe\n" );
505 DestroyWindow( test
);
508 test
= create_tool_window( WS_POPUP
, hwndMain2
);
509 trace( "created owned popup %p\n", test
);
511 ret
= SetParent( test
, child
);
512 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
513 check_parents( test
, child
, child
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
515 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)hwndMain
);
516 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
517 check_parents( test
, hwndMain
, hwndMain
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
518 DestroyWindow( test
);
520 /**************** test owner destruction *******************/
522 /* owned child popup */
523 owner
= create_tool_window( 0, 0 );
524 test
= create_tool_window( WS_POPUP
, owner
);
525 trace( "created owner %p and popup %p\n", owner
, test
);
526 ret
= SetParent( test
, child
);
527 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
528 check_parents( test
, child
, child
, owner
, owner
, hwndMain
, owner
);
529 /* window is now child of 'child' but owned by 'owner' */
530 DestroyWindow( owner
);
531 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
532 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
533 * while Win95, Win2k, WinXP do.
535 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
536 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
539 /* owned top-level popup */
540 owner
= create_tool_window( 0, 0 );
541 test
= create_tool_window( WS_POPUP
, owner
);
542 trace( "created owner %p and popup %p\n", owner
, test
);
543 check_parents( test
, desktop
, owner
, owner
, owner
, test
, owner
);
544 DestroyWindow( owner
);
545 ok( !IsWindow(test
), "Window %p not destroyed by owner destruction\n", test
);
547 /* top-level popup owned by child */
548 owner
= create_tool_window( WS_CHILD
, hwndMain2
);
549 test
= create_tool_window( WS_POPUP
, 0 );
550 trace( "created owner %p and popup %p\n", owner
, test
);
551 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)owner
);
552 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
553 check_parents( test
, desktop
, owner
, owner
, owner
, test
, hwndMain2
);
554 DestroyWindow( owner
);
555 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
556 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
557 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
558 * while Win95, Win2k, WinXP do.
560 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
564 DestroyWindow(child
);
567 owner
= create_tool_window( WS_OVERLAPPED
, 0 );
568 test
= create_tool_window( WS_POPUP
, desktop
);
570 ok( !GetWindow( test
, GW_OWNER
), "Wrong owner window\n" );
572 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
573 "EnumChildWindows should have returned FALSE\n" );
574 ok( numChildren
== 0, "numChildren should be 0 got %d\n", numChildren
);
576 SetWindowLongA( test
, GWL_STYLE
, (GetWindowLongA( test
, GWL_STYLE
) & ~WS_POPUP
) | WS_CHILD
);
577 ret
= SetParent( test
, owner
);
578 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
581 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
582 "EnumChildWindows should have returned TRUE\n" );
583 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
585 child
= create_tool_window( WS_CHILD
, owner
);
587 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
588 "EnumChildWindows should have returned FALSE\n" );
589 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
590 DestroyWindow( child
);
592 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
593 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
595 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
596 "EnumChildWindows should have returned TRUE\n" );
597 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
599 ret
= SetParent( child
, owner
);
600 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
601 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
603 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
604 "EnumChildWindows should have returned FALSE\n" );
605 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
607 ret
= SetParent( child
, NULL
);
608 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
609 ok( ret
== owner
, "SetParent return value %p expected %p\n", ret
, owner
);
611 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
612 "EnumChildWindows should have returned TRUE\n" );
613 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
615 /* even GW_OWNER == owner it's still a desktop's child */
616 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
617 "EnumChildWindows should have found %p and returned FALSE\n", child
);
619 DestroyWindow( child
);
620 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, NULL
);
622 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
623 "EnumChildWindows should have found %p and returned FALSE\n", child
);
625 DestroyWindow( child
);
626 DestroyWindow( test
);
627 DestroyWindow( owner
);
630 static BOOL CALLBACK
enum_proc( HWND hwnd
, LPARAM lParam
)
633 if (*(LPINT
)lParam
> 2) return FALSE
;
636 static DWORD CALLBACK
enum_thread( void *arg
)
643 if (pGetGUIThreadInfo
)
646 info
.cbSize
= sizeof(info
);
647 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
648 ok( ret
|| broken(!ret
), /* win9x */
649 "GetGUIThreadInfo failed without message queue\n" );
650 SetLastError( 0xdeadbeef );
651 info
.cbSize
= sizeof(info
) + 1;
652 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
653 ok( !ret
, "GetGUIThreadInfo succeeded with wrong size\n" );
654 ok( GetLastError() == ERROR_INVALID_PARAMETER
||
655 broken(GetLastError() == 0xdeadbeef), /* win9x */
656 "wrong error %u\n", GetLastError() );
659 PeekMessage( &msg
, 0, 0, 0, PM_NOREMOVE
); /* make sure we have a message queue */
662 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
663 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
664 ok( count
== 0, "count should be 0 got %d\n", count
);
666 hwnd
[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP
,
667 0, 0, 100, 100, 0, 0, 0, NULL
);
669 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
670 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
671 if (count
!= 2) /* Vista gives us two windows for the price of one */
673 ok( count
== 1, "count should be 1 got %d\n", count
);
674 hwnd
[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP
,
675 0, 0, 100, 100, 0, 0, 0, NULL
);
679 hwnd
[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP
,
680 0, 0, 100, 100, 0, 0, 0, NULL
);
682 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
683 ok( !ret
, "EnumThreadWindows should have returned FALSE\n" );
684 ok( count
== 3, "count should be 3 got %d\n", count
);
686 if (hwnd
[2]) DestroyWindow(hwnd
[2]);
687 DestroyWindow(hwnd
[1]);
688 DestroyWindow(hwnd
[0]);
692 /* test EnumThreadWindows in a separate thread */
693 static void test_enum_thread_windows(void)
696 HANDLE handle
= CreateThread( NULL
, 0, enum_thread
, 0, 0, &id
);
697 ok( !WaitForSingleObject( handle
, 10000 ), "wait failed\n" );
698 CloseHandle( handle
);
701 static LRESULT WINAPI
main_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
705 case WM_GETMINMAXINFO
:
707 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
709 trace("WM_GETMINMAXINFO: hwnd %p, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
710 dump_minmax_info( minmax
);
711 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
714 case WM_WINDOWPOSCHANGING
:
716 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
717 trace("main: WM_WINDOWPOSCHANGING %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
718 winpos
->hwnd
, winpos
->hwndInsertAfter
,
719 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
720 if (!(winpos
->flags
& SWP_NOMOVE
))
722 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
723 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
725 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
726 if (!(winpos
->flags
& SWP_NOSIZE
) && !is_win9x
)
728 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
729 winpos
->cx
== 32768, /* win7 doesn't truncate */
730 "bad winpos->cx %d\n", winpos
->cx
);
731 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
732 winpos
->cy
== 40000, /* win7 doesn't truncate */
733 "bad winpos->cy %d\n", winpos
->cy
);
737 case WM_WINDOWPOSCHANGED
:
740 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
741 trace("main: WM_WINDOWPOSCHANGED %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
742 winpos
->hwnd
, winpos
->hwndInsertAfter
,
743 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
744 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
745 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
747 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
748 winpos
->cx
== 32768, /* win7 doesn't truncate */
749 "bad winpos->cx %d\n", winpos
->cx
);
750 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
751 winpos
->cy
== 40000, /* win7 doesn't truncate */
752 "bad winpos->cy %d\n", winpos
->cy
);
754 GetWindowRect(hwnd
, &rc1
);
755 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
756 /* note: winpos coordinates are relative to parent */
757 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
760 /* Uncomment this once the test succeeds in all cases */
761 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
762 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
764 GetClientRect(hwnd
, &rc2
);
765 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
766 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
767 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
768 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
774 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
775 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
777 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
778 if (got_getminmaxinfo
)
779 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
781 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
782 ok(got_getminmaxinfo
, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
784 ok(!got_getminmaxinfo
, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
788 if (test_lbuttondown_flag
)
790 ShowWindow((HWND
)wparam
, SW_SHOW
);
791 flush_events( FALSE
);
796 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
799 static LRESULT WINAPI
tool_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
803 case WM_GETMINMAXINFO
:
805 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
807 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
808 dump_minmax_info( minmax
);
809 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
814 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
815 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
817 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
818 if (got_getminmaxinfo
)
819 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
821 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
822 ok(got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
824 ok(!got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
829 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
832 static BOOL
RegisterWindowClasses(void)
836 cls
.style
= CS_DBLCLKS
;
837 cls
.lpfnWndProc
= main_window_procA
;
840 cls
.hInstance
= GetModuleHandleA(0);
842 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
843 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
844 cls
.lpszMenuName
= NULL
;
845 cls
.lpszClassName
= "MainWindowClass";
847 if(!RegisterClassA(&cls
)) return FALSE
;
850 cls
.lpfnWndProc
= tool_window_procA
;
853 cls
.hInstance
= GetModuleHandleA(0);
855 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
856 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
857 cls
.lpszMenuName
= NULL
;
858 cls
.lpszClassName
= "ToolWindowClass";
860 if(!RegisterClassA(&cls
)) return FALSE
;
865 static void verify_window_info(const char *hook
, HWND hwnd
, const WINDOWINFO
*info
)
867 RECT rcWindow
, rcClient
;
870 ok(IsWindow(hwnd
), "bad window handle %p in hook %s\n", hwnd
, hook
);
872 GetWindowRect(hwnd
, &rcWindow
);
873 ok(EqualRect(&rcWindow
, &info
->rcWindow
), "wrong rcWindow for %p in hook %s\n", hwnd
, hook
);
875 GetClientRect(hwnd
, &rcClient
);
876 /* translate to screen coordinates */
877 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rcClient
, 2);
878 ok(EqualRect(&rcClient
, &info
->rcClient
), "wrong rcClient for %p in hook %s\n", hwnd
, hook
);
880 ok(info
->dwStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_STYLE
),
881 "wrong dwStyle: %08x != %08x for %p in hook %s\n",
882 info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
), hwnd
, hook
);
883 /* Windows reports some undocumented exstyles in WINDOWINFO, but
884 * doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
886 ok((info
->dwExStyle
& ~0xe0000800) == (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
887 "wrong dwExStyle: %08x != %08x for %p in hook %s\n",
888 info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
), hwnd
, hook
);
889 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
890 if (GetForegroundWindow())
891 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04x != %04x active %p fg %p in hook %s\n",
892 info
->dwWindowStatus
, status
, GetActiveWindow(), GetForegroundWindow(), hook
);
894 /* win2k and XP return broken border info in GetWindowInfo most of
895 * the time, so there is no point in testing it.
899 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
900 "wrong cxWindowBorders %d != %d\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
901 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
902 ok(info
->cyWindowBorders
== border
,
903 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
905 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType for %p in hook %s\n",
907 ok(info
->wCreatorVersion
== 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
908 info
->wCreatorVersion
== 0x0500 /* Vista */,
909 "wrong wCreatorVersion %04x for %p in hook %s\n", info
->wCreatorVersion
, hwnd
, hook
);
912 static void FixedAdjustWindowRectEx(RECT
* rc
, LONG style
, BOOL menu
, LONG exstyle
)
914 AdjustWindowRectEx(rc
, style
, menu
, exstyle
);
915 /* AdjustWindowRectEx does not include scroll bars */
916 if (style
& WS_VSCROLL
)
918 if(exstyle
& WS_EX_LEFTSCROLLBAR
)
919 rc
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
921 rc
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
923 if (style
& WS_HSCROLL
)
924 rc
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
927 static void test_nonclient_area(HWND hwnd
)
929 DWORD style
, exstyle
;
930 RECT rc_window
, rc_client
, rc
;
934 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
935 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
936 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
938 GetWindowRect(hwnd
, &rc_window
);
939 GetClientRect(hwnd
, &rc_client
);
941 /* avoid some cases when things go wrong */
942 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
943 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
945 CopyRect(&rc
, &rc_client
);
946 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
947 FixedAdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
949 ok(EqualRect(&rc
, &rc_window
),
950 "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
951 style
, exstyle
, menu
, rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
,
952 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
955 CopyRect(&rc
, &rc_window
);
956 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
957 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
958 ok(EqualRect(&rc
, &rc_client
),
959 "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
960 style
, exstyle
, menu
, rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
,
961 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
963 /* NULL rectangle shouldn't crash */
964 ret
= DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, 0);
965 ok(ret
== 0, "NULL rectangle returned %ld instead of 0\n", ret
);
967 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
971 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
972 SetRect(&rc_client
, 0, 0, 250, 150);
973 CopyRect(&rc_window
, &rc_client
);
974 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
975 FixedAdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
977 CopyRect(&rc
, &rc_window
);
978 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
979 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
980 ok(EqualRect(&rc
, &rc_client
),
981 "synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
982 style
, exstyle
, menu
, rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
,
983 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
986 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
988 static const char *CBT_code_name
[10] = {
999 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
1000 HWND hwnd
= (HWND
)wParam
;
1004 case HCBT_CREATEWND
:
1006 static const RECT rc_null
;
1009 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
1010 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
1015 info
.cbSize
= sizeof(WINDOWINFO
);
1016 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1017 verify_window_info(code_name
, hwnd
, &info
);
1020 /* WS_VISIBLE should be turned off yet */
1021 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
1022 ok(style
== GetWindowLongA(hwnd
, GWL_STYLE
),
1023 "style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
1024 GetWindowLongA(hwnd
, GWL_STYLE
), style
);
1028 /* Uncomment this once the test succeeds in all cases */
1029 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1031 ok(GetParent(hwnd
) == hwndMessage
,
1032 "wrong result from GetParent %p: message window %p\n",
1033 GetParent(hwnd
), hwndMessage
);
1036 ok(!GetParent(hwnd
), "GetParent should return 0 at this point\n");
1038 ok(!GetWindow(hwnd
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
1042 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
1043 * Win9x still has them set to 0.
1045 ok(GetWindow(hwnd
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
1046 ok(GetWindow(hwnd
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
1048 ok(!GetWindow(hwnd
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
1049 ok(!GetWindow(hwnd
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
1053 /* Uncomment this once the test succeeds in all cases */
1056 ok(pGetAncestor(hwnd
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
1057 ok(pGetAncestor(hwnd
, GA_ROOT
) == hwnd
,
1058 "GA_ROOT is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOT
), hwnd
);
1060 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1061 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwndMessage
,
1062 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
1064 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwnd
,
1065 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOTOWNER
), hwnd
);
1068 ok(GetWindowRect(hwnd
, &rc
), "GetWindowRect failed\n");
1069 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
1070 ok(GetClientRect(hwnd
, &rc
), "GetClientRect failed\n");
1071 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
1078 if (pGetWindowInfo
&& IsWindow(hwnd
))
1082 /* Win98 actually does check the info.cbSize and doesn't allow
1083 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
1084 * WinXP do not check it at all.
1086 info
.cbSize
= sizeof(WINDOWINFO
);
1087 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1088 verify_window_info(code_name
, hwnd
, &info
);
1091 /* window state is undefined */
1093 case HCBT_DESTROYWND
:
1099 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
1102 static void test_shell_window(void)
1106 HMODULE hinst
, hUser32
;
1107 BOOL (WINAPI
*SetShellWindow
)(HWND
);
1108 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
1109 HWND shellWindow
, nextWnd
;
1113 win_skip("Skipping shell window test on Win9x\n");
1117 shellWindow
= GetShellWindow();
1118 hinst
= GetModuleHandle(0);
1119 hUser32
= GetModuleHandleA("user32");
1121 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
1123 trace("previous shell window: %p\n", shellWindow
);
1129 GetWindowThreadProcessId(shellWindow
, &pid
);
1130 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
1133 skip( "cannot get access to shell process\n" );
1137 SetLastError(0xdeadbeef);
1138 ret
= DestroyWindow(shellWindow
);
1139 error
= GetLastError();
1141 ok(!ret
, "DestroyWindow(shellWindow)\n");
1142 /* passes on Win XP, but not on Win98 */
1143 ok(error
==ERROR_ACCESS_DENIED
|| error
== 0xdeadbeef,
1144 "got %u after DestroyWindow(shellWindow)\n", error
);
1146 /* close old shell instance */
1147 ret
= TerminateProcess(hProcess
, 0);
1148 ok(ret
, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
1149 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
1150 CloseHandle(hProcess
);
1153 hwnd1
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
1154 trace("created window 1: %p\n", hwnd1
);
1156 ret
= SetShellWindow(hwnd1
);
1157 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
1158 shellWindow
= GetShellWindow();
1159 ok(shellWindow
==hwnd1
, "wrong shell window: %p\n", shellWindow
);
1161 ret
= SetShellWindow(hwnd1
);
1162 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
1164 ret
= SetShellWindow(0);
1165 error
= GetLastError();
1166 /* passes on Win XP, but not on Win98
1167 ok(!ret, "reset shell window by SetShellWindow(0)\n");
1168 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
1170 ret
= SetShellWindow(hwnd1
);
1171 /* passes on Win XP, but not on Win98
1172 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
1174 SetWindowLong(hwnd1
, GWL_EXSTYLE
, GetWindowLong(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
1175 ret
= GetWindowLong(hwnd1
,GWL_EXSTYLE
)&WS_EX_TOPMOST
? TRUE
: FALSE
;
1176 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
1178 ret
= DestroyWindow(hwnd1
);
1179 ok(ret
, "DestroyWindow(hwnd1)\n");
1181 hwnd2
= CreateWindowEx(WS_EX_TOPMOST
, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
1182 trace("created window 2: %p\n", hwnd2
);
1183 ret
= SetShellWindow(hwnd2
);
1184 ok(!ret
, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
1186 hwnd3
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
1187 trace("created window 3: %p\n", hwnd3
);
1189 hwnd4
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
1190 trace("created window 4: %p\n", hwnd4
);
1192 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1193 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd
);
1195 ret
= SetShellWindow(hwnd4
);
1196 ok(ret
, "SetShellWindow(hwnd4)\n");
1197 shellWindow
= GetShellWindow();
1198 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1200 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1201 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
1203 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1204 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1206 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1207 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
1209 ret
= SetShellWindow(hwnd3
);
1210 ok(!ret
, "SetShellWindow(hwnd3)\n");
1211 shellWindow
= GetShellWindow();
1212 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1214 hwnd5
= CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
1215 trace("created window 5: %p\n", hwnd5
);
1216 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1217 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
1221 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1222 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
1225 /* destroy test windows */
1226 DestroyWindow(hwnd2
);
1227 DestroyWindow(hwnd3
);
1228 DestroyWindow(hwnd4
);
1229 DestroyWindow(hwnd5
);
1232 /************** MDI test ****************/
1234 static char mdi_lParam_test_message
[] = "just a test string";
1236 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT_PTR first_id
)
1238 MDICREATESTRUCTA mdi_cs
;
1241 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1242 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
1243 BOOL isWin9x
= FALSE
;
1245 mdi_cs
.szClass
= "MDI_child_Class_1";
1246 mdi_cs
.szTitle
= "MDI child";
1247 mdi_cs
.hOwner
= GetModuleHandle(0);
1248 mdi_cs
.x
= CW_USEDEFAULT
;
1249 mdi_cs
.y
= CW_USEDEFAULT
;
1250 mdi_cs
.cx
= CW_USEDEFAULT
;
1251 mdi_cs
.cy
= CW_USEDEFAULT
;
1253 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1254 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1255 ok(mdi_child
!= 0, "MDI child creation failed\n");
1256 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1257 ok(id
== first_id
, "wrong child id %ld\n", id
);
1258 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1259 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1261 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
1262 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1263 ok(mdi_child
!= 0, "MDI child creation failed\n");
1264 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1265 ok(id
== first_id
, "wrong child id %ld\n", id
);
1266 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1267 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1269 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
1270 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1271 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1273 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1277 ok(mdi_child
!= 0, "MDI child creation failed\n");
1278 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1279 ok(id
== first_id
, "wrong child id %ld\n", id
);
1280 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1281 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1284 /* test MDICREATESTRUCT A<->W mapping */
1285 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1287 mdi_cs
.szClass
= (LPCSTR
)classW
;
1288 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
1289 SetLastError(0xdeadbeef);
1290 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1293 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1296 ok(mdi_child
!= 0, "MDI child creation failed\n");
1300 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1301 ok(id
== first_id
, "wrong child id %ld\n", id
);
1302 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1303 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1306 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1308 CW_USEDEFAULT
, CW_USEDEFAULT
,
1309 CW_USEDEFAULT
, CW_USEDEFAULT
,
1310 mdi_client
, GetModuleHandle(0),
1311 (LPARAM
)mdi_lParam_test_message
);
1312 ok(mdi_child
!= 0, "MDI child creation failed\n");
1313 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1314 ok(id
== first_id
, "wrong child id %ld\n", id
);
1315 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1316 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1318 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1319 0x7fffffff, /* without WS_POPUP */
1320 CW_USEDEFAULT
, CW_USEDEFAULT
,
1321 CW_USEDEFAULT
, CW_USEDEFAULT
,
1322 mdi_client
, GetModuleHandle(0),
1323 (LPARAM
)mdi_lParam_test_message
);
1324 ok(mdi_child
!= 0, "MDI child creation failed\n");
1325 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1326 ok(id
== first_id
, "wrong child id %ld\n", id
);
1327 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1328 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1330 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1331 0xffffffff, /* with WS_POPUP */
1332 CW_USEDEFAULT
, CW_USEDEFAULT
,
1333 CW_USEDEFAULT
, CW_USEDEFAULT
,
1334 mdi_client
, GetModuleHandle(0),
1335 (LPARAM
)mdi_lParam_test_message
);
1336 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1338 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1342 ok(mdi_child
!= 0, "MDI child creation failed\n");
1343 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1344 ok(id
== first_id
, "wrong child id %ld\n", id
);
1345 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1346 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1349 /* test MDICREATESTRUCT A<->W mapping */
1350 SetLastError(0xdeadbeef);
1351 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1353 CW_USEDEFAULT
, CW_USEDEFAULT
,
1354 CW_USEDEFAULT
, CW_USEDEFAULT
,
1355 mdi_client
, GetModuleHandle(0),
1356 (LPARAM
)mdi_lParam_test_message
);
1359 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1362 ok(mdi_child
!= 0, "MDI child creation failed\n");
1366 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1367 ok(id
== first_id
, "wrong child id %ld\n", id
);
1368 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1369 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1372 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1374 CW_USEDEFAULT
, CW_USEDEFAULT
,
1375 CW_USEDEFAULT
, CW_USEDEFAULT
,
1376 mdi_client
, 0, GetModuleHandle(0),
1377 mdi_lParam_test_message
);
1378 ok(mdi_child
!= 0, "MDI child creation failed\n");
1379 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1380 ok(id
== first_id
, "wrong child id %ld\n", id
);
1381 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1382 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1384 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1385 0x7fffffff, /* without WS_POPUP */
1386 CW_USEDEFAULT
, CW_USEDEFAULT
,
1387 CW_USEDEFAULT
, CW_USEDEFAULT
,
1388 mdi_client
, 0, GetModuleHandle(0),
1389 mdi_lParam_test_message
);
1390 ok(mdi_child
!= 0, "MDI child creation failed\n");
1391 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1392 ok(id
== first_id
, "wrong child id %ld\n", id
);
1393 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1394 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1396 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1397 0xffffffff, /* with WS_POPUP */
1398 CW_USEDEFAULT
, CW_USEDEFAULT
,
1399 CW_USEDEFAULT
, CW_USEDEFAULT
,
1400 mdi_client
, 0, GetModuleHandle(0),
1401 mdi_lParam_test_message
);
1402 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1404 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1408 ok(mdi_child
!= 0, "MDI child creation failed\n");
1409 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1410 ok(id
== first_id
, "wrong child id %ld\n", id
);
1411 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1412 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1415 /* test MDICREATESTRUCT A<->W mapping */
1416 SetLastError(0xdeadbeef);
1417 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1419 CW_USEDEFAULT
, CW_USEDEFAULT
,
1420 CW_USEDEFAULT
, CW_USEDEFAULT
,
1421 mdi_client
, 0, GetModuleHandle(0),
1422 mdi_lParam_test_message
);
1425 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1428 ok(mdi_child
!= 0, "MDI child creation failed\n");
1432 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1433 ok(id
== first_id
, "wrong child id %ld\n", id
);
1434 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1435 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1438 /* This test fails on Win9x */
1441 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1443 CW_USEDEFAULT
, CW_USEDEFAULT
,
1444 CW_USEDEFAULT
, CW_USEDEFAULT
,
1445 parent
, 0, GetModuleHandle(0),
1446 mdi_lParam_test_message
);
1447 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1450 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1451 WS_CHILD
, /* without WS_POPUP */
1452 CW_USEDEFAULT
, CW_USEDEFAULT
,
1453 CW_USEDEFAULT
, CW_USEDEFAULT
,
1454 mdi_client
, 0, GetModuleHandle(0),
1455 mdi_lParam_test_message
);
1456 ok(mdi_child
!= 0, "MDI child creation failed\n");
1457 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1458 ok(id
== 0, "wrong child id %ld\n", id
);
1459 DestroyWindow(mdi_child
);
1461 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1462 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1463 CW_USEDEFAULT
, CW_USEDEFAULT
,
1464 CW_USEDEFAULT
, CW_USEDEFAULT
,
1465 mdi_client
, 0, GetModuleHandle(0),
1466 mdi_lParam_test_message
);
1467 ok(mdi_child
!= 0, "MDI child creation failed\n");
1468 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1469 ok(id
== 0, "wrong child id %ld\n", id
);
1470 DestroyWindow(mdi_child
);
1472 /* maximized child */
1473 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1474 WS_CHILD
| WS_MAXIMIZE
,
1475 CW_USEDEFAULT
, CW_USEDEFAULT
,
1476 CW_USEDEFAULT
, CW_USEDEFAULT
,
1477 mdi_client
, 0, GetModuleHandle(0),
1478 mdi_lParam_test_message
);
1479 ok(mdi_child
!= 0, "MDI child creation failed\n");
1480 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1481 ok(id
== 0, "wrong child id %ld\n", id
);
1482 DestroyWindow(mdi_child
);
1484 trace("Creating maximized child with a caption\n");
1485 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1486 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1487 CW_USEDEFAULT
, CW_USEDEFAULT
,
1488 CW_USEDEFAULT
, CW_USEDEFAULT
,
1489 mdi_client
, 0, GetModuleHandle(0),
1490 mdi_lParam_test_message
);
1491 ok(mdi_child
!= 0, "MDI child creation failed\n");
1492 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1493 ok(id
== 0, "wrong child id %ld\n", id
);
1494 DestroyWindow(mdi_child
);
1496 trace("Creating maximized child with a caption and a thick frame\n");
1497 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1498 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1499 CW_USEDEFAULT
, CW_USEDEFAULT
,
1500 CW_USEDEFAULT
, CW_USEDEFAULT
,
1501 mdi_client
, 0, GetModuleHandle(0),
1502 mdi_lParam_test_message
);
1503 ok(mdi_child
!= 0, "MDI child creation failed\n");
1504 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1505 ok(id
== 0, "wrong child id %ld\n", id
);
1506 DestroyWindow(mdi_child
);
1509 /**********************************************************************
1510 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1512 * Note: The rule here is that client rect of the maximized MDI child
1513 * is equal to the client rect of the MDI client window.
1515 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1519 GetClientRect( client
, &rect
);
1520 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1521 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1523 rect
.right
-= rect
.left
;
1524 rect
.bottom
-= rect
.top
;
1525 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1526 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1528 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1529 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1531 trace("max rect (%d,%d - %d, %d)\n",
1532 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1535 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1542 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1543 MDICREATESTRUCTA
*mdi_cs
= cs
->lpCreateParams
;
1545 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1546 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1548 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1549 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1550 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1551 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1552 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1554 /* MDICREATESTRUCT should have original values */
1555 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff,
1556 "mdi_cs->style does not match (%08x)\n", mdi_cs
->style
);
1557 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1558 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1559 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1560 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1562 /* CREATESTRUCT should have fixed values */
1563 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1564 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1566 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1567 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1568 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1570 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1572 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1574 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1575 ok(cs
->style
== style
,
1576 "cs->style does not match (%08x)\n", cs
->style
);
1580 LONG style
= mdi_cs
->style
;
1582 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1583 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1584 ok(cs
->style
== style
,
1585 "cs->style does not match (%08x)\n", cs
->style
);
1590 case WM_GETMINMAXINFO
:
1592 HWND client
= GetParent(hwnd
);
1594 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1595 MINMAXINFO my_minmax
;
1596 LONG style
, exstyle
;
1598 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1599 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1601 GetWindowRect(client
, &rc
);
1602 trace("MDI client %p window size = (%d x %d)\n", client
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1603 GetClientRect(client
, &rc
);
1604 trace("MDI client %p client size = (%d x %d)\n", client
, rc
.right
, rc
.bottom
);
1605 trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN
),
1606 GetSystemMetrics(SM_CYSCREEN
));
1608 GetClientRect(client
, &rc
);
1609 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1610 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1611 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1612 trace("MDI child: calculated max window size = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1613 dump_minmax_info( minmax
);
1615 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1616 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1617 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1618 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1620 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1622 trace("DefMDIChildProc returned:\n");
1623 dump_minmax_info( minmax
);
1625 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1626 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %d != %d\n",
1627 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1628 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %d != %d\n",
1629 minmax
->ptMaxSize
.y
, my_minmax
.ptMaxSize
.y
);
1634 case WM_MDIACTIVATE
:
1636 HWND active
, client
= GetParent(hwnd
);
1637 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1638 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
1639 if (hwnd
== (HWND
)lparam
) /* if we are being activated */
1640 ok (active
== (HWND
)lparam
, "new active %p != active %p\n", (HWND
)lparam
, active
);
1642 ok (active
== (HWND
)wparam
, "old active %p != active %p\n", (HWND
)wparam
, active
);
1646 return DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1649 static LRESULT WINAPI
mdi_child_wnd_proc_2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1656 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1658 trace("%s: x %d, y %d, cx %d, cy %d\n", (msg
== WM_NCCREATE
) ? "WM_NCCREATE" : "WM_CREATE",
1659 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1661 ok(!(cs
->dwExStyle
& WS_EX_MDICHILD
), "WS_EX_MDICHILD should not be set\n");
1662 ok(cs
->lpCreateParams
== mdi_lParam_test_message
, "wrong cs->lpCreateParams\n");
1664 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_2"), "wrong class name\n");
1665 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1667 /* CREATESTRUCT should have fixed values */
1668 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1670 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1671 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1673 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1674 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1675 while Win95, Win2k, WinXP do. */
1676 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1677 ok(cs
->cy
== 0, "%d != 0\n", cs
->cy
);
1681 case WM_GETMINMAXINFO
:
1683 HWND parent
= GetParent(hwnd
);
1685 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1686 LONG style
, exstyle
;
1688 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1689 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1691 GetClientRect(parent
, &rc
);
1692 trace("WM_GETMINMAXINFO: parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
1694 GetClientRect(parent
, &rc
);
1695 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1696 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1697 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1698 dump_minmax_info( minmax
);
1700 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1701 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1702 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1703 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1707 case WM_WINDOWPOSCHANGED
:
1709 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1712 GetWindowRect(hwnd
, &rc1
);
1713 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1714 /* note: winpos coordinates are relative to parent */
1715 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1716 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=(%d,%d)-(%d,%d) pos=(%d,%d)-(%d,%d)\n",
1717 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
1718 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1719 GetWindowRect(hwnd
, &rc1
);
1720 GetClientRect(hwnd
, &rc2
);
1721 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1722 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1723 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
1724 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
1725 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1728 case WM_WINDOWPOSCHANGING
:
1730 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1731 WINDOWPOS my_winpos
= *winpos
;
1733 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1734 (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
1735 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1736 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1738 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1740 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1741 "DefWindowProc should not change WINDOWPOS: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1742 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1743 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1748 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1751 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1753 static HWND mdi_client
;
1759 CLIENTCREATESTRUCT client_cs
;
1762 GetClientRect(hwnd
, &rc
);
1764 client_cs
.hWindowMenu
= 0;
1765 client_cs
.idFirstChild
= 1;
1767 /* MDIClient without MDIS_ALLCHILDSTYLES */
1768 mdi_client
= CreateWindowExA(0, "mdiclient",
1770 WS_CHILD
/*| WS_VISIBLE*/,
1771 /* tests depend on a not zero MDIClient size */
1772 0, 0, rc
.right
, rc
.bottom
,
1773 hwnd
, 0, GetModuleHandle(0),
1776 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1777 DestroyWindow(mdi_client
);
1779 /* MDIClient with MDIS_ALLCHILDSTYLES */
1780 mdi_client
= CreateWindowExA(0, "mdiclient",
1782 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
1783 /* tests depend on a not zero MDIClient size */
1784 0, 0, rc
.right
, rc
.bottom
,
1785 hwnd
, 0, GetModuleHandle(0),
1788 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1789 DestroyWindow(mdi_client
);
1793 case WM_WINDOWPOSCHANGED
:
1795 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1798 GetWindowRect(hwnd
, &rc1
);
1799 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1800 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1801 /* note: winpos coordinates are relative to parent */
1802 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1803 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1804 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1806 GetWindowRect(hwnd
, &rc1
);
1807 GetClientRect(hwnd
, &rc2
);
1808 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1809 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1810 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1813 case WM_WINDOWPOSCHANGING
:
1815 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1816 WINDOWPOS my_winpos
= *winpos
;
1818 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1819 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1820 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1821 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1823 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1825 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1826 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1827 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1829 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1830 "DefWindowProc should not change WINDOWPOS values\n");
1839 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
1842 static BOOL
mdi_RegisterWindowClasses(void)
1847 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
1850 cls
.hInstance
= GetModuleHandleA(0);
1852 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
1853 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1854 cls
.lpszMenuName
= NULL
;
1855 cls
.lpszClassName
= "MDI_parent_Class";
1856 if(!RegisterClassA(&cls
)) return FALSE
;
1858 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
1859 cls
.lpszClassName
= "MDI_child_Class_1";
1860 if(!RegisterClassA(&cls
)) return FALSE
;
1862 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
1863 cls
.lpszClassName
= "MDI_child_Class_2";
1864 if(!RegisterClassA(&cls
)) return FALSE
;
1869 static void test_mdi(void)
1874 if (!mdi_RegisterWindowClasses()) assert(0);
1876 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
1877 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
1878 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
1879 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1880 GetDesktopWindow(), 0,
1881 GetModuleHandle(0), NULL
);
1882 assert(mdi_hwndMain
);
1884 while(GetMessage(&msg, 0, 0, 0))
1886 TranslateMessage(&msg);
1887 DispatchMessage(&msg);
1890 DestroyWindow(mdi_hwndMain
);
1893 static void test_icons(void)
1897 HICON icon
= LoadIconA(0, IDI_APPLICATION
);
1898 HICON icon2
= LoadIconA(0, IDI_QUESTION
);
1899 HICON small_icon
= LoadImageA(0, IDI_APPLICATION
, IMAGE_ICON
,
1900 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
1903 cls
.cbSize
= sizeof(cls
);
1905 cls
.lpfnWndProc
= DefWindowProcA
;
1909 cls
.hIcon
= LoadIconA(0, IDI_HAND
);
1910 cls
.hIconSm
= small_icon
;
1911 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
1912 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1913 cls
.lpszMenuName
= NULL
;
1914 cls
.lpszClassName
= "IconWindowClass";
1916 RegisterClassExA(&cls
);
1918 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
1919 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
1922 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1923 ok( res
== 0, "wrong big icon %p/0\n", res
);
1924 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
1925 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
1926 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1927 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
1928 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
1929 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
1930 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1931 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1933 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1934 ok( res
== 0, "wrong small icon %p/0\n", res
);
1935 /* this test is XP specific */
1936 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1937 ok( res != 0, "wrong small icon %p\n", res );*/
1938 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
1939 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
1940 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1941 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
1942 /* this test is XP specific */
1943 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1944 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
1945 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
1946 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
1947 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
1948 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
1949 /* this test is XP specific */
1950 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
1951 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
1953 /* make sure the big icon hasn't changed */
1954 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
1955 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
1957 DestroyWindow( hwnd
);
1960 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1962 if (msg
== WM_NCCALCSIZE
)
1964 RECT
*rect
= (RECT
*)lparam
;
1965 /* first time around increase the rectangle, next time decrease it */
1966 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
1967 else InflateRect( rect
, -10, -10 );
1970 return DefWindowProc( hwnd
, msg
, wparam
, lparam
);
1973 static void test_SetWindowPos(HWND hwnd
, HWND hwnd2
)
1975 RECT orig_win_rc
, rect
;
1977 HWND hwnd_grandchild
, hwnd_child
, hwnd_child2
;
1982 SetRect(&rect
, 111, 222, 333, 444);
1983 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
1984 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1985 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1987 SetRect(&rect
, 111, 222, 333, 444);
1988 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
1989 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
1990 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1992 GetWindowRect(hwnd
, &orig_win_rc
);
1994 old_proc
= SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
1995 ret
= SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
1996 ok(ret
, "Got %d\n", ret
);
1997 GetWindowRect( hwnd
, &rect
);
1998 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
1999 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2000 GetClientRect( hwnd
, &rect
);
2001 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2002 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
2003 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2005 ret
= SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
2006 ok(ret
, "Got %d\n", ret
);
2007 GetWindowRect( hwnd
, &rect
);
2008 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
2009 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2010 GetClientRect( hwnd
, &rect
);
2011 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2012 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
2013 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2015 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2016 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2017 ok(ret
, "Got %d\n", ret
);
2018 SetWindowLongPtr( hwnd
, GWLP_WNDPROC
, old_proc
);
2020 /* Win9x truncates coordinates to 16-bit irrespectively */
2023 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
2024 ok(ret
, "Got %d\n", ret
);
2025 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
2026 ok(ret
, "Got %d\n", ret
);
2028 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
2029 ok(ret
, "Got %d\n", ret
);
2030 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
2031 ok(ret
, "Got %d\n", ret
);
2034 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2035 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2036 ok(ret
, "Got %d\n", ret
);
2038 ok(!(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
2039 ret
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2040 ok(ret
, "Got %d\n", ret
);
2041 ok(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
2042 ret
= SetWindowPos(hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2043 ok(ret
, "Got %d\n", ret
);
2044 ok(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
2045 ret
= SetWindowPos(hwnd
, HWND_NOTOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2046 ok(ret
, "Got %d\n", ret
);
2047 ok(!(GetWindowLong(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
2049 hwnd_desktop
= GetDesktopWindow();
2050 ok(!!hwnd_desktop
, "Failed to get hwnd_desktop window (%d).\n", GetLastError());
2051 hwnd_child
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2052 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2053 hwnd_grandchild
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd_child
);
2054 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2055 hwnd_child2
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2056 ok(!!hwnd_child2
, "Failed to create second child window (%d)\n", GetLastError());
2058 ret
= SetWindowPos(hwnd
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2059 ok(ret
, "Got %d\n", ret
);
2060 check_active_state(hwnd
, hwnd
, hwnd
);
2062 ret
= SetWindowPos(hwnd2
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2063 ok(ret
, "Got %d\n", ret
);
2064 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2066 /* Returns TRUE also for windows that are not siblings */
2067 ret
= SetWindowPos(hwnd_child
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2068 ok(ret
, "Got %d\n", ret
);
2069 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2071 ret
= SetWindowPos(hwnd2
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2072 ok(ret
, "Got %d\n", ret
);
2073 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2075 /* Does not seem to do anything even without passing flags, still returns TRUE */
2076 GetWindowRect(hwnd_child
, &rc1
);
2077 ret
= SetWindowPos(hwnd_child
, hwnd2
, 1, 2, 3, 4, 0);
2078 ok(ret
, "Got %d\n", ret
);
2079 GetWindowRect(hwnd_child
, &rc2
);
2080 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2081 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2082 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2083 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2084 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2086 /* Same thing the other way around. */
2087 GetWindowRect(hwnd2
, &rc1
);
2088 ret
= SetWindowPos(hwnd2
, hwnd_child
, 1, 2, 3, 4, 0);
2089 ok(ret
, "Got %d\n", ret
);
2090 GetWindowRect(hwnd2
, &rc2
);
2091 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2092 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2093 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2094 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2095 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2097 /* .. and with these windows. */
2098 GetWindowRect(hwnd_grandchild
, &rc1
);
2099 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, 0);
2100 ok(ret
, "Got %d\n", ret
);
2101 GetWindowRect(hwnd_grandchild
, &rc2
);
2102 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2103 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2104 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2105 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2106 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2108 /* Add SWP_NOZORDER and it will be properly resized. */
2109 GetWindowRect(hwnd_grandchild
, &rc1
);
2110 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, SWP_NOZORDER
);
2111 ok(ret
, "Got %d\n", ret
);
2112 GetWindowRect(hwnd_grandchild
, &rc2
);
2113 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2114 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2115 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2116 rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2117 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2119 /* Given a sibling window, the window is properly resized. */
2120 GetWindowRect(hwnd_child
, &rc1
);
2121 ret
= SetWindowPos(hwnd_child
, hwnd_child2
, 1, 2, 3, 4, 0);
2122 ok(ret
, "Got %d\n", ret
);
2123 GetWindowRect(hwnd_child
, &rc2
);
2124 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2125 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2126 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2127 rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2128 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2130 /* Involving the desktop window changes things. */
2131 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2132 ok(!ret
, "Got %d\n", ret
);
2133 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2135 GetWindowRect(hwnd_child
, &rc1
);
2136 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, 0);
2137 ok(!ret
, "Got %d\n", ret
);
2138 GetWindowRect(hwnd_child
, &rc2
);
2139 ok(rc1
.top
== rc2
.top
&& rc1
.left
== rc2
.left
&&
2140 rc1
.bottom
== rc2
.bottom
&& rc1
.right
== rc2
.right
,
2141 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2142 rc1
.top
, rc1
.left
, rc1
.bottom
, rc1
.right
, rc2
.top
, rc2
.left
, rc2
.bottom
, rc2
.right
);
2143 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2145 ret
= SetWindowPos(hwnd_desktop
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2146 ok(!ret
, "Got %d\n", ret
);
2147 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2149 ret
= SetWindowPos(hwnd_desktop
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2150 ok(!ret
, "Got %d\n", ret
);
2151 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2153 ret
= SetWindowPos(hwnd
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2154 ok(!ret
, "Got %d\n", ret
);
2155 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2157 DestroyWindow(hwnd_grandchild
);
2158 DestroyWindow(hwnd_child
);
2159 DestroyWindow(hwnd_child2
);
2162 static void test_SetMenu(HWND parent
)
2169 hMenu
= CreateMenu();
2172 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2175 /* fails on (at least) Wine, NT4, XP SP2 */
2176 test_nonclient_area(parent
);
2178 ret
= GetMenu(parent
);
2179 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2180 /* test whether we can destroy a menu assigned to a window */
2181 retok
= DestroyMenu(hMenu
);
2182 ok( retok
, "DestroyMenu error %d\n", GetLastError());
2183 retok
= IsMenu(hMenu
);
2184 ok(!retok
|| broken(retok
) /* nt4 */, "menu handle should be not valid after DestroyMenu\n");
2185 ret
= GetMenu(parent
);
2186 /* This test fails on Win9x */
2188 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2189 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2190 test_nonclient_area(parent
);
2192 hMenu
= CreateMenu();
2196 ret
= GetMenu(parent
);
2197 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2199 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2200 test_nonclient_area(parent
);
2201 ret
= GetMenu(parent
);
2202 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2204 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2207 /* fails on (at least) Wine, NT4, XP SP2 */
2208 test_nonclient_area(parent
);
2210 ret
= GetMenu(parent
);
2211 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2213 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2214 test_nonclient_area(parent
);
2215 ret
= GetMenu(parent
);
2216 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2219 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
2222 ret
= GetMenu(child
);
2223 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2225 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2226 test_nonclient_area(child
);
2227 ret
= GetMenu(child
);
2228 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2230 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
2231 test_nonclient_area(child
);
2232 ret
= GetMenu(child
);
2233 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2235 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
2236 test_nonclient_area(child
);
2237 ret
= GetMenu(child
);
2238 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2240 style
= GetWindowLong(child
, GWL_STYLE
);
2241 SetWindowLong(child
, GWL_STYLE
, style
| WS_POPUP
);
2242 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
2243 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
2244 SetWindowLong(child
, GWL_STYLE
, style
);
2246 SetWindowLong(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
2247 ok(!SetMenu(child
, hMenu
), "SetMenu on a overlapped child window should fail\n");
2248 SetWindowLong(child
, GWL_STYLE
, style
);
2250 DestroyWindow(child
);
2254 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
2256 HWND child
[5], hwnd
;
2261 hwnd
= GetWindow(parent
, GW_CHILD
);
2262 ok(!hwnd
, "have to start without children to perform the test\n");
2264 for (i
= 0; i
< total
; i
++)
2266 if (style
[i
] & DS_CONTROL
)
2268 child
[i
] = CreateWindowExA(0, MAKEINTATOM(32770), "", style
[i
] & ~WS_VISIBLE
,
2269 0,0,0,0, parent
, (HMENU
)i
, 0, NULL
);
2270 if (style
[i
] & WS_VISIBLE
)
2271 ShowWindow(child
[i
], SW_SHOW
);
2273 SetWindowPos(child
[i
], HWND_BOTTOM
, 0,0,10,10, SWP_NOACTIVATE
);
2276 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
2277 parent
, (HMENU
)i
, 0, NULL
);
2278 trace("child[%ld] = %p\n", i
, child
[i
]);
2279 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
2282 hwnd
= GetWindow(parent
, GW_CHILD
);
2283 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
2284 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
2285 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
2287 for (i
= 0; i
< total
; i
++)
2289 trace("hwnd[%ld] = %p\n", i
, hwnd
);
2290 ok(child
[order
[i
]] == hwnd
, "Z order of child #%ld is wrong\n", i
);
2292 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
2295 for (i
= 0; i
< total
; i
++)
2296 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
2299 static void test_children_zorder(HWND parent
)
2301 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
2303 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
2305 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
2306 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
2307 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
2308 const int complex_order_1
[1] = { 0 };
2309 const int complex_order_2
[2] = { 1, 0 };
2310 const int complex_order_3
[3] = { 1, 0, 2 };
2311 const int complex_order_4
[4] = { 1, 0, 2, 3 };
2312 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
2313 const DWORD complex_style_6
[3] = { WS_CHILD
| WS_VISIBLE
,
2314 WS_CHILD
| WS_CLIPSIBLINGS
| DS_CONTROL
| WS_VISIBLE
,
2315 WS_CHILD
| WS_VISIBLE
};
2316 const int complex_order_6
[3] = { 0, 1, 2 };
2318 /* simple WS_CHILD */
2319 test_window_tree(parent
, simple_style
, simple_order
, 5);
2321 /* complex children styles */
2322 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
2323 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
2324 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
2325 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
2326 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
2328 /* another set of complex children styles */
2329 test_window_tree(parent
, complex_style_6
, complex_order_6
, 3);
2332 #define check_z_order(hwnd, next, prev, owner, topmost) \
2333 check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
2336 static void check_z_order_debug(HWND hwnd
, HWND next
, HWND prev
, HWND owner
,
2337 BOOL topmost
, const char *file
, int line
)
2342 test
= GetWindow(hwnd
, GW_HWNDNEXT
);
2343 /* skip foreign windows */
2344 while (test
&& test
!= next
&&
2345 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2346 UlongToHandle(GetWindowLongPtr(test
, GWLP_HINSTANCE
)) != GetModuleHandle(0) ||
2347 GetWindow(test
, GW_OWNER
) == next
))
2349 /*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2350 test
= GetWindow(test
, GW_HWNDNEXT
);
2352 ok_(file
, line
)(next
== test
, "%p: expected next %p, got %p\n", hwnd
, next
, test
);
2354 test
= GetWindow(hwnd
, GW_HWNDPREV
);
2355 /* skip foreign windows */
2356 while (test
&& test
!= prev
&&
2357 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2358 UlongToHandle(GetWindowLongPtr(test
, GWLP_HINSTANCE
)) != GetModuleHandle(0) ||
2359 GetWindow(test
, GW_OWNER
) == hwnd
))
2361 /*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2362 test
= GetWindow(test
, GW_HWNDPREV
);
2364 ok_(file
, line
)(prev
== test
, "%p: expected prev %p, got %p\n", hwnd
, prev
, test
);
2366 test
= GetWindow(hwnd
, GW_OWNER
);
2367 ok_(file
, line
)(owner
== test
, "%p: expected owner %p, got %p\n", hwnd
, owner
, test
);
2369 ex_style
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
2370 ok_(file
, line
)(!(ex_style
& WS_EX_TOPMOST
) == !topmost
, "%p: expected %stopmost\n",
2371 hwnd
, topmost
? "" : "NOT ");
2374 static void test_popup_zorder(HWND hwnd_D
, HWND hwnd_E
, DWORD style
)
2376 HWND hwnd_A
, hwnd_B
, hwnd_C
, hwnd_F
;
2378 trace("hwnd_D %p, hwnd_E %p\n", hwnd_D
, hwnd_E
);
2380 SetWindowPos(hwnd_E
, hwnd_D
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2382 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2383 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2385 hwnd_F
= CreateWindowEx(0, "MainWindowClass", "Owner window",
2386 WS_OVERLAPPED
| WS_CAPTION
,
2388 0, 0, GetModuleHandle(0), NULL
);
2389 trace("hwnd_F %p\n", hwnd_F
);
2390 check_z_order(hwnd_F
, hwnd_D
, 0, 0, FALSE
);
2392 SetWindowPos(hwnd_F
, hwnd_E
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2393 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2394 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2395 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2397 hwnd_C
= CreateWindowEx(0, "MainWindowClass", NULL
,
2400 hwnd_F
, 0, GetModuleHandle(0), NULL
);
2401 trace("hwnd_C %p\n", hwnd_C
);
2402 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2403 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2404 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2405 check_z_order(hwnd_C
, hwnd_D
, 0, hwnd_F
, FALSE
);
2407 hwnd_B
= CreateWindowEx(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2410 hwnd_F
, 0, GetModuleHandle(0), NULL
);
2411 trace("hwnd_B %p\n", hwnd_B
);
2412 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2413 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2414 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2415 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2416 check_z_order(hwnd_B
, hwnd_C
, 0, hwnd_F
, TRUE
);
2418 hwnd_A
= CreateWindowEx(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2421 0, 0, GetModuleHandle(0), NULL
);
2422 trace("hwnd_A %p\n", hwnd_A
);
2423 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2424 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2425 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2426 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2427 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2428 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2430 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
);
2432 /* move hwnd_F and its popups up */
2433 SetWindowPos(hwnd_F
, HWND_TOP
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2434 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2435 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2436 check_z_order(hwnd_F
, hwnd_D
, hwnd_C
, 0, FALSE
);
2437 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2438 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2439 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2441 /* move hwnd_F and its popups down */
2442 #if 0 /* enable once Wine is fixed to pass this test */
2443 SetWindowPos(hwnd_F
, HWND_BOTTOM
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2444 check_z_order(hwnd_F
, 0, hwnd_C
, 0, FALSE
);
2445 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2446 check_z_order(hwnd_B
, hwnd_C
, hwnd_E
, hwnd_F
, FALSE
);
2447 check_z_order(hwnd_E
, hwnd_B
, hwnd_D
, 0, FALSE
);
2448 check_z_order(hwnd_D
, hwnd_E
, hwnd_A
, 0, FALSE
);
2449 check_z_order(hwnd_A
, hwnd_D
, 0, 0, TRUE
);
2452 /* make hwnd_C owned by a topmost window */
2453 DestroyWindow( hwnd_C
);
2454 hwnd_C
= CreateWindowEx(0, "MainWindowClass", NULL
,
2457 hwnd_A
, 0, GetModuleHandle(0), NULL
);
2458 trace("hwnd_C %p\n", hwnd_C
);
2459 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2460 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2461 check_z_order(hwnd_F
, hwnd_D
, hwnd_B
, 0, FALSE
);
2462 check_z_order(hwnd_B
, hwnd_F
, hwnd_A
, hwnd_F
, TRUE
);
2463 check_z_order(hwnd_A
, hwnd_B
, hwnd_C
, 0, TRUE
);
2464 check_z_order(hwnd_C
, hwnd_A
, 0, hwnd_A
, TRUE
);
2466 DestroyWindow(hwnd_A
);
2467 DestroyWindow(hwnd_B
);
2468 DestroyWindow(hwnd_C
);
2469 DestroyWindow(hwnd_F
);
2472 static void test_vis_rgn( HWND hwnd
)
2474 RECT win_rect
, rgn_rect
;
2475 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
2478 ShowWindow(hwnd
,SW_SHOW
);
2479 hdc
= GetDC( hwnd
);
2480 ok( GetRandomRgn( hdc
, hrgn
, SYSRGN
) != 0, "GetRandomRgn failed\n" );
2481 GetWindowRect( hwnd
, &win_rect
);
2482 GetRgnBox( hrgn
, &rgn_rect
);
2485 trace("win9x, mapping to screen coords\n");
2486 MapWindowPoints( hwnd
, 0, (POINT
*)&rgn_rect
, 2 );
2488 trace("win: %d,%d-%d,%d\n", win_rect
.left
, win_rect
.top
, win_rect
.right
, win_rect
.bottom
);
2489 trace("rgn: %d,%d-%d,%d\n", rgn_rect
.left
, rgn_rect
.top
, rgn_rect
.right
, rgn_rect
.bottom
);
2490 ok( win_rect
.left
<= rgn_rect
.left
, "rgn left %d not inside win rect %d\n",
2491 rgn_rect
.left
, win_rect
.left
);
2492 ok( win_rect
.top
<= rgn_rect
.top
, "rgn top %d not inside win rect %d\n",
2493 rgn_rect
.top
, win_rect
.top
);
2494 ok( win_rect
.right
>= rgn_rect
.right
, "rgn right %d not inside win rect %d\n",
2495 rgn_rect
.right
, win_rect
.right
);
2496 ok( win_rect
.bottom
>= rgn_rect
.bottom
, "rgn bottom %d not inside win rect %d\n",
2497 rgn_rect
.bottom
, win_rect
.bottom
);
2498 ReleaseDC( hwnd
, hdc
);
2501 static LRESULT WINAPI
set_focus_on_activate_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
2503 if (msg
== WM_ACTIVATE
&& LOWORD(wp
) == WA_ACTIVE
)
2505 HWND child
= GetWindow(hwnd
, GW_CHILD
);
2506 ok(child
!= 0, "couldn't find child window\n");
2508 ok(GetFocus() == child
, "Focus should be on child %p\n", child
);
2511 return DefWindowProc(hwnd
, msg
, wp
, lp
);
2514 static void test_SetFocus(HWND hwnd
)
2516 HWND child
, child2
, ret
;
2517 WNDPROC old_wnd_proc
;
2519 /* check if we can set focus to non-visible windows */
2521 ShowWindow(hwnd
, SW_SHOW
);
2524 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2525 ok( GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
2526 ShowWindow(hwnd
, SW_HIDE
);
2529 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
2530 ok( !(GetWindowLong(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
2531 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2534 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
2535 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2536 ShowWindow(child
, SW_SHOW
);
2537 ok( GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
2538 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
2539 ShowWindow(child
, SW_HIDE
);
2540 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2541 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2542 ShowWindow(child
, SW_SHOW
);
2543 child2
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, child
, 0, 0, NULL
);
2545 ShowWindow(child2
, SW_SHOW
);
2547 ShowWindow(child
, SW_HIDE
);
2548 ok( !(GetWindowLong(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2549 ok( GetFocus() == child2
, "Focus should be on %p, not %p\n", child2
, GetFocus() );
2550 ShowWindow(child
, SW_SHOW
);
2552 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2553 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
2554 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2556 ShowWindow(child
, SW_HIDE
);
2558 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2559 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
2560 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2561 ShowWindow(child
, SW_HIDE
);
2562 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2564 ShowWindow(hwnd
, SW_SHOW
);
2565 ShowWindow(child
, SW_SHOW
);
2567 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2568 EnableWindow(hwnd
, FALSE
);
2569 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2570 EnableWindow(hwnd
, TRUE
);
2572 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2573 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2574 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2576 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2577 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2578 ShowWindow(hwnd
, SW_RESTORE
);
2579 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2580 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2581 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2582 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2583 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2585 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2586 old_wnd_proc
= (WNDPROC
)SetWindowLongPtr(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)set_focus_on_activate_proc
);
2587 ShowWindow(hwnd
, SW_RESTORE
);
2588 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2590 ok( GetFocus() == child
, "Focus should be on child %p, not %p\n", child
, GetFocus() );
2591 SetWindowLongPtr(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)old_wnd_proc
);
2594 SetParent( child
, GetDesktopWindow());
2595 SetParent( child2
, child
);
2596 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2597 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2598 ret
= SetFocus( child2
);
2599 ok( ret
== 0, "SetFocus %p should fail\n", child2
);
2600 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2601 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2602 ret
= SetFocus( child
);
2603 ok( ret
== 0, "SetFocus %p should fail\n", child
);
2604 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2605 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2606 SetWindowLongW( child
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
2608 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
2609 ok( GetFocus() == child2
, "Focus should be on child2 %p\n", child2
);
2611 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2612 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2614 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
2615 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2617 DestroyWindow( child2
);
2618 DestroyWindow( child
);
2621 static void test_SetActiveWindow(HWND hwnd
)
2625 flush_events( TRUE
);
2626 ShowWindow(hwnd
, SW_HIDE
);
2629 check_wnd_state(0, 0, 0, 0);
2631 /*trace("testing SetActiveWindow %p\n", hwnd);*/
2633 ShowWindow(hwnd
, SW_SHOW
);
2634 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2636 hwnd2
= SetActiveWindow(0);
2637 ok(hwnd2
== hwnd
, "SetActiveWindow returned %p instead of %p\n", hwnd2
, hwnd
);
2638 if (!GetActiveWindow()) /* doesn't always work on vista */
2640 check_wnd_state(0, 0, 0, 0);
2641 hwnd2
= SetActiveWindow(hwnd
);
2642 ok(hwnd2
== 0, "SetActiveWindow returned %p instead of 0\n", hwnd2
);
2644 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2646 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2647 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2649 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2650 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2652 ShowWindow(hwnd
, SW_HIDE
);
2653 check_wnd_state(0, 0, 0, 0);
2655 /*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/
2656 SetActiveWindow(hwnd
);
2657 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2659 ShowWindow(hwnd
, SW_SHOW
);
2660 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2662 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2663 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2665 DestroyWindow(hwnd2
);
2666 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2668 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2669 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2671 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2672 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2674 DestroyWindow(hwnd2
);
2675 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2678 struct create_window_thread_params
2681 HANDLE window_created
;
2682 HANDLE test_finished
;
2685 static DWORD WINAPI
create_window_thread(void *param
)
2687 struct create_window_thread_params
*p
= param
;
2691 p
->window
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
2693 ret
= SetEvent(p
->window_created
);
2694 ok(ret
, "SetEvent failed, last error %#x.\n", GetLastError());
2696 res
= WaitForSingleObject(p
->test_finished
, INFINITE
);
2697 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
2699 DestroyWindow(p
->window
);
2703 static void test_SetForegroundWindow(HWND hwnd
)
2705 struct create_window_thread_params thread_params
;
2712 flush_events( TRUE
);
2713 ShowWindow(hwnd
, SW_HIDE
);
2716 check_wnd_state(0, 0, 0, 0);
2718 /*trace("testing SetForegroundWindow %p\n", hwnd);*/
2720 ShowWindow(hwnd
, SW_SHOW
);
2721 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2723 hwnd2
= SetActiveWindow(0);
2724 ok(hwnd2
== hwnd
, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2
, hwnd
);
2725 if (GetActiveWindow() == hwnd
) /* doesn't always work on vista */
2726 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2728 check_wnd_state(0, 0, 0, 0);
2730 ret
= SetForegroundWindow(hwnd
);
2733 skip( "SetForegroundWindow not working\n" );
2736 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2738 SetLastError(0xdeadbeef);
2739 ret
= SetForegroundWindow(0);
2740 ok(!ret
, "SetForegroundWindow returned TRUE instead of FALSE\n");
2741 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
2742 broken(GetLastError() == 0xdeadbeef), /* win9x */
2743 "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
2744 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2746 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2747 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2749 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2750 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2752 hwnd2
= GetForegroundWindow();
2753 ok(hwnd2
== hwnd
, "Wrong foreground window %p\n", hwnd2
);
2754 ret
= SetForegroundWindow( GetDesktopWindow() );
2755 ok(ret
, "SetForegroundWindow(desktop) error: %d\n", GetLastError());
2756 hwnd2
= GetForegroundWindow();
2757 ok(hwnd2
!= hwnd
, "Wrong foreground window %p\n", hwnd2
);
2759 ShowWindow(hwnd
, SW_HIDE
);
2760 check_wnd_state(0, 0, 0, 0);
2762 /*trace("testing SetForegroundWindow on an invisible window %p\n", hwnd);*/
2763 ret
= SetForegroundWindow(hwnd
);
2764 ok(ret
|| broken(!ret
), /* win98 */ "SetForegroundWindow returned FALSE instead of TRUE\n");
2765 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2767 ShowWindow(hwnd
, SW_SHOW
);
2768 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2770 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2771 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2773 DestroyWindow(hwnd2
);
2774 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2776 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2777 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2779 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2780 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2782 DestroyWindow(hwnd2
);
2783 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2785 hwnd2
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
2786 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2788 thread_params
.window_created
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2789 ok(!!thread_params
.window_created
, "CreateEvent failed, last error %#x.\n", GetLastError());
2790 thread_params
.test_finished
= CreateEvent(NULL
, FALSE
, FALSE
, NULL
);
2791 ok(!!thread_params
.test_finished
, "CreateEvent failed, last error %#x.\n", GetLastError());
2792 thread
= CreateThread(NULL
, 0, create_window_thread
, &thread_params
, 0, &tid
);
2793 ok(!!thread
, "Failed to create thread, last error %#x.\n", GetLastError());
2794 res
= WaitForSingleObject(thread_params
.window_created
, INFINITE
);
2795 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
2796 check_wnd_state(hwnd2
, thread_params
.window
, hwnd2
, 0);
2798 SetForegroundWindow(hwnd2
);
2799 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2801 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessage(&msg
);
2802 if (0) check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2803 todo_wine
ok(GetActiveWindow() == hwnd2
, "Expected active window %p, got %p.\n", hwnd2
, GetActiveWindow());
2804 todo_wine
ok(GetFocus() == hwnd2
, "Expected focus window %p, got %p.\n", hwnd2
, GetFocus());
2806 SetEvent(thread_params
.test_finished
);
2807 WaitForSingleObject(thread
, INFINITE
);
2808 CloseHandle(thread_params
.test_finished
);
2809 CloseHandle(thread_params
.window_created
);
2810 CloseHandle(thread
);
2811 DestroyWindow(hwnd2
);
2814 static WNDPROC old_button_proc
;
2816 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2821 key_state
= GetKeyState(VK_LBUTTON
);
2822 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
2824 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
2826 if (msg
== WM_LBUTTONDOWN
)
2830 check_wnd_state(button
, button
, button
, button
);
2832 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2834 trace("hwnd %p\n", hwnd
);
2836 check_wnd_state(button
, button
, button
, button
);
2838 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2840 check_wnd_state(button
, button
, button
, button
);
2842 DestroyWindow(hwnd
);
2844 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2846 trace("hwnd %p\n", hwnd
);
2848 check_wnd_state(button
, button
, button
, button
);
2850 /* button wnd proc should release capture on WM_KILLFOCUS if it does
2851 * match internal button state.
2853 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2854 check_wnd_state(button
, button
, button
, 0);
2856 ShowWindow(hwnd
, SW_SHOW
);
2857 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2859 capture
= SetCapture(hwnd
);
2860 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2862 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2864 DestroyWindow(hwnd
);
2866 check_wnd_state(button
, 0, button
, 0);
2872 static void test_capture_1(void)
2874 HWND button
, capture
;
2876 capture
= GetCapture();
2877 ok(capture
== 0, "GetCapture() = %p\n", capture
);
2879 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2881 trace("button %p\n", button
);
2883 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
2885 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
2887 capture
= SetCapture(button
);
2888 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2889 check_wnd_state(button
, 0, button
, button
);
2891 DestroyWindow(button
);
2892 /* old active window test depends on previously executed window
2893 * activation tests, and fails under NT4.
2894 check_wnd_state(oldActive, 0, oldFocus, 0);*/
2897 static void test_capture_2(void)
2899 HWND button
, hwnd
, capture
, oldFocus
, oldActive
;
2901 oldFocus
= GetFocus();
2902 oldActive
= GetActiveWindow();
2903 check_wnd_state(oldActive
, 0, oldFocus
, 0);
2905 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2907 trace("button %p\n", button
);
2909 check_wnd_state(button
, button
, button
, 0);
2911 capture
= SetCapture(button
);
2912 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2914 check_wnd_state(button
, button
, button
, button
);
2916 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
2917 * internal button state.
2919 SendMessage(button
, WM_KILLFOCUS
, 0, 0);
2920 check_wnd_state(button
, button
, button
, button
);
2922 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2924 trace("hwnd %p\n", hwnd
);
2926 check_wnd_state(button
, button
, button
, button
);
2928 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2930 check_wnd_state(button
, button
, button
, button
);
2932 DestroyWindow(hwnd
);
2934 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2936 trace("hwnd %p\n", hwnd
);
2938 check_wnd_state(button
, button
, button
, button
);
2940 ShowWindow(hwnd
, SW_SHOW
);
2942 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
2944 capture
= SetCapture(hwnd
);
2945 ok(capture
== button
, "SetCapture() = %p\n", capture
);
2947 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2949 DestroyWindow(hwnd
);
2950 check_wnd_state(button
, button
, button
, 0);
2952 DestroyWindow(button
);
2953 check_wnd_state(oldActive
, 0, oldFocus
, 0);
2956 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
2960 ShowWindow(hwnd1
, SW_HIDE
);
2961 ShowWindow(hwnd2
, SW_HIDE
);
2963 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
2964 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
2967 check_wnd_state(0, 0, 0, hwnd1
);
2970 check_wnd_state(0, 0, 0, hwnd2
);
2972 ShowWindow(hwnd1
, SW_SHOW
);
2973 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
2975 ret
= ReleaseCapture();
2976 ok (ret
, "releasecapture did not return TRUE.\n");
2977 ret
= ReleaseCapture();
2978 ok (ret
, "releasecapture did not return TRUE after second try.\n");
2981 static LRESULT CALLBACK
test_capture_4_proc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
2984 HWND cap_wnd
, cap_wnd2
, set_cap_wnd
;
2988 case WM_CAPTURECHANGED
:
2990 /* now try to release capture from menu. this should fail */
2991 if (pGetGUIThreadInfo
)
2993 memset(>i
, 0, sizeof(GUITHREADINFO
));
2994 gti
.cbSize
= sizeof(GUITHREADINFO
);
2995 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
2996 ok(status
, "GetGUIThreadInfo() failed!\n");
2997 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
2999 cap_wnd
= GetCapture();
3001 /* check that re-setting the capture for the menu fails */
3002 set_cap_wnd
= SetCapture(cap_wnd
);
3003 ok(!set_cap_wnd
|| broken(set_cap_wnd
== cap_wnd
), /* nt4 */
3004 "SetCapture should have failed!\n");
3007 DestroyWindow(hWnd
);
3011 /* check that SetCapture fails for another window and that it does not touch the error code */
3012 set_cap_wnd
= SetCapture(hWnd
);
3013 ok(!set_cap_wnd
, "SetCapture should have failed!\n");
3015 /* check that ReleaseCapture fails and does not touch the error code */
3016 status
= ReleaseCapture();
3017 ok(!status
, "ReleaseCapture should have failed!\n");
3019 /* check that thread info did not change */
3020 if (pGetGUIThreadInfo
)
3022 memset(>i
, 0, sizeof(GUITHREADINFO
));
3023 gti
.cbSize
= sizeof(GUITHREADINFO
);
3024 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
3025 ok(status
, "GetGUIThreadInfo() failed!\n");
3026 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
3029 /* verify that no capture change took place */
3030 cap_wnd2
= GetCapture();
3031 ok(cap_wnd2
== cap_wnd
, "Capture changed!\n");
3033 /* we are done. kill the window */
3034 DestroyWindow(hWnd
);
3038 return( DefWindowProcA( hWnd
, msg
, wParam
, lParam
) );
3043 /* Test that no-one can mess around with the current capture while a menu is open */
3044 static void test_capture_4(void)
3050 HINSTANCE hInstance
= GetModuleHandleA( NULL
);
3053 if (!pGetGUIThreadInfo
)
3055 win_skip("GetGUIThreadInfo is not available\n");
3058 wclass
.lpszClassName
= "TestCapture4Class";
3059 wclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
3060 wclass
.lpfnWndProc
= test_capture_4_proc
;
3061 wclass
.hInstance
= hInstance
;
3062 wclass
.hIcon
= LoadIconA( 0, IDI_APPLICATION
);
3063 wclass
.hCursor
= LoadCursorA( NULL
, IDC_ARROW
);
3064 wclass
.hbrBackground
= (HBRUSH
)( COLOR_WINDOW
+ 1 );
3065 wclass
.lpszMenuName
= 0;
3066 wclass
.cbClsExtra
= 0;
3067 wclass
.cbWndExtra
= 0;
3068 aclass
= RegisterClassA( &wclass
);
3069 ok( aclass
, "RegisterClassA failed with error %d\n", GetLastError());
3070 hwnd
= CreateWindowA( wclass
.lpszClassName
, "MenuTest",
3071 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0,
3072 400, 200, NULL
, NULL
, hInstance
, NULL
);
3073 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
3075 hmenu
= CreatePopupMenu();
3077 ret
= AppendMenuA( hmenu
, MF_STRING
, 1, "winetest2");
3078 ok( ret
, "AppendMenuA has failed!\n");
3080 /* set main window to have initial capture */
3085 win_skip("TrackPopupMenu test crashes on Win9x/WinMe\n");
3089 /* create popup (it will self-destruct) */
3090 ret
= TrackPopupMenu(hmenu
, TPM_RETURNCMD
, 100, 100, 0, hwnd
, NULL
);
3091 ok( ret
== 0, "TrackPopupMenu returned %d expected zero\n", ret
);
3096 DestroyWindow(hwnd
);
3099 /* PeekMessage wrapper that ignores the messages we don't care about */
3100 static BOOL
peek_message( MSG
*msg
)
3105 ret
= PeekMessageA(msg
, 0, 0, 0, PM_REMOVE
);
3106 } while (ret
&& (msg
->message
== WM_TIMER
|| ignore_message(msg
->message
)));
3110 static void test_keyboard_input(HWND hwnd
)
3115 flush_events( TRUE
);
3116 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_SHOWWINDOW
);
3118 flush_events( TRUE
);
3120 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
3123 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3125 flush_events( TRUE
);
3127 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3128 ret
= peek_message(&msg
);
3129 ok( ret
, "no message available\n");
3130 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3131 ret
= peek_message(&msg
);
3132 ok( !ret
, "message %04x available\n", msg
.message
);
3134 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3136 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3137 ret
= peek_message(&msg
);
3138 ok(ret
, "no message available\n");
3139 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3140 ret
= peek_message(&msg
);
3141 ok( !ret
, "message %04x available\n", msg
.message
);
3143 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3145 keybd_event(VK_SPACE
, 0, 0, 0);
3146 if (!peek_message(&msg
))
3148 skip( "keybd_event didn't work, skipping keyboard test\n" );
3151 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3152 ret
= peek_message(&msg
);
3153 ok( !ret
, "message %04x available\n", msg
.message
);
3156 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3158 flush_events( TRUE
);
3160 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3161 ret
= peek_message(&msg
);
3162 ok(ret
, "no message available\n");
3163 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3164 ret
= peek_message(&msg
);
3165 ok( !ret
, "message %04x available\n", msg
.message
);
3167 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3169 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3170 ret
= peek_message(&msg
);
3171 ok(ret
, "no message available\n");
3172 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3173 ret
= peek_message(&msg
);
3174 ok( !ret
, "message %04x available\n", msg
.message
);
3176 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3178 keybd_event(VK_SPACE
, 0, 0, 0);
3179 ret
= peek_message(&msg
);
3180 ok(ret
, "no message available\n");
3181 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3182 ret
= peek_message(&msg
);
3183 ok( !ret
, "message %04x available\n", msg
.message
);
3186 static BOOL
wait_for_message( MSG
*msg
)
3192 ret
= peek_message(msg
);
3195 if (msg
->message
== WM_PAINT
) DispatchMessage(msg
);
3198 else if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
3200 if (!ret
) msg
->message
= 0;
3204 static void test_mouse_input(HWND hwnd
)
3214 ShowWindow(hwnd
, SW_SHOWNORMAL
);
3216 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3218 GetWindowRect(hwnd
, &rc
);
3219 trace("main window %p: (%d,%d)-(%d,%d)\n", hwnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3221 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
3222 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
3225 ShowWindow(popup
, SW_SHOW
);
3226 UpdateWindow(popup
);
3227 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3229 GetWindowRect(popup
, &rc
);
3230 trace("popup window %p: (%d,%d)-(%d,%d)\n", popup
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3232 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
3233 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
3234 trace("setting cursor to (%d,%d)\n", x
, y
);
3238 if (x
!= pt
.x
|| y
!= pt
.y
)
3240 skip( "failed to set mouse position, skipping mouse input tests\n" );
3244 flush_events( TRUE
);
3246 /* Check that setting the same position may generate WM_MOUSEMOVE */
3249 ret
= peek_message(&msg
);
3252 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n",
3253 msg
.hwnd
, msg
.message
);
3254 ok(msg
.pt
.x
== x
&& msg
.pt
.y
== y
, "wrong message coords (%d,%d)/(%d,%d)\n",
3255 x
, y
, msg
.pt
.x
, msg
.pt
.y
);
3258 /* force the system to update its internal queue mouse position,
3259 * otherwise it won't generate relative mouse movements below.
3261 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3262 flush_events( TRUE
);
3265 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3266 flush_events( FALSE
);
3267 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
3268 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
3270 if (msg
.message
== WM_TIMER
|| ignore_message(msg
.message
)) continue;
3271 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
,
3272 "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3273 DispatchMessage(&msg
);
3275 ret
= peek_message(&msg
);
3276 ok( !ret
, "message %04x available\n", msg
.message
);
3278 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3279 ShowWindow(popup
, SW_HIDE
);
3280 ret
= wait_for_message( &msg
);
3282 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3283 flush_events( TRUE
);
3285 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3286 ShowWindow(hwnd
, SW_HIDE
);
3287 ret
= wait_for_message( &msg
);
3288 ok( !ret
, "message %04x available\n", msg
.message
);
3289 flush_events( TRUE
);
3291 /* test mouse clicks */
3293 ShowWindow(hwnd
, SW_SHOW
);
3294 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3295 flush_events( TRUE
);
3296 ShowWindow(popup
, SW_SHOW
);
3297 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3298 flush_events( TRUE
);
3300 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3301 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3302 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3303 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3305 ret
= wait_for_message( &msg
);
3308 skip( "simulating mouse click doesn't work, skipping mouse button tests\n" );
3311 if (msg
.message
== WM_MOUSEMOVE
) /* win2k has an extra WM_MOUSEMOVE here */
3313 ret
= wait_for_message( &msg
);
3314 ok(ret
, "no message available\n");
3317 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3318 msg
.hwnd
, popup
, msg
.message
);
3320 ret
= wait_for_message( &msg
);
3321 ok(ret
, "no message available\n");
3322 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3323 msg
.hwnd
, popup
, msg
.message
);
3325 ret
= wait_for_message( &msg
);
3326 ok(ret
, "no message available\n");
3327 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p/%p message %04x\n",
3328 msg
.hwnd
, popup
, msg
.message
);
3330 ret
= wait_for_message( &msg
);
3331 ok(ret
, "no message available\n");
3332 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3333 msg
.hwnd
, popup
, msg
.message
);
3335 ret
= peek_message(&msg
);
3336 ok(!ret
, "message %04x available\n", msg
.message
);
3338 ShowWindow(popup
, SW_HIDE
);
3339 flush_events( TRUE
);
3341 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3342 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3343 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3344 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3346 ret
= wait_for_message( &msg
);
3347 ok(ret
, "no message available\n");
3348 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3349 msg
.hwnd
, hwnd
, msg
.message
);
3350 ret
= wait_for_message( &msg
);
3351 ok(ret
, "no message available\n");
3352 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3353 msg
.hwnd
, hwnd
, msg
.message
);
3355 test_lbuttondown_flag
= TRUE
;
3356 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
3357 test_lbuttondown_flag
= FALSE
;
3359 ret
= wait_for_message( &msg
);
3360 ok(ret
, "no message available\n");
3361 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3362 msg
.hwnd
, popup
, msg
.message
);
3363 ok(peek_message(&msg
), "no message available\n");
3364 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3365 msg
.hwnd
, popup
, msg
.message
);
3366 ok(peek_message(&msg
), "no message available\n");
3368 /* Test WM_MOUSEACTIVATE */
3369 #define TEST_MOUSEACTIVATE(A,B) \
3370 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
3371 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
3373 TEST_MOUSEACTIVATE(HTERROR
,MA_ACTIVATE
);
3374 TEST_MOUSEACTIVATE(HTTRANSPARENT
,MA_ACTIVATE
);
3375 TEST_MOUSEACTIVATE(HTNOWHERE
,MA_ACTIVATE
);
3376 TEST_MOUSEACTIVATE(HTCLIENT
,MA_ACTIVATE
);
3377 TEST_MOUSEACTIVATE(HTCAPTION
,MA_ACTIVATE
);
3378 TEST_MOUSEACTIVATE(HTSYSMENU
,MA_ACTIVATE
);
3379 TEST_MOUSEACTIVATE(HTSIZE
,MA_ACTIVATE
);
3380 TEST_MOUSEACTIVATE(HTMENU
,MA_ACTIVATE
);
3381 TEST_MOUSEACTIVATE(HTHSCROLL
,MA_ACTIVATE
);
3382 TEST_MOUSEACTIVATE(HTVSCROLL
,MA_ACTIVATE
);
3383 TEST_MOUSEACTIVATE(HTMINBUTTON
,MA_ACTIVATE
);
3384 TEST_MOUSEACTIVATE(HTMAXBUTTON
,MA_ACTIVATE
);
3385 TEST_MOUSEACTIVATE(HTLEFT
,MA_ACTIVATE
);
3386 TEST_MOUSEACTIVATE(HTRIGHT
,MA_ACTIVATE
);
3387 TEST_MOUSEACTIVATE(HTTOP
,MA_ACTIVATE
);
3388 TEST_MOUSEACTIVATE(HTTOPLEFT
,MA_ACTIVATE
);
3389 TEST_MOUSEACTIVATE(HTTOPRIGHT
,MA_ACTIVATE
);
3390 TEST_MOUSEACTIVATE(HTBOTTOM
,MA_ACTIVATE
);
3391 TEST_MOUSEACTIVATE(HTBOTTOMLEFT
,MA_ACTIVATE
);
3392 TEST_MOUSEACTIVATE(HTBOTTOMRIGHT
,MA_ACTIVATE
);
3393 TEST_MOUSEACTIVATE(HTBORDER
,MA_ACTIVATE
);
3394 TEST_MOUSEACTIVATE(HTOBJECT
,MA_ACTIVATE
);
3395 TEST_MOUSEACTIVATE(HTCLOSE
,MA_ACTIVATE
);
3396 TEST_MOUSEACTIVATE(HTHELP
,MA_ACTIVATE
);
3399 /* Clear any messages left behind by WM_MOUSEACTIVATE tests */
3400 flush_events( TRUE
);
3402 DestroyWindow(popup
);
3405 static void test_validatergn(HWND hwnd
)
3411 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
3412 ShowWindow(hwnd
, SW_SHOW
);
3413 UpdateWindow( hwnd
);
3414 /* test that ValidateRect validates children*/
3415 InvalidateRect( child
, NULL
, 1);
3416 GetWindowRect( child
, &rc
);
3417 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3418 ret
= GetUpdateRect( child
, &rc2
, 0);
3419 ok( ret
== 1, "Expected GetUpdateRect to return non-zero, got %d\n", ret
);
3420 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
3421 "Update rectangle is empty!\n");
3422 ValidateRect( hwnd
, &rc
);
3423 ret
= GetUpdateRect( child
, &rc2
, 0);
3424 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3425 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3426 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
3427 rc2
.right
, rc2
.bottom
);
3429 /* now test ValidateRgn */
3430 InvalidateRect( child
, NULL
, 1);
3431 GetWindowRect( child
, &rc
);
3432 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3433 rgn
= CreateRectRgnIndirect( &rc
);
3434 ValidateRgn( hwnd
, rgn
);
3435 ret
= GetUpdateRect( child
, &rc2
, 0);
3436 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3437 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3438 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
3439 rc2
.right
, rc2
.bottom
);
3442 DestroyWindow( child
);
3445 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
3448 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
3449 GetWindowRect( hwnd
, prc
);
3451 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
3452 trace("window rect is %d,%d - %d,%d, nccalc rect is %d,%d - %d,%d\n",
3453 rc
.left
,rc
.top
,rc
.right
,rc
.bottom
, prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
3456 static void test_nccalcscroll(HWND parent
)
3459 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
3460 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
3461 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
3462 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
3463 10, 10, 200, 200, parent
, 0, 0, NULL
);
3464 ShowWindow( parent
, SW_SHOW
);
3465 UpdateWindow( parent
);
3467 /* test window too low for a horizontal scroll bar */
3468 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
3469 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %d,%d - %d,%d\n",
3470 sbheight
, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3472 /* test window just high enough for a horizontal scroll bar */
3473 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
3474 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be %d size is %d,%d - %d,%d\n",
3475 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3477 /* test window too narrow for a vertical scroll bar */
3478 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
3479 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %d,%d - %d,%d\n",
3480 sbwidth
- 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3482 /* test window just wide enough for a vertical scroll bar */
3483 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
3484 ok( rc1
.right
- rc1
.left
== 0, "Width should be %d size is %d,%d - %d,%d\n",
3485 0, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3487 /* same test, but with client edge: not enough width */
3488 SetWindowLong( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLong( hwnd
, GWL_EXSTYLE
));
3489 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
3490 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
3491 "Width should be %d size is %d,%d - %d,%d\n",
3492 sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
), rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3494 DestroyWindow( hwnd
);
3497 static void test_SetParent(void)
3499 HWND desktop
= GetDesktopWindow();
3501 HWND ret
, parent
, child1
, child2
, child3
, child4
, sibling
, popup
;
3504 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3505 100, 100, 200, 200, 0, 0, 0, NULL
);
3506 assert(parent
!= 0);
3507 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3508 0, 0, 50, 50, parent
, 0, 0, NULL
);
3509 assert(child1
!= 0);
3510 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3511 0, 0, 50, 50, child1
, 0, 0, NULL
);
3512 assert(child2
!= 0);
3513 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3514 0, 0, 50, 50, child2
, 0, 0, NULL
);
3515 assert(child3
!= 0);
3516 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3517 0, 0, 50, 50, child3
, 0, 0, NULL
);
3518 assert(child4
!= 0);
3520 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
3521 parent
, child1
, child2
, child3
, child4
);
3523 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
3524 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
3525 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3526 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3527 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3529 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
3530 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
3531 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
3532 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
3533 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
3535 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
3536 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
3537 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
3538 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
3539 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
3540 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
3541 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
3542 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
3543 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
3545 if (!is_win9x
) /* Win9x doesn't survive this test */
3547 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
3548 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
3549 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
3550 ret
= SetParent(parent
, child2
);
3551 todo_wine
ok( !ret
|| broken( ret
!= 0 ), "SetParent should fail\n");
3552 if (ret
) /* nt4, win2k */
3554 ret
= SetParent(parent
, child3
);
3555 ok(ret
!= 0, "SetParent should not fail\n");
3556 ret
= SetParent(child2
, parent
);
3557 ok(!ret
, "SetParent should fail\n");
3558 ret
= SetParent(parent
, child4
);
3559 ok(ret
!= 0, "SetParent should not fail\n");
3560 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
3561 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
3562 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3563 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3564 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3568 ret
= SetParent(parent
, child3
);
3569 ok(ret
!= 0, "SetParent should not fail\n");
3570 ret
= SetParent(child2
, parent
);
3571 ok(!ret
, "SetParent should fail\n");
3572 ret
= SetParent(parent
, child4
);
3573 ok(!ret
, "SetParent should fail\n");
3574 check_parents(parent
, child3
, child3
, 0, 0, child2
, parent
);
3575 check_parents(child1
, parent
, parent
, parent
, 0, child2
, parent
);
3576 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3577 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3578 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3582 skip("Win9x/WinMe crash\n");
3584 hMenu
= CreateMenu();
3585 sibling
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3586 100, 100, 200, 200, 0, hMenu
, 0, NULL
);
3587 assert(sibling
!= 0);
3589 ok(SetParent(sibling
, parent
) != 0, "SetParent should not fail\n");
3590 ok(GetMenu(sibling
) == hMenu
, "SetParent should not remove menu\n");
3592 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
3594 ok(!IsWindow(parent
), "parent still exists\n");
3595 ok(!IsWindow(sibling
), "sibling still exists\n");
3596 ok(!IsWindow(child1
), "child1 still exists\n");
3597 ok(!IsWindow(child2
), "child2 still exists\n");
3598 ok(!IsWindow(child3
), "child3 still exists\n");
3599 ok(!IsWindow(child4
), "child4 still exists\n");
3601 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3602 100, 100, 200, 200, 0, 0, 0, NULL
);
3603 assert(parent
!= 0);
3604 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3605 0, 0, 50, 50, parent
, 0, 0, NULL
);
3606 assert(child1
!= 0);
3607 popup
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3608 0, 0, 50, 50, 0, 0, 0, NULL
);
3611 trace("parent %p, child %p, popup %p\n", parent
, child1
, popup
);
3613 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
3614 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
3615 check_parents(popup
, desktop
, 0, 0, 0, popup
, popup
);
3617 SetActiveWindow(parent
);
3619 check_active_state(parent
, 0, parent
);
3621 ret
= SetParent(popup
, child1
);
3622 ok(ret
== desktop
, "expected %p, got %p\n", desktop
, ret
);
3623 check_parents(popup
, child1
, child1
, 0, 0, parent
, popup
);
3625 check_active_state(popup
, 0, popup
);
3627 SetActiveWindow(parent
);
3629 check_active_state(parent
, 0, parent
);
3631 bret
= SetForegroundWindow(popup
);
3633 ok(bret
|| broken(!bret
), "SetForegroundWindow() failed\n");
3635 check_active_state(popup
, 0, popup
);
3637 check_active_state(popup
, popup
, popup
);
3640 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
3642 ok(!IsWindow(parent
), "parent still exists\n");
3643 ok(!IsWindow(child1
), "child1 still exists\n");
3644 ok(!IsWindow(popup
), "popup still exists\n");
3647 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3649 LPCREATESTRUCT lpcs
;
3656 lpcs
= (LPCREATESTRUCT
)lparam
;
3657 lpss
= lpcs
->lpCreateParams
;
3660 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
3661 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
3662 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
3663 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
3665 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
3667 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
3668 "Ex style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
3669 (lpss
->styleOld
& ~WS_EX_WINDOWEDGE
), (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
));
3671 ok(lpss
->styleNew
== lpcs
->style
,
3672 "Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
3673 lpss
->styleNew
, lpcs
->style
);
3677 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
3680 static ATOM atomStyleCheckClass
;
3682 static void register_style_check_class(void)
3690 GetModuleHandle(NULL
),
3692 LoadCursor(NULL
, IDC_ARROW
),
3693 (HBRUSH
)(COLOR_BTNFACE
+1),
3695 TEXT("WineStyleCheck"),
3698 atomStyleCheckClass
= RegisterClass(&wc
);
3699 assert(atomStyleCheckClass
);
3702 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
3704 DWORD dwActualStyle
;
3705 DWORD dwActualExStyle
;
3708 HWND hwndParent
= NULL
;
3710 ss
.styleNew
= dwStyleIn
;
3711 ss
.styleOld
= dwExStyleIn
;
3713 if (dwStyleIn
& WS_CHILD
)
3715 hwndParent
= CreateWindowEx(0, MAKEINTATOM(atomStyleCheckClass
), NULL
,
3716 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
3719 hwnd
= CreateWindowEx(dwExStyleIn
, MAKEINTATOM(atomStyleCheckClass
), NULL
,
3720 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
3723 flush_events( TRUE
);
3725 dwActualStyle
= GetWindowLong(hwnd
, GWL_STYLE
);
3726 dwActualExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
3727 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3728 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3730 /* try setting the styles explicitly */
3731 SetWindowLong( hwnd
, GWL_EXSTYLE
, dwExStyleIn
);
3732 dwActualStyle
= GetWindowLong(hwnd
, GWL_STYLE
);
3733 dwActualExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
3734 /* WS_EX_WINDOWEDGE can't always be changed */
3735 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
3736 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3737 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
3738 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3740 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
3741 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3742 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3744 SetWindowLong( hwnd
, GWL_STYLE
, dwStyleIn
);
3745 dwActualStyle
= GetWindowLong(hwnd
, GWL_STYLE
);
3746 dwActualExStyle
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
3747 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3748 if ((dwStyleIn
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
) dwStyleOut
= dwStyleIn
;
3749 else dwStyleOut
= dwStyleIn
| WS_CLIPSIBLINGS
;
3750 /* WS_EX_WINDOWEDGE can't always be changed */
3751 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
3752 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3753 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
3754 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3756 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
3757 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3758 /* FIXME: Remove the condition below once Wine is fixed */
3759 if (dwActualExStyle
!= dwExStyleOut
)
3760 todo_wine
ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3762 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3764 DestroyWindow(hwnd
);
3765 if (hwndParent
) DestroyWindow(hwndParent
);
3768 /* tests what window styles the window manager automatically adds */
3769 static void test_window_styles(void)
3771 register_style_check_class();
3773 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3774 check_window_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3775 check_window_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3776 check_window_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
3777 check_window_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
3778 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
3779 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
3780 check_window_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
3781 check_window_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
3782 check_window_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
3783 check_window_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
3784 check_window_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3785 check_window_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
3786 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3787 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3788 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3789 check_window_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3790 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3791 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3792 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3793 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3794 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
3795 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3796 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3797 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
3798 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3799 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3800 check_window_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3801 check_window_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3802 check_window_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3803 check_window_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3804 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
3805 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
3807 if (pGetLayeredWindowAttributes
)
3809 check_window_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
);
3810 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_WINDOWEDGE
);
3811 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
3812 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
);
3816 static INT_PTR WINAPI
empty_dlg_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3821 static void check_dialog_style(DWORD style_in
, DWORD ex_style_in
, DWORD style_out
, DWORD ex_style_out
)
3831 DWORD style
, ex_style
;
3832 HWND hwnd
, parent
= 0;
3834 if (style_in
& WS_CHILD
)
3835 parent
= CreateWindowEx(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3836 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
3838 dlg_data
.dt
.style
= style_in
;
3839 dlg_data
.dt
.dwExtendedStyle
= ex_style_in
;
3840 dlg_data
.dt
.cdit
= 0;
3843 dlg_data
.dt
.cx
= 100;
3844 dlg_data
.dt
.cy
= 100;
3845 dlg_data
.menu_name
= 0;
3846 dlg_data
.class_id
= 0;
3847 dlg_data
.class_atom
= 0;
3848 dlg_data
.caption
[0] = 0;
3850 hwnd
= CreateDialogIndirectParam(GetModuleHandle(0), &dlg_data
.dt
, parent
, empty_dlg_proc
, 0);
3851 ok(hwnd
!= 0, "dialog creation failed, style %#x, exstyle %#x\n", style_in
, ex_style_in
);
3853 flush_events( TRUE
);
3855 style
= GetWindowLong(hwnd
, GWL_STYLE
);
3856 ex_style
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
3857 ok(style
== (style_out
| DS_3DLOOK
), "expected style %#x, got %#x\n", style_out
| DS_3DLOOK
, style
);
3858 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
3860 /* try setting the styles explicitly */
3861 SetWindowLong(hwnd
, GWL_EXSTYLE
, ex_style_in
);
3862 style
= GetWindowLong(hwnd
, GWL_STYLE
);
3863 ex_style
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
3864 ok(style
== (style_out
| DS_3DLOOK
), "expected style %#x, got %#x\n", style_out
|DS_3DLOOK
, style
);
3865 /* WS_EX_WINDOWEDGE can't always be changed */
3866 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
3867 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
3868 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
3869 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
3871 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
3872 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
3874 SetWindowLong(hwnd
, GWL_STYLE
, style_in
);
3875 style
= GetWindowLong(hwnd
, GWL_STYLE
);
3876 ex_style
= GetWindowLong(hwnd
, GWL_EXSTYLE
);
3877 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3878 if ((style_in
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
) style_out
= style_in
;
3879 else style_out
= style_in
| WS_CLIPSIBLINGS
;
3880 ok(style
== style_out
, "expected style %#x, got %#x\n", style_out
, style
);
3881 /* WS_EX_WINDOWEDGE can't always be changed */
3882 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
3883 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
3884 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
3885 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
3887 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
3888 /* FIXME: Remove the condition below once Wine is fixed */
3889 if (ex_style
!= ex_style_out
)
3890 todo_wine
ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
3892 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
3894 DestroyWindow(hwnd
);
3895 DestroyWindow(parent
);
3898 static void test_dialog_styles(void)
3900 check_dialog_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3901 check_dialog_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3902 check_dialog_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3903 check_dialog_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
3904 check_dialog_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
3905 check_dialog_style(DS_CONTROL
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
|DS_CONTROL
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3906 check_dialog_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3907 check_dialog_style(WS_CHILD
, 0, WS_CHILD
, 0);
3908 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
3909 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
3910 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
3911 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
3912 check_dialog_style(WS_CHILD
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
3913 check_dialog_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3914 check_dialog_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
3915 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3916 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3917 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3918 check_dialog_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3919 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3920 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3921 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3922 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3923 check_dialog_style(WS_CHILD
|WS_POPUP
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
3924 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
3925 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3926 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3927 check_dialog_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
|WS_EX_CONTROLPARENT
);
3928 check_dialog_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
3929 check_dialog_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
3930 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3931 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3932 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
3933 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
3934 check_dialog_style(WS_POPUP
|DS_CONTROL
, 0, WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
3935 check_dialog_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3936 check_dialog_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3938 if (pGetLayeredWindowAttributes
)
3940 check_dialog_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3941 check_dialog_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3942 check_dialog_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
3943 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
3947 static void test_scrollwindow( HWND hwnd
)
3953 ShowWindow( hwnd
, SW_SHOW
);
3954 UpdateWindow( hwnd
);
3955 flush_events( TRUE
);
3956 GetClientRect( hwnd
, &rc
);
3958 /* test ScrollWindow(Ex) with no clip rectangle */
3959 /* paint the lower half of the window black */
3961 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
3962 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3963 /* paint the upper half of the window white */
3964 rc2
.bottom
= rc2
.top
;
3966 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
3967 /* scroll lower half up */
3969 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
3970 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, NULL
, NULL
, NULL
, SW_ERASE
);
3971 flush_events(FALSE
);
3972 /* expected: black should have scrolled to the upper half */
3973 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
3974 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3975 /* Repeat that test of ScrollWindow(Ex) now with clip rectangle */
3976 /* paint the lower half of the window black */
3978 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
3979 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
3980 /* paint the upper half of the window white */
3981 rc2
.bottom
= rc2
.top
;
3983 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
3984 /* scroll lower half up */
3986 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
3988 rc3
.left
= rc3
.right
/ 4;
3989 rc3
.right
-= rc3
.right
/ 4;
3990 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, &rc3
, NULL
, NULL
, SW_ERASE
);
3991 flush_events(FALSE
);
3992 /* expected: black should have scrolled to the upper half */
3993 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
3994 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
3997 ReleaseDC( hwnd
, hdc
);
4000 static void test_scrollvalidate( HWND parent
)
4003 HRGN hrgn
=CreateRectRgn(0,0,0,0);
4004 HRGN exprgn
, tmprgn
, clipping
;
4005 RECT rc
, rcu
, cliprc
;
4006 /* create two overlapping child windows. The visual region
4007 * of hwnd1 is clipped by the overlapping part of
4008 * hwnd2 because of the WS_CLIPSIBLING style */
4011 clipping
= CreateRectRgn(0,0,0,0);
4012 tmprgn
= CreateRectRgn(0,0,0,0);
4013 exprgn
= CreateRectRgn(0,0,0,0);
4014 hwnd2
= CreateWindowExA(0, "static", NULL
,
4015 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4016 75, 30, 100, 100, parent
, 0, 0, NULL
);
4017 hwnd1
= CreateWindowExA(0, "static", NULL
,
4018 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4019 25, 50, 100, 100, parent
, 0, 0, NULL
);
4020 ShowWindow( parent
, SW_SHOW
);
4021 UpdateWindow( parent
);
4022 GetClientRect( hwnd1
, &rc
);
4024 SetRectRgn( clipping
, 10, 10, 90, 90);
4025 hdc
= GetDC( hwnd1
);
4026 /* for a visual touch */
4027 TextOut( hdc
, 0,10, "0123456789", 10);
4028 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4029 if (winetest_debug
> 0) dump_region(hrgn
);
4030 /* create a region with what is expected */
4031 SetRectRgn( exprgn
, 39,0,49,74);
4032 SetRectRgn( tmprgn
, 88,79,98,93);
4033 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4034 SetRectRgn( tmprgn
, 0,93,98,98);
4035 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4036 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4037 trace("update rect is %d,%d - %d,%d\n",
4038 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
4039 /* now with clipping region */
4040 SelectClipRgn( hdc
, clipping
);
4041 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4042 if (winetest_debug
> 0) dump_region(hrgn
);
4043 /* create a region with what is expected */
4044 SetRectRgn( exprgn
, 39,10,49,74);
4045 SetRectRgn( tmprgn
, 80,79,90,85);
4046 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4047 SetRectRgn( tmprgn
, 10,85,90,90);
4048 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4049 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4050 trace("update rect is %d,%d - %d,%d\n",
4051 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
4052 ReleaseDC( hwnd1
, hdc
);
4054 /* test scrolling a window with an update region */
4055 DestroyWindow( hwnd2
);
4056 ValidateRect( hwnd1
, NULL
);
4057 SetRect( &rc
, 40,40, 50,50);
4058 InvalidateRect( hwnd1
, &rc
, 1);
4059 GetClientRect( hwnd1
, &rc
);
4061 ScrollWindowEx( hwnd1
, -10, 0, &rc
, &cliprc
, hrgn
, &rcu
,
4062 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4063 if (winetest_debug
> 0) dump_region(hrgn
);
4064 SetRectRgn( exprgn
, 88,0,98,98);
4065 SetRectRgn( tmprgn
, 30, 40, 50, 50);
4066 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4067 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4069 /* clear an update region */
4070 UpdateWindow( hwnd1
);
4072 SetRect( &rc
, 0,40, 100,60);
4073 SetRect( &cliprc
, 0,0, 100,100);
4074 ScrollWindowEx( hwnd1
, 0, -25, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4075 if (winetest_debug
> 0) dump_region( hrgn
);
4076 SetRectRgn( exprgn
, 0, 40, 98, 60 );
4077 ok( EqualRgn( exprgn
, hrgn
), "wrong update region in excessive scroll\n");
4079 /* now test ScrollWindowEx with a combination of
4080 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
4081 /* make hwnd2 the child of hwnd1 */
4082 hwnd2
= CreateWindowExA(0, "static", NULL
,
4083 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
4084 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
4085 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
4086 GetClientRect( hwnd1
, &rc
);
4089 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
4090 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
4091 ValidateRect( hwnd1
, NULL
);
4092 ValidateRect( hwnd2
, NULL
);
4093 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
4094 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4095 if (winetest_debug
> 0) dump_region(hrgn
);
4096 SetRectRgn( exprgn
, 88,0,98,88);
4097 SetRectRgn( tmprgn
, 0,88,98,98);
4098 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4099 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4101 /* SW_SCROLLCHILDREN */
4102 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
4103 ValidateRect( hwnd1
, NULL
);
4104 ValidateRect( hwnd2
, NULL
);
4105 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4106 if (winetest_debug
> 0) dump_region(hrgn
);
4107 /* expected region is the same as in previous test */
4108 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4110 /* no SW_SCROLLCHILDREN */
4111 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
4112 ValidateRect( hwnd1
, NULL
);
4113 ValidateRect( hwnd2
, NULL
);
4114 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4115 if (winetest_debug
> 0) dump_region(hrgn
);
4116 /* expected region is the same as in previous test */
4117 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4119 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
4120 SetWindowLong( hwnd1
, GWL_STYLE
, GetWindowLong( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
4121 ValidateRect( hwnd1
, NULL
);
4122 ValidateRect( hwnd2
, NULL
);
4123 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4124 if (winetest_debug
> 0) dump_region(hrgn
);
4125 SetRectRgn( exprgn
, 88,0,98,20);
4126 SetRectRgn( tmprgn
, 20,20,98,30);
4127 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4128 SetRectRgn( tmprgn
, 20,30,30,88);
4129 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4130 SetRectRgn( tmprgn
, 0,88,30,98);
4131 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4132 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4135 DeleteObject( hrgn
);
4136 DeleteObject( exprgn
);
4137 DeleteObject( tmprgn
);
4138 DestroyWindow( hwnd1
);
4139 DestroyWindow( hwnd2
);
4142 /* couple of tests of return values of scrollbar functions
4143 * called on a scrollbarless window */
4144 static void test_scroll(void)
4149 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
4150 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
4151 100, 100, 200, 200, 0, 0, 0, NULL
);
4153 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
4154 if (!ret
) /* win9x */
4156 win_skip( "GetScrollRange doesn't work\n" );
4157 DestroyWindow( hwnd
);
4160 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
4161 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
4162 si
.cbSize
= sizeof( si
);
4163 si
.fMask
= SIF_PAGE
;
4164 si
.nPage
= 0xdeadbeef;
4165 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
4166 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
4167 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
4169 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
4170 ok( ret
, "GetScrollRange returns FALSE\n");
4171 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
4172 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
4173 si
.cbSize
= sizeof( si
);
4174 si
.fMask
= SIF_PAGE
;
4175 si
.nPage
= 0xdeadbeef;
4176 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
4177 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
4178 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
4180 DestroyWindow( hwnd
);
4183 static void test_scrolldc( HWND parent
)
4186 HRGN exprgn
, tmprgn
, hrgn
;
4187 RECT rc
, rc2
, rcu
, cliprc
;
4191 hrgn
= CreateRectRgn(0,0,0,0);
4192 tmprgn
= CreateRectRgn(0,0,0,0);
4193 exprgn
= CreateRectRgn(0,0,0,0);
4195 hwnd1
= CreateWindowExA(0, "static", NULL
,
4196 WS_CHILD
| WS_VISIBLE
,
4197 25, 50, 100, 100, parent
, 0, 0, NULL
);
4198 ShowWindow( parent
, SW_SHOW
);
4199 UpdateWindow( parent
);
4200 flush_events( TRUE
);
4201 GetClientRect( hwnd1
, &rc
);
4202 hdc
= GetDC( hwnd1
);
4203 /* paint the upper half of the window black */
4205 rc2
.bottom
= ( rc
.top
+ rc
.bottom
) /2;
4206 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4207 /* clip region is the lower half */
4209 cliprc
.top
= (rc
.top
+ rc
.bottom
) /2;
4210 /* test whether scrolled pixels are properly clipped */
4211 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
4212 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4213 /* this scroll should not cause any visible changes */
4214 ScrollDC( hdc
, 5, -20, &rc
, &cliprc
, hrgn
, &rcu
);
4215 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
4216 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4217 /* test with NULL clip rect */
4218 ScrollDC( hdc
, 20, -20, &rc
, NULL
, hrgn
, &rcu
);
4219 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
4220 trace("update rect: %d,%d - %d,%d\n",
4221 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
4222 if (winetest_debug
> 0) dump_region(hrgn
);
4223 SetRect(&rc2
, 0, 0, 100, 100);
4224 ok(EqualRect(&rcu
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
4225 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
4227 SetRectRgn( exprgn
, 0, 0, 20, 80);
4228 SetRectRgn( tmprgn
, 0, 80, 100, 100);
4229 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
4230 if (winetest_debug
> 0) dump_region(exprgn
);
4231 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
4232 /* test clip rect > scroll rect */
4233 FillRect( hdc
, &rc
, GetStockObject(WHITE_BRUSH
));
4235 InflateRect( &rc2
, -(rc
.right
-rc
.left
)/4, -(rc
.bottom
-rc
.top
)/4);
4236 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4237 ScrollDC( hdc
, 10, 10, &rc2
, &rc
, hrgn
, &rcu
);
4238 SetRectRgn( exprgn
, 25, 25, 75, 35);
4239 SetRectRgn( tmprgn
, 25, 35, 35, 75);
4240 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
4241 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
4242 trace("update rect: %d,%d - %d,%d\n",
4243 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
4244 if (winetest_debug
> 0) dump_region(hrgn
);
4248 DeleteObject(exprgn
);
4249 DeleteObject(tmprgn
);
4250 DestroyWindow(hwnd1
);
4253 static void test_params(void)
4258 ok(!IsWindow(0), "IsWindow(0)\n");
4259 ok(!IsWindow(HWND_BROADCAST
), "IsWindow(HWND_BROADCAST)\n");
4260 ok(!IsWindow(HWND_TOPMOST
), "IsWindow(HWND_TOPMOST)\n");
4262 /* Just a param check */
4263 if (pGetMonitorInfoA
)
4265 SetLastError(0xdeadbeef);
4266 rc
= GetWindowText(hwndMain2
, NULL
, 1024);
4267 ok( rc
==0, "GetWindowText: rc=%d err=%d\n",rc
,GetLastError());
4271 /* Skips actually on Win95 and NT4 */
4272 win_skip("Test would crash on Win95\n");
4275 SetLastError(0xdeadbeef);
4276 hwnd
=CreateWindow("LISTBOX", "TestList",
4277 (LBS_STANDARD
& ~LBS_SORT
),
4279 NULL
, (HMENU
)1, NULL
, 0);
4281 ok(!hwnd
|| broken(hwnd
!= NULL
), /* w2k3 sp2 */
4282 "CreateWindow with invalid menu handle should fail\n");
4284 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
|| /* NT */
4285 GetLastError() == 0xdeadbeef, /* Win9x */
4286 "wrong last error value %d\n", GetLastError());
4289 static void test_AWRwindow(LPCSTR
class, LONG style
, LONG exStyle
, BOOL menu
)
4293 hwnd
= CreateWindowEx(exStyle
, class, class, style
,
4300 trace("Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style
, exStyle
);
4303 ShowWindow(hwnd
, SW_SHOW
);
4305 test_nonclient_area(hwnd
);
4308 DestroyWindow(hwnd
);
4311 static BOOL
AWR_init(void)
4315 class.style
= CS_HREDRAW
| CS_VREDRAW
;
4316 class.lpfnWndProc
= DefWindowProcA
;
4317 class.cbClsExtra
= 0;
4318 class.cbWndExtra
= 0;
4319 class.hInstance
= 0;
4320 class.hIcon
= LoadIcon (0, IDI_APPLICATION
);
4321 class.hCursor
= LoadCursor (0, IDC_ARROW
);
4322 class.hbrBackground
= 0;
4323 class.lpszMenuName
= 0;
4324 class.lpszClassName
= szAWRClass
;
4326 if (!RegisterClass (&class)) {
4327 ok(FALSE
, "RegisterClass failed\n");
4331 hmenu
= CreateMenu();
4334 ok(hmenu
!= 0, "Failed to create menu\n");
4335 ok(AppendMenu(hmenu
, MF_STRING
, 1, "Test!"), "Failed to create menu item\n");
4341 static void test_AWR_window_size(BOOL menu
)
4345 WS_MAXIMIZE
, WS_BORDER
, WS_DLGFRAME
,
4348 WS_MINIMIZEBOX
, WS_MAXIMIZEBOX
,
4349 WS_HSCROLL
, WS_VSCROLL
4353 WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
,
4356 /* These styles have problems on (at least) WinXP (SP2) and Wine */
4357 WS_EX_DLGMODALFRAME
,
4364 /* A exhaustive check of all the styles takes too long
4365 * so just do a (hopefully representative) sample
4367 for (i
= 0; i
< COUNTOF(styles
); ++i
)
4368 test_AWRwindow(szAWRClass
, styles
[i
], 0, menu
);
4369 for (i
= 0; i
< COUNTOF(exStyles
); ++i
) {
4370 test_AWRwindow(szAWRClass
, WS_POPUP
, exStyles
[i
], menu
);
4371 test_AWRwindow(szAWRClass
, WS_THICKFRAME
, exStyles
[i
], menu
);
4376 #define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
4378 static void test_AdjustWindowRect(void)
4383 SHOWSYSMETRIC(SM_CYCAPTION
);
4384 SHOWSYSMETRIC(SM_CYSMCAPTION
);
4385 SHOWSYSMETRIC(SM_CYMENU
);
4386 SHOWSYSMETRIC(SM_CXEDGE
);
4387 SHOWSYSMETRIC(SM_CYEDGE
);
4388 SHOWSYSMETRIC(SM_CXVSCROLL
);
4389 SHOWSYSMETRIC(SM_CYHSCROLL
);
4390 SHOWSYSMETRIC(SM_CXFRAME
);
4391 SHOWSYSMETRIC(SM_CYFRAME
);
4392 SHOWSYSMETRIC(SM_CXDLGFRAME
);
4393 SHOWSYSMETRIC(SM_CYDLGFRAME
);
4394 SHOWSYSMETRIC(SM_CXBORDER
);
4395 SHOWSYSMETRIC(SM_CYBORDER
);
4397 test_AWR_window_size(FALSE
);
4398 test_AWR_window_size(TRUE
);
4402 #undef SHOWSYSMETRIC
4405 /* Global variables to trigger exit from loop */
4406 static int redrawComplete
, WMPAINT_count
;
4408 static LRESULT WINAPI
redraw_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4413 trace("doing WM_PAINT %d\n", WMPAINT_count
);
4415 if (WMPAINT_count
> 10 && redrawComplete
== 0) {
4417 BeginPaint(hwnd
, &ps
);
4418 EndPaint(hwnd
, &ps
);
4423 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
4426 /* Ensure we exit from RedrawNow regardless of invalidated area */
4427 static void test_redrawnow(void)
4432 cls
.style
= CS_DBLCLKS
;
4433 cls
.lpfnWndProc
= redraw_window_procA
;
4436 cls
.hInstance
= GetModuleHandleA(0);
4438 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
4439 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4440 cls
.lpszMenuName
= NULL
;
4441 cls
.lpszClassName
= "RedrawWindowClass";
4443 if(!RegisterClassA(&cls
)) {
4444 trace("Register failed %d\n", GetLastError());
4448 hwndMain
= CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
4449 CW_USEDEFAULT
, 0, 100, 100, NULL
, NULL
, 0, NULL
);
4451 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4452 ShowWindow(hwndMain
, SW_SHOW
);
4453 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4454 RedrawWindow(hwndMain
, NULL
,NULL
,RDW_UPDATENOW
| RDW_ALLCHILDREN
);
4455 ok( WMPAINT_count
== 1 || broken(WMPAINT_count
== 0), /* sometimes on win9x */
4456 "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4457 redrawComplete
= TRUE
;
4458 ok( WMPAINT_count
< 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count
);
4461 DestroyWindow( hwndMain
);
4464 struct parentdc_stat
{
4470 struct parentdc_test
{
4471 struct parentdc_stat main
, main_todo
;
4472 struct parentdc_stat child1
, child1_todo
;
4473 struct parentdc_stat child2
, child2_todo
;
4476 static LRESULT WINAPI
parentdc_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4481 struct parentdc_stat
*t
= (struct parentdc_stat
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
4486 GetClientRect(hwnd
, &rc
);
4487 CopyRect(&t
->client
, &rc
);
4488 GetWindowRect(hwnd
, &rc
);
4489 trace("WM_PAINT: hwnd %p, client rect (%d,%d)-(%d,%d), window rect (%d,%d)-(%d,%d)\n", hwnd
,
4490 t
->client
.left
, t
->client
.top
, t
->client
.right
, t
->client
.bottom
,
4491 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4492 BeginPaint(hwnd
, &ps
);
4493 CopyRect(&t
->paint
, &ps
.rcPaint
);
4494 GetClipBox(ps
.hdc
, &rc
);
4495 CopyRect(&t
->clip
, &rc
);
4496 trace("clip rect (%d,%d)-(%d,%d), paint rect (%d,%d)-(%d,%d)\n",
4497 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
4498 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
4499 EndPaint(hwnd
, &ps
);
4502 return DefWindowProc(hwnd
, msg
, wparam
, lparam
);
4505 static void zero_parentdc_stat(struct parentdc_stat
*t
)
4507 SetRectEmpty(&t
->client
);
4508 SetRectEmpty(&t
->clip
);
4509 SetRectEmpty(&t
->paint
);
4512 static void zero_parentdc_test(struct parentdc_test
*t
)
4514 zero_parentdc_stat(&t
->main
);
4515 zero_parentdc_stat(&t
->child1
);
4516 zero_parentdc_stat(&t
->child2
);
4519 #define parentdc_field_ok(t, w, r, f, got) \
4520 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
4521 ": expected %d, got %d\n", \
4524 #define parentdc_todo_field_ok(t, w, r, f, got) \
4525 if (t.w##_todo.r.f) todo_wine { parentdc_field_ok(t, w, r, f, got); } \
4526 else parentdc_field_ok(t, w, r, f, got)
4528 #define parentdc_rect_ok(t, w, r, got) \
4529 parentdc_todo_field_ok(t, w, r, left, got); \
4530 parentdc_todo_field_ok(t, w, r, top, got); \
4531 parentdc_todo_field_ok(t, w, r, right, got); \
4532 parentdc_todo_field_ok(t, w, r, bottom, got);
4534 #define parentdc_win_ok(t, w, got) \
4535 parentdc_rect_ok(t, w, client, got); \
4536 parentdc_rect_ok(t, w, clip, got); \
4537 parentdc_rect_ok(t, w, paint, got);
4539 #define parentdc_ok(t, got) \
4540 parentdc_win_ok(t, main, got); \
4541 parentdc_win_ok(t, child1, got); \
4542 parentdc_win_ok(t, child2, got);
4544 static void test_csparentdc(void)
4546 WNDCLASSA clsMain
, cls
;
4547 HWND hwndMain
, hwnd1
, hwnd2
;
4550 struct parentdc_test test_answer
;
4552 #define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
4553 const struct parentdc_test test1
=
4555 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo
,
4556 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4557 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4560 const struct parentdc_test test2
=
4562 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo
,
4563 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4564 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4567 const struct parentdc_test test3
=
4569 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4570 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4571 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4574 const struct parentdc_test test4
=
4576 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo
,
4577 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo
,
4578 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4581 const struct parentdc_test test5
=
4583 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo
,
4584 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4585 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4588 const struct parentdc_test test6
=
4590 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4591 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4592 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4595 const struct parentdc_test test7
=
4597 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4598 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4599 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4603 clsMain
.style
= CS_DBLCLKS
;
4604 clsMain
.lpfnWndProc
= parentdc_window_procA
;
4605 clsMain
.cbClsExtra
= 0;
4606 clsMain
.cbWndExtra
= 0;
4607 clsMain
.hInstance
= GetModuleHandleA(0);
4609 clsMain
.hCursor
= LoadCursorA(0, IDC_ARROW
);
4610 clsMain
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4611 clsMain
.lpszMenuName
= NULL
;
4612 clsMain
.lpszClassName
= "ParentDcMainWindowClass";
4614 if(!RegisterClassA(&clsMain
)) {
4615 trace("Register failed %d\n", GetLastError());
4619 cls
.style
= CS_DBLCLKS
| CS_PARENTDC
;
4620 cls
.lpfnWndProc
= parentdc_window_procA
;
4623 cls
.hInstance
= GetModuleHandleA(0);
4625 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
4626 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4627 cls
.lpszMenuName
= NULL
;
4628 cls
.lpszClassName
= "ParentDcWindowClass";
4630 if(!RegisterClassA(&cls
)) {
4631 trace("Register failed %d\n", GetLastError());
4635 SetRect(&rc
, 0, 0, 150, 150);
4636 AdjustWindowRectEx(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
, 0);
4637 hwndMain
= CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
4638 CW_USEDEFAULT
, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, NULL
, NULL
, 0, NULL
);
4639 SetWindowLongPtrA(hwndMain
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.main
);
4640 hwnd1
= CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD
,
4641 20, 20, 40, 40, hwndMain
, NULL
, 0, NULL
);
4642 SetWindowLongPtrA(hwnd1
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child1
);
4643 hwnd2
= CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD
,
4644 40, 40, 40, 40, hwndMain
, NULL
, 0, NULL
);
4645 SetWindowLongPtrA(hwnd2
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child2
);
4646 ShowWindow(hwndMain
, SW_SHOW
);
4647 ShowWindow(hwnd1
, SW_SHOW
);
4648 ShowWindow(hwnd2
, SW_SHOW
);
4649 SetWindowPos(hwndMain
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
4650 flush_events( TRUE
);
4652 zero_parentdc_test(&test_answer
);
4653 InvalidateRect(hwndMain
, NULL
, TRUE
);
4654 flush_events( TRUE
);
4655 parentdc_ok(test1
, test_answer
);
4657 zero_parentdc_test(&test_answer
);
4658 SetRect(&rc
, 0, 0, 50, 50);
4659 InvalidateRect(hwndMain
, &rc
, TRUE
);
4660 flush_events( TRUE
);
4661 parentdc_ok(test2
, test_answer
);
4663 zero_parentdc_test(&test_answer
);
4664 SetRect(&rc
, 0, 0, 10, 10);
4665 InvalidateRect(hwndMain
, &rc
, TRUE
);
4666 flush_events( TRUE
);
4667 parentdc_ok(test3
, test_answer
);
4669 zero_parentdc_test(&test_answer
);
4670 SetRect(&rc
, 40, 40, 50, 50);
4671 InvalidateRect(hwndMain
, &rc
, TRUE
);
4672 flush_events( TRUE
);
4673 parentdc_ok(test4
, test_answer
);
4675 zero_parentdc_test(&test_answer
);
4676 SetRect(&rc
, 20, 20, 60, 60);
4677 InvalidateRect(hwndMain
, &rc
, TRUE
);
4678 flush_events( TRUE
);
4679 parentdc_ok(test5
, test_answer
);
4681 zero_parentdc_test(&test_answer
);
4682 SetRect(&rc
, 0, 0, 10, 10);
4683 InvalidateRect(hwnd1
, &rc
, TRUE
);
4684 flush_events( TRUE
);
4685 parentdc_ok(test6
, test_answer
);
4687 zero_parentdc_test(&test_answer
);
4688 SetRect(&rc
, -5, -5, 65, 65);
4689 InvalidateRect(hwnd1
, &rc
, TRUE
);
4690 flush_events( TRUE
);
4691 parentdc_ok(test7
, test_answer
);
4693 DestroyWindow(hwndMain
);
4694 DestroyWindow(hwnd1
);
4695 DestroyWindow(hwnd2
);
4698 static LRESULT WINAPI
def_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4700 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4703 static LRESULT WINAPI
def_window_procW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4705 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
4708 static void test_IsWindowUnicode(void)
4710 static const char ansi_class_nameA
[] = "ansi class name";
4711 static const WCHAR ansi_class_nameW
[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
4712 static const char unicode_class_nameA
[] = "unicode class name";
4713 static const WCHAR unicode_class_nameW
[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
4718 memset(&classW
, 0, sizeof(classW
));
4719 classW
.hInstance
= GetModuleHandleA(0);
4720 classW
.lpfnWndProc
= def_window_procW
;
4721 classW
.lpszClassName
= unicode_class_nameW
;
4722 if (!RegisterClassW(&classW
)) return; /* this catches Win9x as well */
4724 memset(&classA
, 0, sizeof(classA
));
4725 classA
.hInstance
= GetModuleHandleA(0);
4726 classA
.lpfnWndProc
= def_window_procA
;
4727 classA
.lpszClassName
= ansi_class_nameA
;
4728 assert(RegisterClassA(&classA
));
4730 /* unicode class: window proc */
4731 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
4732 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4735 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4736 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4737 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4738 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4739 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4741 DestroyWindow(hwnd
);
4743 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
4744 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4747 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4748 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4749 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4750 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4751 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4753 DestroyWindow(hwnd
);
4755 /* ansi class: window proc */
4756 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
4757 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4760 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4761 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4762 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4763 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4764 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4766 DestroyWindow(hwnd
);
4768 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
4769 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4772 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4773 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4774 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4775 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4776 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4778 DestroyWindow(hwnd
);
4780 /* unicode class: class proc */
4781 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
4782 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4785 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4786 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4787 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4788 /* do not restore class window proc back to unicode */
4790 DestroyWindow(hwnd
);
4792 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
4793 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4796 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4797 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4798 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4800 DestroyWindow(hwnd
);
4802 /* ansi class: class proc */
4803 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
4804 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4807 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4808 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4809 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4810 /* do not restore class window proc back to ansi */
4812 DestroyWindow(hwnd
);
4814 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
4815 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4818 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4819 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4820 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4822 DestroyWindow(hwnd
);
4825 static LRESULT CALLBACK
minmax_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
4829 if (msg
!= WM_GETMINMAXINFO
)
4830 return DefWindowProc(hwnd
, msg
, wp
, lp
);
4832 minmax
= (MINMAXINFO
*)lp
;
4834 if ((GetWindowLong(hwnd
, GWL_STYLE
) & WS_CHILD
))
4836 minmax
->ptReserved
.x
= 0;
4837 minmax
->ptReserved
.y
= 0;
4838 minmax
->ptMaxSize
.x
= 400;
4839 minmax
->ptMaxSize
.y
= 400;
4840 minmax
->ptMaxPosition
.x
= 300;
4841 minmax
->ptMaxPosition
.y
= 300;
4842 minmax
->ptMaxTrackSize
.x
= 200;
4843 minmax
->ptMaxTrackSize
.y
= 200;
4844 minmax
->ptMinTrackSize
.x
= 100;
4845 minmax
->ptMinTrackSize
.y
= 100;
4848 DefWindowProc(hwnd
, msg
, wp
, lp
);
4852 static int expected_cx
, expected_cy
;
4853 static RECT expected_rect
, broken_rect
;
4855 static LRESULT CALLBACK
winsizes_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
4859 case WM_GETMINMAXINFO
:
4862 GetWindowRect( hwnd
, &rect
);
4863 ok( !rect
.left
&& !rect
.top
&& !rect
.right
&& !rect
.bottom
,
4864 "wrong rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
4865 return DefWindowProc(hwnd
, msg
, wp
, lp
);
4870 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
4872 GetWindowRect( hwnd
, &rect
);
4873 trace( "hwnd %p msg %x size %dx%d rect %d,%d-%d,%d\n",
4874 hwnd
, msg
, cs
->cx
, cs
->cy
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
4875 ok( cs
->cx
== expected_cx
|| broken(cs
->cx
== (short)expected_cx
),
4876 "wrong x size %d/%d\n", cs
->cx
, expected_cx
);
4877 ok( cs
->cy
== expected_cy
|| broken(cs
->cy
== (short)expected_cy
),
4878 "wrong y size %d/%d\n", cs
->cy
, expected_cy
);
4879 ok( (rect
.right
- rect
.left
== expected_rect
.right
- expected_rect
.left
&&
4880 rect
.bottom
- rect
.top
== expected_rect
.bottom
- expected_rect
.top
) ||
4881 (rect
.right
- rect
.left
== min( 65535, expected_rect
.right
- expected_rect
.left
) &&
4882 rect
.bottom
- rect
.top
== min( 65535, expected_rect
.bottom
- expected_rect
.top
)) ||
4883 broken( rect
.right
- rect
.left
== broken_rect
.right
- broken_rect
.left
&&
4884 rect
.bottom
- rect
.top
== broken_rect
.bottom
- broken_rect
.top
) ||
4885 broken( rect
.right
- rect
.left
== (short)broken_rect
.right
- (short)broken_rect
.left
&&
4886 rect
.bottom
- rect
.top
== (short)broken_rect
.bottom
- (short)broken_rect
.top
),
4887 "wrong rect %d,%d-%d,%d / %d,%d-%d,%d\n",
4888 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
4889 expected_rect
.left
, expected_rect
.top
, expected_rect
.right
, expected_rect
.bottom
);
4890 return DefWindowProc(hwnd
, msg
, wp
, lp
);
4894 RECT rect
, *r
= (RECT
*)lp
;
4895 GetWindowRect( hwnd
, &rect
);
4896 ok( !memcmp( &rect
, r
, sizeof(rect
) ),
4897 "passed rect %d,%d-%d,%d doesn't match window rect %d,%d-%d,%d\n",
4898 r
->left
, r
->top
, r
->right
, r
->bottom
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
4899 return DefWindowProc(hwnd
, msg
, wp
, lp
);
4902 return DefWindowProc(hwnd
, msg
, wp
, lp
);
4906 static void test_CreateWindow(void)
4915 #define expect_menu(window, menu) \
4916 SetLastError(0xdeadbeef); \
4917 res = (GetMenu(window) == (HMENU)menu); \
4918 ok(res, "GetMenu error %d\n", GetLastError())
4920 #define expect_style(window, style)\
4921 ok((ULONG)GetWindowLong(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLong(window, GWL_STYLE))
4923 #define expect_ex_style(window, ex_style)\
4924 ok((ULONG)GetWindowLong(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLong(window, GWL_EXSTYLE))
4926 #define expect_gle_broken_9x(gle)\
4927 ok(GetLastError() == gle ||\
4928 broken(GetLastError() == 0xdeadbeef),\
4929 "IsMenu set error %d\n", GetLastError())
4931 hmenu
= CreateMenu();
4933 parent
= GetDesktopWindow();
4934 assert(parent
!= 0);
4936 SetLastError(0xdeadbeef);
4937 res
= IsMenu(hmenu
);
4938 ok(res
, "IsMenu error %d\n", GetLastError());
4941 SetLastError(0xdeadbeef);
4942 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
,
4943 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4944 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4945 expect_menu(hwnd
, 1);
4946 expect_style(hwnd
, WS_CHILD
);
4947 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
4948 DestroyWindow(hwnd
);
4950 SetLastError(0xdeadbeef);
4951 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_CAPTION
,
4952 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4953 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4954 expect_menu(hwnd
, 1);
4955 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
4956 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
4957 DestroyWindow(hwnd
);
4959 SetLastError(0xdeadbeef);
4960 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
,
4961 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4962 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4963 expect_menu(hwnd
, 1);
4964 expect_style(hwnd
, WS_CHILD
);
4965 expect_ex_style(hwnd
, 0);
4966 DestroyWindow(hwnd
);
4968 SetLastError(0xdeadbeef);
4969 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_CAPTION
,
4970 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
4971 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4972 expect_menu(hwnd
, 1);
4973 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
4974 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
4975 DestroyWindow(hwnd
);
4978 SetLastError(0xdeadbeef);
4979 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
4980 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4981 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4982 expect_menu(hwnd
, hmenu
);
4983 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
4984 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
4985 DestroyWindow(hwnd
);
4986 SetLastError(0xdeadbeef);
4987 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
4988 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
4990 hmenu
= CreateMenu();
4992 SetLastError(0xdeadbeef);
4993 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
| WS_CAPTION
,
4994 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
4995 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
4996 expect_menu(hwnd
, hmenu
);
4997 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
4998 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
4999 DestroyWindow(hwnd
);
5000 SetLastError(0xdeadbeef);
5001 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5002 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5004 hmenu
= CreateMenu();
5006 SetLastError(0xdeadbeef);
5007 hwnd
= CreateWindowEx(0, "static", NULL
, WS_POPUP
,
5008 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5009 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5010 expect_menu(hwnd
, hmenu
);
5011 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
5012 expect_ex_style(hwnd
, 0);
5013 DestroyWindow(hwnd
);
5014 SetLastError(0xdeadbeef);
5015 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5016 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5018 hmenu
= CreateMenu();
5020 SetLastError(0xdeadbeef);
5021 hwnd
= CreateWindowEx(0, "static", NULL
, WS_POPUP
| WS_CAPTION
,
5022 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5023 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5024 expect_menu(hwnd
, hmenu
);
5025 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5026 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5027 DestroyWindow(hwnd
);
5028 SetLastError(0xdeadbeef);
5029 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5030 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5032 /* WS_CHILD | WS_POPUP */
5033 SetLastError(0xdeadbeef);
5034 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5035 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5036 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5037 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5039 DestroyWindow(hwnd
);
5041 hmenu
= CreateMenu();
5043 SetLastError(0xdeadbeef);
5044 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5045 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5046 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5047 expect_menu(hwnd
, hmenu
);
5048 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
5049 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5050 DestroyWindow(hwnd
);
5051 SetLastError(0xdeadbeef);
5052 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5053 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5055 SetLastError(0xdeadbeef);
5056 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5057 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5058 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5059 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5061 DestroyWindow(hwnd
);
5063 hmenu
= CreateMenu();
5065 SetLastError(0xdeadbeef);
5066 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5067 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5068 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5069 expect_menu(hwnd
, hmenu
);
5070 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5071 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5072 DestroyWindow(hwnd
);
5073 SetLastError(0xdeadbeef);
5074 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5075 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5077 SetLastError(0xdeadbeef);
5078 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
5079 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5080 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5081 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5083 DestroyWindow(hwnd
);
5085 hmenu
= CreateMenu();
5087 SetLastError(0xdeadbeef);
5088 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
5089 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5090 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5091 expect_menu(hwnd
, hmenu
);
5092 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
5093 expect_ex_style(hwnd
, 0);
5094 DestroyWindow(hwnd
);
5095 SetLastError(0xdeadbeef);
5096 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5097 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5099 SetLastError(0xdeadbeef);
5100 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5101 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5102 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5103 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5105 DestroyWindow(hwnd
);
5107 hmenu
= CreateMenu();
5109 SetLastError(0xdeadbeef);
5110 hwnd
= CreateWindowEx(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5111 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5112 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5113 expect_menu(hwnd
, hmenu
);
5114 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5115 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5116 DestroyWindow(hwnd
);
5117 SetLastError(0xdeadbeef);
5118 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5119 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5121 /* test child window sizing */
5123 cls
.lpfnWndProc
= minmax_wnd_proc
;
5126 cls
.hInstance
= GetModuleHandle(0);
5128 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
5129 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5130 cls
.lpszMenuName
= NULL
;
5131 cls
.lpszClassName
= "MinMax_WndClass";
5132 RegisterClass(&cls
);
5134 SetLastError(0xdeadbeef);
5135 parent
= CreateWindowEx(0, "MinMax_WndClass", NULL
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
5136 0, 0, 100, 100, 0, 0, 0, NULL
);
5137 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
5138 expect_menu(parent
, 0);
5139 expect_style(parent
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
| WS_CLIPSIBLINGS
);
5140 expect_ex_style(parent
, WS_EX_WINDOWEDGE
);
5142 memset(&minmax
, 0, sizeof(minmax
));
5143 SendMessage(parent
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
5144 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxSize
.x
, minmax
.ptMaxSize
.y
);
5145 ok(IsRectEmpty(&rc_minmax
), "ptMaxSize is not empty\n");
5146 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
5147 ok(IsRectEmpty(&rc_minmax
), "ptMaxTrackSize is not empty\n");
5149 GetWindowRect(parent
, &rc
);
5150 ok(!IsRectEmpty(&rc
), "parent window rect is empty\n");
5151 GetClientRect(parent
, &rc
);
5152 ok(!IsRectEmpty(&rc
), "parent client rect is empty\n");
5154 InflateRect(&rc
, 200, 200);
5155 trace("creating child with rect (%d,%d-%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5157 SetLastError(0xdeadbeef);
5158 hwnd
= CreateWindowEx(0, "MinMax_WndClass", NULL
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
5159 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
5160 parent
, (HMENU
)1, 0, NULL
);
5161 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5162 expect_menu(hwnd
, 1);
5163 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
);
5164 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5166 memset(&minmax
, 0, sizeof(minmax
));
5167 SendMessage(hwnd
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
5168 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
5170 GetWindowRect(hwnd
, &rc
);
5171 OffsetRect(&rc
, -rc
.left
, -rc
.top
);
5172 ok(EqualRect(&rc
, &rc_minmax
), "rects don't match: (%d,%d-%d,%d) and (%d,%d-%d,%d)\n",
5173 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
5174 rc_minmax
.left
, rc_minmax
.top
, rc_minmax
.right
, rc_minmax
.bottom
);
5175 DestroyWindow(hwnd
);
5177 cls
.lpfnWndProc
= winsizes_wnd_proc
;
5178 cls
.lpszClassName
= "Sizes_WndClass";
5179 RegisterClass(&cls
);
5181 expected_cx
= expected_cy
= 200000;
5182 SetRect( &expected_rect
, 0, 0, 200000, 200000 );
5183 broken_rect
= expected_rect
;
5184 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 300000, 300000, 200000, 200000, parent
, 0, 0, NULL
);
5185 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5186 GetClientRect( hwnd
, &rc
);
5187 ok( rc
.right
== 200000 || rc
.right
== 65535 || broken(rc
.right
== (short)200000),
5188 "invalid rect right %u\n", rc
.right
);
5189 ok( rc
.bottom
== 200000 || rc
.bottom
== 65535 || broken(rc
.bottom
== (short)200000),
5190 "invalid rect bottom %u\n", rc
.bottom
);
5191 DestroyWindow(hwnd
);
5193 expected_cx
= expected_cy
= -10;
5194 SetRect( &expected_rect
, 0, 0, 0, 0 );
5195 SetRect( &broken_rect
, 0, 0, -10, -10 );
5196 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -20, -20, -10, -10, parent
, 0, 0, NULL
);
5197 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5198 GetClientRect( hwnd
, &rc
);
5199 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
5200 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
5201 DestroyWindow(hwnd
);
5203 expected_cx
= expected_cy
= -200000;
5204 SetRect( &expected_rect
, 0, 0, 0, 0 );
5205 SetRect( &broken_rect
, 0, 0, -200000, -200000 );
5206 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -300000, -300000, -200000, -200000, parent
, 0, 0, NULL
);
5207 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5208 GetClientRect( hwnd
, &rc
);
5209 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
5210 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
5211 DestroyWindow(hwnd
);
5213 /* we need a parent at 0,0 so that child coordinates match */
5214 DestroyWindow(parent
);
5215 parent
= CreateWindowEx(0, "MinMax_WndClass", NULL
, WS_POPUP
, 0, 0, 100, 100, 0, 0, 0, NULL
);
5216 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
5219 expected_cy
= 0x7fffffff;
5220 SetRect( &expected_rect
, 10, 10, 110, 0x7fffffff );
5221 SetRect( &broken_rect
, 10, 10, 110, 0x7fffffffU
+ 10 );
5222 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 10, 10, 100, 0x7fffffff, parent
, 0, 0, NULL
);
5223 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5224 GetClientRect( hwnd
, &rc
);
5225 ok( rc
.right
== 100, "invalid rect right %u\n", rc
.right
);
5226 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.bottom
==65535 || broken(rc
.bottom
== 0),
5227 "invalid rect bottom %u\n", rc
.bottom
);
5228 DestroyWindow(hwnd
);
5230 expected_cx
= 0x7fffffff;
5231 expected_cy
= 0x7fffffff;
5232 SetRect( &expected_rect
, 20, 10, 0x7fffffff, 0x7fffffff );
5233 SetRect( &broken_rect
, 20, 10, 0x7fffffffU
+ 20, 0x7fffffffU
+ 10 );
5234 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 20, 10, 0x7fffffff, 0x7fffffff, parent
, 0, 0, NULL
);
5235 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5236 GetClientRect( hwnd
, &rc
);
5237 ok( rc
.right
== 0x7fffffff - 20 || rc
.right
== 65535 || broken(rc
.right
== 0),
5238 "invalid rect right %u\n", rc
.right
);
5239 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.right
== 65535 || broken(rc
.bottom
== 0),
5240 "invalid rect bottom %u\n", rc
.bottom
);
5241 DestroyWindow(hwnd
);
5243 /* top level window */
5244 expected_cx
= expected_cy
= 200000;
5245 SetRect( &expected_rect
, 0, 0, GetSystemMetrics(SM_CXMAXTRACK
), GetSystemMetrics(SM_CYMAXTRACK
) );
5246 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_OVERLAPPEDWINDOW
, 300000, 300000, 200000, 200000, 0, 0, 0, NULL
);
5247 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5248 GetClientRect( hwnd
, &rc
);
5249 ok( rc
.right
<= expected_cx
, "invalid rect right %u\n", rc
.right
);
5250 ok( rc
.bottom
<= expected_cy
, "invalid rect bottom %u\n", rc
.bottom
);
5251 DestroyWindow(hwnd
);
5253 if (pGetLayout
&& pSetLayout
)
5255 HDC hdc
= GetDC( parent
);
5256 pSetLayout( hdc
, LAYOUT_RTL
);
5257 if (pGetLayout( hdc
))
5259 ReleaseDC( parent
, hdc
);
5260 DestroyWindow( parent
);
5261 SetLastError( 0xdeadbeef );
5262 parent
= CreateWindowEx(WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
,
5263 0, 0, 100, 100, 0, 0, 0, NULL
);
5264 ok( parent
!= 0, "creation failed err %u\n", GetLastError());
5265 expect_ex_style( parent
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
5266 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5267 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5268 expect_ex_style( hwnd
, WS_EX_LAYOUTRTL
);
5269 DestroyWindow( hwnd
);
5270 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5271 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5272 expect_ex_style( hwnd
, 0 );
5273 DestroyWindow( hwnd
);
5274 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
| WS_EX_NOINHERITLAYOUT
);
5275 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5276 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5277 expect_ex_style( hwnd
, 0 );
5278 DestroyWindow( hwnd
);
5280 if (pGetProcessDefaultLayout
&& pSetProcessDefaultLayout
)
5284 SetLastError( 0xdeadbeef );
5285 ok( !pGetProcessDefaultLayout( NULL
), "GetProcessDefaultLayout succeeded\n" );
5286 ok( GetLastError() == ERROR_NOACCESS
, "wrong error %u\n", GetLastError() );
5287 SetLastError( 0xdeadbeef );
5288 res
= pGetProcessDefaultLayout( &layout
);
5289 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5290 ok( layout
== 0, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5291 SetLastError( 0xdeadbeef );
5292 res
= pSetProcessDefaultLayout( 7 );
5293 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
5294 res
= pGetProcessDefaultLayout( &layout
);
5295 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5296 ok( layout
== 7, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5297 SetLastError( 0xdeadbeef );
5298 res
= pSetProcessDefaultLayout( LAYOUT_RTL
);
5299 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
5300 res
= pGetProcessDefaultLayout( &layout
);
5301 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5302 ok( layout
== LAYOUT_RTL
, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5303 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5304 0, 0, 100, 100, 0, 0, 0, NULL
);
5305 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5306 expect_ex_style( hwnd
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
5307 DestroyWindow( hwnd
);
5308 hwnd
= CreateWindowEx(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5309 0, 0, 100, 100, parent
, 0, 0, NULL
);
5310 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5311 expect_ex_style( hwnd
, WS_EX_APPWINDOW
);
5312 DestroyWindow( hwnd
);
5313 pSetProcessDefaultLayout( 0 );
5315 else win_skip( "SetProcessDefaultLayout not supported\n" );
5317 else win_skip( "SetLayout not supported\n" );
5319 else win_skip( "SetLayout not available\n" );
5321 DestroyWindow(parent
);
5323 UnregisterClass("MinMax_WndClass", GetModuleHandle(0));
5324 UnregisterClass("Sizes_WndClass", GetModuleHandle(0));
5326 #undef expect_gle_broken_9x
5329 #undef expect_ex_style
5332 /* function that remembers whether the system the test is running on sets the
5333 * last error for user32 functions to make the tests stricter */
5334 static int check_error(DWORD actual
, DWORD expected
)
5336 static int sets_last_error
= -1;
5337 if (sets_last_error
== -1)
5338 sets_last_error
= (actual
!= 0xdeadbeef);
5339 return (!sets_last_error
&& (actual
== 0xdeadbeef)) || (actual
== expected
);
5342 static void test_SetWindowLong(void)
5345 WNDPROC old_window_procW
;
5347 SetLastError(0xdeadbeef);
5348 retval
= SetWindowLongPtr(NULL
, GWLP_WNDPROC
, 0);
5349 ok(!retval
, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval
);
5350 ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE
),
5351 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instead of %d\n", GetLastError());
5353 SetLastError(0xdeadbeef);
5354 retval
= SetWindowLongPtr(hwndMain
, 0xdeadbeef, 0);
5355 ok(!retval
, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval
);
5356 ok(check_error(GetLastError(), ERROR_INVALID_INDEX
),
5357 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instead of %d\n", GetLastError());
5359 SetLastError(0xdeadbeef);
5360 retval
= SetWindowLongPtr(hwndMain
, GWLP_WNDPROC
, 0);
5361 ok((WNDPROC
)retval
== main_window_procA
|| broken(!retval
), /* win9x */
5362 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval
);
5363 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
5364 retval
= GetWindowLongPtr(hwndMain
, GWLP_WNDPROC
);
5365 ok((WNDPROC
)retval
== main_window_procA
,
5366 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
5367 ok(!IsWindowUnicode(hwndMain
), "hwndMain shouldn't be Unicode\n");
5369 old_window_procW
= (WNDPROC
)GetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
);
5370 SetLastError(0xdeadbeef);
5371 retval
= SetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
, 0);
5372 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED
)
5374 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
5375 ok(retval
!= 0, "SetWindowLongPtr error %d\n", GetLastError());
5376 ok((WNDPROC
)retval
== old_window_procW
,
5377 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
5378 ok(IsWindowUnicode(hwndMain
), "hwndMain should now be Unicode\n");
5380 /* set it back to ANSI */
5381 SetWindowLongPtr(hwndMain
, GWLP_WNDPROC
, 0);
5385 static void test_ShowWindow(void)
5389 RECT rcMain
, rc
, rcMinimized
;
5392 SetRect(&rcMain
, 120, 120, 210, 210);
5394 hwnd
= CreateWindowEx(0, "MainWindowClass", NULL
,
5395 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
5396 WS_MAXIMIZEBOX
| WS_POPUP
,
5397 rcMain
.left
, rcMain
.top
,
5398 rcMain
.right
- rcMain
.left
, rcMain
.bottom
- rcMain
.top
,
5402 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5403 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5404 ok(!(style
& WS_VISIBLE
), "window should not be visible\n");
5405 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5406 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5407 GetWindowRect(hwnd
, &rc
);
5408 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5409 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5410 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5412 ret
= ShowWindow(hwnd
, SW_SHOW
);
5413 ok(!ret
, "not expected ret: %lu\n", ret
);
5414 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5415 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5416 ok(style
& WS_VISIBLE
, "window should be visible\n");
5417 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5418 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5419 GetWindowRect(hwnd
, &rc
);
5420 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5421 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5422 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5424 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
5425 ok(ret
, "not expected ret: %lu\n", ret
);
5426 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5427 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5428 ok(style
& WS_VISIBLE
, "window should be visible\n");
5429 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5430 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5431 GetWindowRect(hwnd
, &rcMinimized
);
5432 ok(!EqualRect(&rcMain
, &rcMinimized
), "rects shouldn't match\n");
5433 /* shouldn't be able to resize minimized windows */
5434 ret
= SetWindowPos(hwnd
, 0, 0, 0,
5435 (rcMinimized
.right
- rcMinimized
.left
) * 2,
5436 (rcMinimized
.bottom
- rcMinimized
.top
) * 2,
5437 SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
5438 ok(ret
, "not expected ret: %lu\n", ret
);
5439 GetWindowRect(hwnd
, &rc
);
5440 ok(EqualRect(&rc
, &rcMinimized
), "rects should match\n");
5442 ShowWindow(hwnd
, SW_RESTORE
);
5443 ok(ret
, "not expected ret: %lu\n", ret
);
5444 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5445 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5446 ok(style
& WS_VISIBLE
, "window should be visible\n");
5447 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5448 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5449 GetWindowRect(hwnd
, &rc
);
5450 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5451 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5452 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5454 ret
= EnableWindow(hwnd
, FALSE
);
5455 ok(!ret
, "not expected ret: %lu\n", ret
);
5456 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5457 ok(style
& WS_DISABLED
, "window should be disabled\n");
5459 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
5460 ok(!ret
, "not expected ret: %lu\n", ret
);
5461 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5462 ok(style
& WS_DISABLED
, "window should be disabled\n");
5463 ok(style
& WS_VISIBLE
, "window should be visible\n");
5464 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5465 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5466 GetWindowRect(hwnd
, &rc
);
5467 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5468 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5469 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5471 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_MAXIMIZE
, 0);
5472 ok(!ret
, "not expected ret: %lu\n", ret
);
5473 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5474 ok(style
& WS_DISABLED
, "window should be disabled\n");
5475 ok(style
& WS_VISIBLE
, "window should be visible\n");
5476 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5477 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5478 GetWindowRect(hwnd
, &rc
);
5479 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5480 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5481 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5483 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
5484 ok(ret
, "not expected ret: %lu\n", ret
);
5485 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5486 ok(style
& WS_DISABLED
, "window should be disabled\n");
5487 ok(style
& WS_VISIBLE
, "window should be visible\n");
5488 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5489 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5490 GetWindowRect(hwnd
, &rc
);
5491 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
5493 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0);
5494 ok(!ret
, "not expected ret: %lu\n", ret
);
5495 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5496 ok(style
& WS_DISABLED
, "window should be disabled\n");
5497 ok(style
& WS_VISIBLE
, "window should be visible\n");
5498 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5499 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5500 GetWindowRect(hwnd
, &rc
);
5501 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
5503 ret
= ShowWindow(hwnd
, SW_RESTORE
);
5504 ok(ret
, "not expected ret: %lu\n", ret
);
5505 style
= GetWindowLong(hwnd
, GWL_STYLE
);
5506 ok(style
& WS_DISABLED
, "window should be disabled\n");
5507 ok(style
& WS_VISIBLE
, "window should be visible\n");
5508 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5509 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5510 GetWindowRect(hwnd
, &rc
);
5511 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5512 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5513 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5515 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
5516 ok(!ret
, "not expected ret: %lu\n", ret
);
5517 ok(IsWindow(hwnd
), "window should exist\n");
5519 ret
= EnableWindow(hwnd
, TRUE
);
5520 ok(ret
, "not expected ret: %lu\n", ret
);
5522 ret
= DefWindowProc(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
5523 ok(!ret
, "not expected ret: %lu\n", ret
);
5524 ok(!IsWindow(hwnd
), "window should not exist\n");
5527 static void test_gettext(void)
5530 LPCSTR clsname
= "gettexttest";
5534 memset( &cls
, 0, sizeof cls
);
5535 cls
.lpfnWndProc
= DefWindowProc
;
5536 cls
.lpszClassName
= clsname
;
5537 cls
.hInstance
= GetModuleHandle(NULL
);
5539 if (!RegisterClass( &cls
)) return;
5541 hwnd
= CreateWindow( clsname
, "test text", WS_OVERLAPPED
, 0, 0, 10, 10, 0, NULL
, NULL
, NULL
);
5542 ok( hwnd
!= NULL
, "window was null\n");
5544 r
= SendMessage( hwnd
, WM_GETTEXT
, 0x10, 0x1000);
5545 ok( r
== 0, "settext should return zero\n");
5547 r
= SendMessage( hwnd
, WM_GETTEXT
, 0x10000, 0);
5548 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5550 r
= SendMessage( hwnd
, WM_GETTEXT
, 0xff000000, 0x1000);
5551 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5553 r
= SendMessage( hwnd
, WM_GETTEXT
, 0x1000, 0xff000000);
5554 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5556 DestroyWindow(hwnd
);
5557 UnregisterClass( clsname
, NULL
);
5561 static void test_GetUpdateRect(void)
5564 BOOL ret
, parent_wm_paint
, grandparent_wm_paint
;
5566 HWND hgrandparent
, hparent
, hchild
;
5568 static const char classNameA
[] = "GetUpdateRectClass";
5570 hgrandparent
= CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW
,
5571 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
5573 hparent
= CreateWindowA("static", "parent", WS_CHILD
|WS_VISIBLE
,
5574 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
5576 hchild
= CreateWindowA("static", "child", WS_CHILD
|WS_VISIBLE
,
5577 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
5579 ShowWindow(hgrandparent
, SW_SHOW
);
5580 UpdateWindow(hgrandparent
);
5581 flush_events( TRUE
);
5583 ShowWindow(hchild
, SW_HIDE
);
5584 SetRect(&rc2
, 0, 0, 0, 0);
5585 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
5586 ok(!ret
, "GetUpdateRect returned not empty region\n");
5587 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5588 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5589 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5591 SetRect(&rc2
, 10, 10, 40, 40);
5592 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
5593 ok(ret
, "GetUpdateRect returned empty region\n");
5594 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5595 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5596 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5598 parent_wm_paint
= FALSE
;
5599 grandparent_wm_paint
= FALSE
;
5600 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
5602 if (msg
.message
== WM_PAINT
)
5604 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
5605 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
5607 DispatchMessage(&msg
);
5609 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
5610 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
5612 DestroyWindow(hgrandparent
);
5615 cls
.lpfnWndProc
= DefWindowProcA
;
5618 cls
.hInstance
= GetModuleHandleA(0);
5620 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
5621 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5622 cls
.lpszMenuName
= NULL
;
5623 cls
.lpszClassName
= classNameA
;
5625 if(!RegisterClassA(&cls
)) {
5626 trace("Register failed %d\n", GetLastError());
5630 hgrandparent
= CreateWindowA(classNameA
, "grandparent", WS_OVERLAPPEDWINDOW
,
5631 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
5633 hparent
= CreateWindowA(classNameA
, "parent", WS_CHILD
|WS_VISIBLE
,
5634 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
5636 hchild
= CreateWindowA(classNameA
, "child", WS_CHILD
|WS_VISIBLE
,
5637 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
5639 ShowWindow(hgrandparent
, SW_SHOW
);
5640 UpdateWindow(hgrandparent
);
5641 flush_events( TRUE
);
5643 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
5644 ok(!ret
, "GetUpdateRect returned not empty region\n");
5646 ShowWindow(hchild
, SW_HIDE
);
5648 SetRect(&rc2
, 0, 0, 0, 0);
5649 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
5650 ok(!ret
, "GetUpdateRect returned not empty region\n");
5651 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5652 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5653 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5655 SetRect(&rc2
, 10, 10, 40, 40);
5656 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
5657 ok(ret
, "GetUpdateRect returned empty region\n");
5658 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5659 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5660 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5662 parent_wm_paint
= FALSE
;
5663 grandparent_wm_paint
= FALSE
;
5664 while (PeekMessage(&msg
, 0, 0, 0, PM_REMOVE
))
5666 if (msg
.message
== WM_PAINT
)
5668 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
5669 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
5671 DispatchMessage(&msg
);
5673 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
5674 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
5676 DestroyWindow(hgrandparent
);
5680 static LRESULT CALLBACK
TestExposedRegion_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
5688 const int waitTime
= 2000;
5690 BeginPaint(hwnd
, &ps
);
5692 /* create and destroy window to create an exposed region on this window */
5693 win
= CreateWindowA("static", "win", WS_VISIBLE
,
5694 10,10,50,50, NULL
, NULL
, 0, NULL
);
5697 waitResult
= MsgWaitForMultipleObjects( 0, NULL
, FALSE
, waitTime
, QS_PAINT
);
5699 ValidateRect(hwnd
, NULL
);
5700 EndPaint(hwnd
, &ps
);
5702 if(waitResult
!= WAIT_TIMEOUT
)
5704 GetUpdateRect(hwnd
, &updateRect
, FALSE
);
5705 ok(IsRectEmpty(&updateRect
), "Exposed rect should be empty\n");
5710 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
5713 static void test_Expose(void)
5718 memset(&cls
, 0, sizeof(WNDCLASSA
));
5719 cls
.lpfnWndProc
= TestExposedRegion_WndProc
;
5720 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5721 cls
.lpszClassName
= "TestExposeClass";
5722 RegisterClassA(&cls
);
5724 mw
= CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
5725 0, 0, 200, 100, NULL
, NULL
, 0, NULL
);
5731 static LRESULT CALLBACK
TestNCRedraw_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
5733 static UINT ncredrawflags
;
5739 ncredrawflags
= *(UINT
*) (((CREATESTRUCT
*)lParam
)->lpCreateParams
);
5742 RedrawWindow(hwnd
, NULL
, NULL
, ncredrawflags
);
5745 BeginPaint(hwnd
, &ps
);
5746 EndPaint(hwnd
, &ps
);
5749 return DefWindowProc(hwnd
, msg
, wParam
, lParam
);
5752 static void run_NCRedrawLoop(UINT flags
)
5759 hwnd
= CreateWindowA("TestNCRedrawClass", "MainWindow",
5760 WS_OVERLAPPEDWINDOW
, 0, 0, 200, 100,
5761 NULL
, NULL
, 0, &flags
);
5762 ShowWindow(hwnd
, SW_SHOW
);
5764 flush_events( FALSE
);
5765 while(PeekMessage(&msg
, hwnd
, 0, 0, PM_REMOVE
) != 0)
5767 if (msg
.message
== WM_PAINT
) loopcount
++;
5768 if (loopcount
>= 100) break;
5769 TranslateMessage(&msg
);
5770 DispatchMessage(&msg
);
5771 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, QS_ALLINPUT
);
5773 if (flags
== (RDW_INVALIDATE
| RDW_FRAME
))
5774 todo_wine
ok(loopcount
< 100, "Detected infinite WM_PAINT loop (%x).\n", flags
);
5776 ok(loopcount
< 100, "Detected infinite WM_PAINT loop (%x).\n", flags
);
5777 DestroyWindow(hwnd
);
5780 static void test_NCRedraw(void)
5784 wndclass
.lpszClassName
= "TestNCRedrawClass";
5785 wndclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
5786 wndclass
.lpfnWndProc
= TestNCRedraw_WndProc
;
5787 wndclass
.cbClsExtra
= 0;
5788 wndclass
.cbWndExtra
= 0;
5789 wndclass
.hInstance
= 0;
5790 wndclass
.hIcon
= LoadIcon(NULL
, IDI_APPLICATION
);
5791 wndclass
.hCursor
= LoadCursor(NULL
, IDC_ARROW
);
5792 wndclass
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5793 wndclass
.lpszMenuName
= NULL
;
5795 RegisterClassA(&wndclass
);
5797 run_NCRedrawLoop(RDW_INVALIDATE
| RDW_FRAME
);
5798 run_NCRedrawLoop(RDW_INVALIDATE
);
5801 static void test_GetWindowModuleFileName(void)
5806 char buf1
[MAX_PATH
], buf2
[MAX_PATH
];
5808 if (!pGetWindowModuleFileNameA
)
5810 win_skip("GetWindowModuleFileNameA is not available\n");
5814 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
5817 hinst
= (HINSTANCE
)GetWindowLongPtr(hwnd
, GWLP_HINSTANCE
);
5818 ok(hinst
== 0 || broken(hinst
== GetModuleHandle(0)), /* win9x */ "expected 0, got %p\n", hinst
);
5821 SetLastError(0xdeadbeef);
5822 ret1
= GetModuleFileName(hinst
, buf1
, sizeof(buf1
));
5823 ok(ret1
, "GetModuleFileName error %u\n", GetLastError());
5826 SetLastError(0xdeadbeef);
5827 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
5828 ok(ret2
|| broken(!ret2
), /* nt4 sp 3 */
5829 "GetWindowModuleFileNameA error %u\n", GetLastError());
5833 ok(ret1
== ret2
|| broken(ret2
== ret1
+ 1), /* win98 */ "%u != %u\n", ret1
, ret2
);
5834 ok(!strcmp(buf1
, buf2
), "%s != %s\n", buf1
, buf2
);
5836 hinst
= GetModuleHandle(0);
5838 SetLastError(0xdeadbeef);
5839 ret2
= GetModuleFileName(hinst
, buf2
, ret1
- 2);
5840 ok(ret2
== ret1
- 2 || broken(ret2
== ret1
- 3), /* win98 */
5841 "expected %u, got %u\n", ret1
- 2, ret2
);
5842 ok(GetLastError() == 0xdeadbeef /* XP */ ||
5843 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
5844 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
5846 SetLastError(0xdeadbeef);
5847 ret2
= GetModuleFileName(hinst
, buf2
, 0);
5848 ok(!ret2
, "GetModuleFileName should return 0\n");
5849 ok(GetLastError() == 0xdeadbeef /* XP */ ||
5850 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
5851 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
5853 SetLastError(0xdeadbeef);
5854 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, ret1
- 2);
5855 ok(ret2
== ret1
- 2 || broken(ret2
== ret1
- 3) /* win98 */ || broken(!ret2
), /* nt4 sp3 */
5856 "expected %u, got %u\n", ret1
- 2, ret2
);
5857 ok(GetLastError() == 0xdeadbeef /* XP */ ||
5858 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
5859 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
5861 SetLastError(0xdeadbeef);
5862 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, 0);
5863 ok(!ret2
, "expected 0, got %u\n", ret2
);
5864 ok(GetLastError() == 0xdeadbeef /* XP */ ||
5865 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
5866 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
5868 DestroyWindow(hwnd
);
5871 hwnd
= (HWND
)0xdeadbeef;
5872 SetLastError(0xdeadbeef);
5873 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
5874 ok(!ret1
, "expected 0, got %u\n", ret1
);
5875 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
5876 "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
5878 hwnd
= FindWindow("Shell_TrayWnd", NULL
);
5879 ok(IsWindow(hwnd
) || broken(!hwnd
), "got invalid tray window %p\n", hwnd
);
5880 SetLastError(0xdeadbeef);
5881 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
5882 ok(!ret1
|| broken(ret1
), /* win98 */ "expected 0, got %u\n", ret1
);
5884 if (!ret1
) /* inter-process GetWindowModuleFileName works on win9x, so don't test the desktop there */
5886 ret1
= GetModuleFileName(0, buf1
, sizeof(buf1
));
5887 hwnd
= GetDesktopWindow();
5888 ok(IsWindow(hwnd
), "got invalid desktop window %p\n", hwnd
);
5889 SetLastError(0xdeadbeef);
5890 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
5892 ret1
== ret2
|| /* vista */
5893 broken(ret2
), /* some win98 return user.exe as file name */
5894 "expected 0 or %u, got %u %s\n", ret1
, ret2
, buf2
);
5898 static void test_hwnd_message(void)
5900 static const WCHAR mainwindowclassW
[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
5901 static const WCHAR message_windowW
[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
5903 HWND parent
= 0, hwnd
, found
;
5906 /* HWND_MESSAGE is not supported below w2k, but win9x return != 0
5907 on CreateWindowExA and crash later in the test.
5908 Use UNICODE here to fail on win9x */
5909 hwnd
= CreateWindowExW(0, mainwindowclassW
, message_windowW
, WS_CAPTION
| WS_VISIBLE
,
5910 100, 100, 200, 200, HWND_MESSAGE
, 0, 0, NULL
);
5913 win_skip("CreateWindowExW with parent HWND_MESSAGE failed\n");
5917 ok( !GetParent(hwnd
), "GetParent should return 0 for message only windows\n" );
5921 HWND root
, desktop
= GetDesktopWindow();
5923 parent
= pGetAncestor(hwnd
, GA_PARENT
);
5924 ok(parent
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
5925 ok(parent
!= desktop
, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
5926 root
= pGetAncestor(hwnd
, GA_ROOT
);
5927 ok(root
== hwnd
, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
5928 ok( !pGetAncestor(parent
, GA_PARENT
) || broken(pGetAncestor(parent
, GA_PARENT
) != 0), /* win2k */
5929 "parent shouldn't have parent %p\n", pGetAncestor(parent
, GA_PARENT
) );
5930 trace("parent %p root %p desktop %p\n", parent
, root
, desktop
);
5931 if (!GetClassNameA( parent
, buffer
, sizeof(buffer
) )) buffer
[0] = 0;
5932 ok( !lstrcmpi( buffer
, "Message" ), "wrong parent class '%s'\n", buffer
);
5933 GetWindowRect( parent
, &rect
);
5934 ok( rect
.left
== 0 && rect
.right
== 100 && rect
.top
== 0 && rect
.bottom
== 100,
5935 "wrong parent rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5937 GetWindowRect( hwnd
, &rect
);
5938 ok( rect
.left
== 100 && rect
.right
== 300 && rect
.top
== 100 && rect
.bottom
== 300,
5939 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5941 /* test FindWindow behavior */
5943 found
= FindWindowExA( 0, 0, 0, "message window" );
5944 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
5945 SetLastError(0xdeadbeef);
5946 found
= FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
5947 ok( found
== 0, "found message window %p/%p\n", found
, hwnd
);
5948 ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %d\n", GetLastError() );
5951 found
= FindWindowExA( parent
, 0, 0, "message window" );
5952 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
5955 /* test IsChild behavior */
5957 if (parent
) ok( !IsChild( parent
, hwnd
), "HWND_MESSAGE is child of top window\n" );
5959 /* test IsWindowVisible behavior */
5961 ok( !IsWindowVisible( hwnd
), "HWND_MESSAGE window is visible\n" );
5962 if (parent
) ok( !IsWindowVisible( parent
), "HWND_MESSAGE parent is visible\n" );
5964 DestroyWindow(hwnd
);
5967 static void test_layered_window(void)
5973 POINT pt
= { 0, 0 };
5974 SIZE sz
= { 200, 200 };
5979 if (!pGetLayeredWindowAttributes
|| !pSetLayeredWindowAttributes
|| !pUpdateLayeredWindow
)
5981 win_skip( "layered windows not supported\n" );
5985 hdc
= CreateCompatibleDC( 0 );
5986 hbm
= CreateCompatibleBitmap( hdc
, 200, 200 );
5987 SelectObject( hdc
, hbm
);
5989 hwnd
= CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION
,
5990 100, 100, 200, 200, 0, 0, 0, NULL
);
5992 SetLastError( 0xdeadbeef );
5993 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
5994 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
5995 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
5996 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
5997 ok( !ret
, "GetLayeredWindowAttributes should fail on non-layered window\n" );
5998 ret
= pSetLayeredWindowAttributes( hwnd
, 0, 0, LWA_ALPHA
);
5999 ok( !ret
, "SetLayeredWindowAttributes should fail on non-layered window\n" );
6000 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6001 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6002 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6003 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6004 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
6005 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6006 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6007 ret
= pSetLayeredWindowAttributes( hwnd
, 0x123456, 44, LWA_ALPHA
);
6008 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6009 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6010 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6011 ok( key
== 0x123456 || key
== 0, "wrong color key %x\n", key
);
6012 ok( alpha
== 44, "wrong alpha %u\n", alpha
);
6013 ok( flags
== LWA_ALPHA
, "wrong flags %x\n", flags
);
6014 SetLastError( 0xdeadbeef );
6015 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6016 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
6017 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6019 /* clearing WS_EX_LAYERED resets attributes */
6020 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
6021 SetLastError( 0xdeadbeef );
6022 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6023 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
6024 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6025 ok( !ret
, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
6026 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6027 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6028 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6029 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6030 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
6031 ret
= pSetLayeredWindowAttributes( hwnd
, 0x654321, 22, LWA_COLORKEY
| LWA_ALPHA
);
6032 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6033 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6034 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6035 ok( key
== 0x654321, "wrong color key %x\n", key
);
6036 ok( alpha
== 22, "wrong alpha %u\n", alpha
);
6037 ok( flags
== (LWA_COLORKEY
| LWA_ALPHA
), "wrong flags %x\n", flags
);
6038 SetLastError( 0xdeadbeef );
6039 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6040 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
6041 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6043 ret
= pSetLayeredWindowAttributes( hwnd
, 0x888888, 33, LWA_COLORKEY
);
6044 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6046 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6047 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6048 ok( key
== 0x888888, "wrong color key %x\n", key
);
6049 /* alpha not changed on vista if LWA_ALPHA is not set */
6050 ok( alpha
== 22 || alpha
== 33, "wrong alpha %u\n", alpha
);
6051 ok( flags
== LWA_COLORKEY
, "wrong flags %x\n", flags
);
6053 /* color key may or may not be changed without LWA_COLORKEY */
6054 ret
= pSetLayeredWindowAttributes( hwnd
, 0x999999, 44, 0 );
6055 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6057 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6058 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6059 ok( key
== 0x888888 || key
== 0x999999, "wrong color key %x\n", key
);
6060 ok( alpha
== 22 || alpha
== 44, "wrong alpha %u\n", alpha
);
6061 ok( flags
== 0, "wrong flags %x\n", flags
);
6063 /* default alpha and color key is 0 */
6064 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
6065 SetWindowLong( hwnd
, GWL_EXSTYLE
, GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6066 ret
= pSetLayeredWindowAttributes( hwnd
, 0x222222, 55, 0 );
6067 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6068 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6069 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6070 ok( key
== 0 || key
== 0x222222, "wrong color key %x\n", key
);
6071 ok( alpha
== 0 || alpha
== 55, "wrong alpha %u\n", alpha
);
6072 ok( flags
== 0, "wrong flags %x\n", flags
);
6074 DestroyWindow( hwnd
);
6076 DeleteObject( hbm
);
6079 static MONITORINFO mi
;
6081 static LRESULT CALLBACK
fullscreen_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
6087 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
6088 trace("WM_NCCREATE: rect %d,%d-%d,%d\n", cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
6089 ok(cs
->x
== mi
.rcMonitor
.left
&& cs
->y
== mi
.rcMonitor
.top
&&
6090 cs
->cx
== mi
.rcMonitor
.right
&& cs
->cy
== mi
.rcMonitor
.bottom
,
6091 "expected %d,%d-%d,%d, got %d,%d-%d,%d\n",
6092 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6093 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
6096 case WM_GETMINMAXINFO
:
6098 MINMAXINFO
*minmax
= (MINMAXINFO
*)lp
;
6099 dump_minmax_info(minmax
);
6100 ok(minmax
->ptMaxPosition
.x
<= mi
.rcMonitor
.left
, "%d <= %d\n", minmax
->ptMaxPosition
.x
, mi
.rcMonitor
.left
);
6101 ok(minmax
->ptMaxPosition
.y
<= mi
.rcMonitor
.top
, "%d <= %d\n", minmax
->ptMaxPosition
.y
, mi
.rcMonitor
.top
);
6102 ok(minmax
->ptMaxSize
.x
>= mi
.rcMonitor
.right
, "%d >= %d\n", minmax
->ptMaxSize
.x
, mi
.rcMonitor
.right
);
6103 ok(minmax
->ptMaxSize
.y
>= mi
.rcMonitor
.bottom
, "%d >= %d\n", minmax
->ptMaxSize
.y
, mi
.rcMonitor
.bottom
);
6107 return DefWindowProc(hwnd
, msg
, wp
, lp
);
6110 static void test_fullscreen(void)
6112 static const DWORD t_style
[] = {
6113 WS_OVERLAPPED
, WS_POPUP
, WS_CHILD
, WS_THICKFRAME
, WS_DLGFRAME
6115 static const DWORD t_ex_style
[] = {
6116 0, WS_EX_APPWINDOW
, WS_EX_TOOLWINDOW
6126 if (!pGetMonitorInfoA
|| !pMonitorFromPoint
)
6128 win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
6133 SetLastError(0xdeadbeef);
6134 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
6135 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
6137 mi
.cbSize
= sizeof(mi
);
6138 SetLastError(0xdeadbeef);
6139 ret
= pGetMonitorInfoA(hmon
, &mi
);
6140 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
6141 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
6142 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6143 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
6146 cls
.lpfnWndProc
= fullscreen_wnd_proc
;
6149 cls
.hInstance
= GetModuleHandle(0);
6151 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
6152 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6153 cls
.lpszMenuName
= NULL
;
6154 cls
.lpszClassName
= "fullscreen_class";
6155 RegisterClass(&cls
);
6157 for (i
= 0; i
< sizeof(t_style
)/sizeof(t_style
[0]); i
++)
6159 DWORD style
, ex_style
;
6161 /* avoid a WM interaction */
6162 assert(!(t_style
[i
] & WS_VISIBLE
));
6164 for (j
= 0; j
< sizeof(t_ex_style
)/sizeof(t_ex_style
[0]); j
++)
6169 ex_style
= t_ex_style
[j
];
6171 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6172 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6173 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
6174 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6175 GetWindowRect(hwnd
, &rc
);
6176 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6177 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6178 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6179 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6180 DestroyWindow(hwnd
);
6182 style
= t_style
[i
] | WS_MAXIMIZE
;
6183 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6184 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6185 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
6186 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6187 GetWindowRect(hwnd
, &rc
);
6188 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6189 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6190 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6191 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6192 DestroyWindow(hwnd
);
6194 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
;
6195 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6196 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6197 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
6198 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6199 GetWindowRect(hwnd
, &rc
);
6200 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6201 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6202 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6203 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6204 DestroyWindow(hwnd
);
6206 style
= t_style
[i
] | WS_CAPTION
| WS_MAXIMIZEBOX
;
6207 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6208 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6209 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
6210 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6211 GetWindowRect(hwnd
, &rc
);
6212 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6213 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6214 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6215 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6216 DestroyWindow(hwnd
);
6218 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
| WS_MAXIMIZEBOX
;
6219 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6220 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6221 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
6222 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6223 GetWindowRect(hwnd
, &rc
);
6224 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6225 /* Windows makes a maximized window slightly larger (to hide the borders?) */
6226 fixup
= min(abs(rc
.left
), abs(rc
.top
));
6227 InflateRect(&rc
, -fixup
, -fixup
);
6228 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
6229 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
6230 "%#x/%#x: window rect %d,%d-%d,%d must be in %d,%d-%d,%d\n",
6231 ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
6232 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
6233 DestroyWindow(hwnd
);
6235 style
= t_style
[i
] | WS_MAXIMIZE
| WS_MAXIMIZEBOX
;
6236 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6237 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6238 GetDesktopWindow(), 0, GetModuleHandle(0), NULL
);
6239 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6240 GetWindowRect(hwnd
, &rc
);
6241 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6242 /* Windows makes a maximized window slightly larger (to hide the borders?) */
6243 fixup
= min(abs(rc
.left
), abs(rc
.top
));
6244 InflateRect(&rc
, -fixup
, -fixup
);
6245 if (style
& (WS_CHILD
| WS_POPUP
))
6246 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6247 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6248 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6250 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
6251 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
6252 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6253 DestroyWindow(hwnd
);
6257 UnregisterClass("fullscreen_class", GetModuleHandle(0));
6260 static BOOL test_thick_child_got_minmax
;
6261 static const char * test_thick_child_name
;
6262 static LONG test_thick_child_style
;
6263 static LONG test_thick_child_exStyle
;
6265 static LRESULT WINAPI
test_thick_child_size_winproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
6268 int expectedMinTrackX
;
6269 int expectedMinTrackY
;
6270 int actualMinTrackX
;
6271 int actualMinTrackY
;
6272 int expectedMaxTrackX
;
6273 int expectedMaxTrackY
;
6274 int actualMaxTrackX
;
6275 int actualMaxTrackY
;
6276 int expectedMaxSizeX
;
6277 int expectedMaxSizeY
;
6288 case WM_GETMINMAXINFO
:
6290 minmax
= (MINMAXINFO
*)lparam
;
6291 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
6292 dump_minmax_info( minmax
);
6294 test_thick_child_got_minmax
= TRUE
;
6297 adjustedStyle
= test_thick_child_style
;
6298 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
6299 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
6300 GetClientRect(GetParent(hwnd
), &rect
);
6301 AdjustWindowRectEx(&rect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
6303 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
6305 expectedMinTrackX
= GetSystemMetrics(SM_CXMINTRACK
);
6306 expectedMinTrackY
= GetSystemMetrics(SM_CYMINTRACK
);
6310 expectedMinTrackX
= -2 * rect
.left
;
6311 expectedMinTrackY
= -2 * rect
.top
;
6313 actualMinTrackX
= minmax
->ptMinTrackSize
.x
;
6314 actualMinTrackY
= minmax
->ptMinTrackSize
.y
;
6316 ok(actualMinTrackX
== expectedMinTrackX
&& actualMinTrackY
== expectedMinTrackY
,
6317 "expected minTrack %dx%d, actual minTrack %dx%d for %s\n",
6318 expectedMinTrackX
, expectedMinTrackY
, actualMinTrackX
, actualMinTrackY
,
6319 test_thick_child_name
);
6321 actualMaxTrackX
= minmax
->ptMaxTrackSize
.x
;
6322 actualMaxTrackY
= minmax
->ptMaxTrackSize
.y
;
6323 expectedMaxTrackX
= GetSystemMetrics(SM_CXMAXTRACK
);
6324 expectedMaxTrackY
= GetSystemMetrics(SM_CYMAXTRACK
);
6325 ok(actualMaxTrackX
== expectedMaxTrackX
&& actualMaxTrackY
== expectedMaxTrackY
,
6326 "expected maxTrack %dx%d, actual maxTrack %dx%d for %s\n",
6327 expectedMaxTrackX
, expectedMaxTrackY
, actualMaxTrackX
, actualMaxTrackY
,
6328 test_thick_child_name
);
6330 expectedMaxSizeX
= rect
.right
- rect
.left
;
6331 expectedMaxSizeY
= rect
.bottom
- rect
.top
;
6332 actualMaxSizeX
= minmax
->ptMaxSize
.x
;
6333 actualMaxSizeY
= minmax
->ptMaxSize
.y
;
6335 ok(actualMaxSizeX
== expectedMaxSizeX
&& actualMaxSizeY
== expectedMaxSizeY
,
6336 "expected maxSize %dx%d, actual maxSize %dx%d for %s\n",
6337 expectedMaxSizeX
, expectedMaxSizeY
, actualMaxSizeX
, actualMaxSizeY
,
6338 test_thick_child_name
);
6341 expectedPosX
= rect
.left
;
6342 expectedPosY
= rect
.top
;
6343 actualPosX
= minmax
->ptMaxPosition
.x
;
6344 actualPosY
= minmax
->ptMaxPosition
.y
;
6345 ok(actualPosX
== expectedPosX
&& actualPosY
== expectedPosY
,
6346 "expected maxPosition (%d/%d), actual maxPosition (%d/%d) for %s\n",
6347 expectedPosX
, expectedPosY
, actualPosX
, actualPosY
, test_thick_child_name
);
6353 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
6356 #define NUMBER_OF_THICK_CHILD_TESTS 16
6357 static void test_thick_child_size(HWND parentWindow
)
6361 RECT adjustedParentRect
;
6366 LONG expectedHeight
;
6368 LPCTSTR className
= "THICK_CHILD_CLASS";
6371 static const LONG styles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6372 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6373 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6374 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6375 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6376 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6377 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6378 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6379 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6380 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6381 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6382 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6383 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6384 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6385 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6386 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6387 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6390 static const LONG exStyles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6395 WS_EX_DLGMODALFRAME
,
6396 WS_EX_DLGMODALFRAME
,
6397 WS_EX_DLGMODALFRAME
,
6398 WS_EX_DLGMODALFRAME
,
6403 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6404 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6405 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6406 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6408 static const char *styleName
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6409 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME",
6410 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME",
6411 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER",
6412 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER",
6413 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_DLGMODALFRAME",
6414 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_DLGMODALFRAME",
6415 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
6416 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
6417 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME exstyle= WS_EX_STATICEDGE",
6418 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE",
6419 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
6420 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
6421 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6422 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6423 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6424 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6428 cls
.lpfnWndProc
= test_thick_child_size_winproc
;
6431 cls
.hInstance
= GetModuleHandleA(0);
6433 cls
.hCursor
= LoadCursorA(0, IDC_ARROW
);
6434 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6435 cls
.lpszMenuName
= NULL
;
6436 cls
.lpszClassName
= className
;
6437 SetLastError(0xdeadbeef);
6438 success
= RegisterClassA(&cls
);
6439 ok(success
,"RegisterClassA failed, error: %u\n", GetLastError());
6441 for(i
= 0; i
< NUMBER_OF_THICK_CHILD_TESTS
; i
++)
6443 test_thick_child_name
= styleName
[i
];
6444 test_thick_child_style
= styles
[i
];
6445 test_thick_child_exStyle
= exStyles
[i
];
6446 test_thick_child_got_minmax
= FALSE
;
6448 SetLastError(0xdeadbeef);
6449 childWindow
= CreateWindowEx( exStyles
[i
], className
, "", styles
[i
], 0, 0, 0, 0, parentWindow
, 0, GetModuleHandleA(0), NULL
);
6450 ok(childWindow
!= NULL
, "Failed to create child window, error: %u\n", GetLastError());
6452 ok(test_thick_child_got_minmax
, "Got no WM_GETMINMAXINFO\n");
6454 SetLastError(0xdeadbeef);
6455 success
= GetWindowRect(childWindow
, &childRect
);
6456 ok(success
,"GetWindowRect call failed, error: %u\n", GetLastError());
6457 childWidth
= childRect
.right
- childRect
.left
;
6458 childHeight
= childRect
.bottom
- childRect
.top
;
6460 adjustedStyle
= styles
[i
];
6461 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
6462 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
6463 GetClientRect(GetParent(childWindow
), &adjustedParentRect
);
6464 AdjustWindowRectEx(&adjustedParentRect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
6467 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
6469 expectedWidth
= GetSystemMetrics(SM_CXMINTRACK
);
6470 expectedHeight
= GetSystemMetrics(SM_CYMINTRACK
);
6474 expectedWidth
= -2 * adjustedParentRect
.left
;
6475 expectedHeight
= -2 * adjustedParentRect
.top
;
6478 ok((childWidth
== expectedWidth
) && (childHeight
== expectedHeight
),
6479 "size of window (%s) is wrong: expected size %dx%d != actual size %dx%d\n",
6480 test_thick_child_name
, expectedWidth
, expectedHeight
, childWidth
, childHeight
);
6482 SetLastError(0xdeadbeef);
6483 success
= DestroyWindow(childWindow
);
6484 ok(success
,"DestroyWindow call failed, error: %u\n", GetLastError());
6486 ok(UnregisterClass(className
, GetModuleHandleA(0)),"UnregisterClass call failed\n");
6489 static void test_handles( HWND full_hwnd
)
6491 HWND hwnd
= full_hwnd
;
6495 SetLastError( 0xdeadbeef );
6496 ret
= GetWindowRect( hwnd
, &rect
);
6497 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6500 if ((ULONG_PTR
)full_hwnd
>> 32)
6501 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
& ~0u);
6503 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
| ((ULONG_PTR
)~0u << 32));
6504 SetLastError( 0xdeadbeef );
6505 ret
= GetWindowRect( hwnd
, &rect
);
6506 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6508 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& ~0u) | ((ULONG_PTR
)0x1234 << 32));
6509 SetLastError( 0xdeadbeef );
6510 ret
= GetWindowRect( hwnd
, &rect
);
6511 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6513 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x9876 << 16));
6514 SetLastError( 0xdeadbeef );
6515 ret
= GetWindowRect( hwnd
, &rect
);
6516 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
6517 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
6519 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x12345678 << 16));
6520 SetLastError( 0xdeadbeef );
6521 ret
= GetWindowRect( hwnd
, &rect
);
6522 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
6523 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
6527 static void test_winregion(void)
6534 if (!pGetWindowRgnBox
)
6536 win_skip("GetWindowRgnBox not supported\n");
6540 hwnd
= CreateWindowExA(0, "static", NULL
, WS_VISIBLE
, 10, 10, 10, 10, NULL
, 0, 0, NULL
);
6542 SetLastError(0xdeadbeef);
6543 ret
= pGetWindowRgnBox(hwnd
, NULL
);
6544 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
6545 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
6547 hrgn
= CreateRectRgn(2, 3, 10, 15);
6548 ok( hrgn
!= NULL
, "Region creation failed\n");
6551 SetWindowRgn(hwnd
, hrgn
, FALSE
);
6553 SetLastError(0xdeadbeef);
6554 ret
= pGetWindowRgnBox(hwnd
, NULL
);
6555 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
6556 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
6558 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6559 ret
= pGetWindowRgnBox(hwnd
, &r
);
6560 ok( ret
== SIMPLEREGION
, "Expected SIMPLEREGION, got %d\n", ret
);
6561 ok( r
.left
== 2 && r
.top
== 3 && r
.right
== 10 && r
.bottom
== 15,
6562 "Expected (2,3,10,15), got (%d,%d,%d,%d)\n", r
.left
, r
.top
,
6566 hrgn
= CreateRectRgn(2, 3, 10, 15);
6567 ret
= pMirrorRgn( hwnd
, hrgn
);
6568 ok( ret
== TRUE
, "MirrorRgn failed %u\n", ret
);
6569 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6570 GetWindowRect( hwnd
, &r
);
6571 width
= r
.right
- r
.left
;
6572 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6573 ret
= GetRgnBox( hrgn
, &r
);
6574 ok( ret
== SIMPLEREGION
, "GetRgnBox failed %u\n", ret
);
6575 ok( r
.left
== width
- 10 && r
.top
== 3 && r
.right
== width
- 2 && r
.bottom
== 15,
6576 "Wrong rectangle (%d,%d,%d,%d) for width %d\n", r
.left
, r
.top
, r
.right
, r
.bottom
, width
);
6578 else win_skip( "MirrorRgn not supported\n" );
6580 DestroyWindow(hwnd
);
6583 static void test_rtl_layout(void)
6589 if (!pSetProcessDefaultLayout
)
6591 win_skip( "SetProcessDefaultLayout not supported\n" );
6595 parent
= CreateWindowExA(WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
, 100, 100, 300, 300, NULL
, 0, 0, NULL
);
6596 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 10, 10, 20, 20, parent
, 0, 0, NULL
);
6598 GetWindowRect( parent
, &r
);
6599 ok( r
.left
== 100 && r
.right
== 400, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6600 GetClientRect( parent
, &r
);
6601 ok( r
.left
== 0 && r
.right
== 300, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6602 GetClientRect( child
, &r
);
6603 ok( r
.left
== 0 && r
.right
== 20, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6604 MapWindowPoints( child
, parent
, (POINT
*)&r
, 2 );
6605 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6606 GetWindowRect( child
, &r
);
6607 ok( r
.left
== 370 && r
.right
== 390, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6608 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6609 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6610 GetWindowRect( child
, &r
);
6611 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 1 );
6612 MapWindowPoints( NULL
, parent
, (POINT
*)&r
+ 1, 1 );
6613 ok( r
.left
== 30 && r
.right
== 10, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6615 MapWindowPoints( child
, parent
, &pt
, 1 );
6616 ok( pt
.x
== 22 && pt
.y
== 22, "wrong point %d,%d\n", pt
.x
, pt
.y
);
6617 SetWindowPos( parent
, 0, 0, 0, 250, 250, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
6618 GetWindowRect( parent
, &r
);
6619 ok( r
.left
== 100 && r
.right
== 350, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6620 GetWindowRect( child
, &r
);
6621 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6622 SetWindowLongW( parent
, GWL_EXSTYLE
, 0 );
6623 GetWindowRect( child
, &r
);
6624 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6625 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6626 ok( r
.left
== 220 && r
.right
== 240, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6627 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_LAYOUTRTL
);
6628 GetWindowRect( child
, &r
);
6629 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6630 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6631 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6632 SetWindowPos( child
, 0, 0, 0, 30, 30, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
6633 GetWindowRect( child
, &r
);
6634 ok( r
.left
== 310 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6635 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6636 ok( r
.left
== 10 && r
.right
== 40, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6637 DestroyWindow( child
);
6638 DestroyWindow( parent
);
6641 static void test_FlashWindowEx(void)
6647 if (!pFlashWindowEx
)
6649 win_skip( "FlashWindowEx not supported\n" );
6653 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP
,
6654 0, 0, 0, 0, 0, 0, 0, NULL
);
6655 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6657 finfo
.cbSize
= sizeof(FLASHWINFO
);
6658 finfo
.dwFlags
= FLASHW_TIMER
;
6660 finfo
.dwTimeout
= 200;
6662 SetLastError(0xdeadbeef);
6663 ret
= pFlashWindowEx(&finfo
);
6664 todo_wine
ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
6665 "FlashWindowEx returned with %d\n", GetLastError());
6668 SetLastError(0xdeadbeef);
6669 ret
= pFlashWindowEx(NULL
);
6670 todo_wine
ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
6671 "FlashWindowEx returned with %d\n", GetLastError());
6673 SetLastError(0xdeadbeef);
6674 ret
= pFlashWindowEx(&finfo
);
6675 todo_wine
ok(!ret
, "FlashWindowEx succeeded\n");
6677 finfo
.cbSize
= sizeof(FLASHWINFO
) - 1;
6678 SetLastError(0xdeadbeef);
6679 ret
= pFlashWindowEx(&finfo
);
6680 todo_wine
ok(!ret
&& GetLastError()==ERROR_INVALID_PARAMETER
,
6681 "FlashWindowEx succeeded\n");
6683 finfo
.cbSize
= sizeof(FLASHWINFO
) + 1;
6684 SetLastError(0xdeadbeef);
6685 ret
= pFlashWindowEx(&finfo
);
6686 todo_wine
ok(!ret
&& GetLastError()==ERROR_INVALID_PARAMETER
,
6687 "FlashWindowEx succeeded\n");
6688 finfo
.cbSize
= sizeof(FLASHWINFO
);
6690 DestroyWindow( hwnd
);
6692 SetLastError(0xdeadbeef);
6693 ret
= pFlashWindowEx(&finfo
);
6694 todo_wine
ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
6695 "FlashWindowEx returned with %d\n", GetLastError());
6697 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
6698 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
6699 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
6700 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
6701 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
6703 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_VISIBLE
| WS_POPUPWINDOW
,
6704 0, 0, 0, 0, 0, 0, 0, NULL
);
6705 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6708 SetLastError(0xdeadbeef);
6709 ret
= pFlashWindowEx(NULL
);
6710 todo_wine
ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
6711 "FlashWindowEx returned with %d\n", GetLastError());
6713 SetLastError(0xdeadbeef);
6714 ret
= pFlashWindowEx(&finfo
);
6715 todo_wine
ok(!ret
, "FlashWindowEx succeeded\n");
6717 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
6718 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
6719 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
6720 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
6721 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
6723 finfo
.dwFlags
= FLASHW_STOP
;
6724 SetLastError(0xdeadbeef);
6725 ret
= pFlashWindowEx(&finfo
);
6726 ok(ret
, "FlashWindowEx failed with %d\n", GetLastError());
6728 DestroyWindow( hwnd
);
6731 static void test_FindWindowEx(void)
6736 hwnd
= CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
6737 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6741 found
= FindWindowExA( 0, 0, "MainWindowClass", title
);
6742 ok( found
== NULL
, "expected a NULL hwnd\n" );
6743 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
6744 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
6746 DestroyWindow( hwnd
);
6748 hwnd
= CreateWindowExA( 0, "MainWindowClass", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
6749 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6751 found
= FindWindowExA( 0, 0, "MainWindowClass", title
);
6752 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
6753 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
6754 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
6756 DestroyWindow( hwnd
);
6758 /* test behaviour with a window title that is an empty character */
6759 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", title
);
6760 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
6761 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", NULL
);
6762 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
6765 static void test_GetLastActivePopup(void)
6767 HWND hwndOwner
, hwndPopup1
, hwndPopup2
;
6769 hwndOwner
= CreateWindowExA(0, "MainWindowClass", NULL
,
6770 WS_VISIBLE
| WS_POPUPWINDOW
,
6772 NULL
, 0, GetModuleHandle(0), NULL
);
6773 hwndPopup1
= CreateWindowExA(0, "MainWindowClass", NULL
,
6774 WS_VISIBLE
| WS_POPUPWINDOW
,
6776 hwndOwner
, 0, GetModuleHandle(0), NULL
);
6777 hwndPopup2
= CreateWindowExA(0, "MainWindowClass", NULL
,
6778 WS_VISIBLE
| WS_POPUPWINDOW
,
6780 hwndPopup1
, 0, GetModuleHandle(0), NULL
);
6781 ok( GetLastActivePopup(hwndOwner
) == hwndPopup2
, "wrong last active popup\n" );
6782 DestroyWindow( hwndPopup2
);
6783 DestroyWindow( hwndPopup1
);
6784 DestroyWindow( hwndOwner
);
6789 HMODULE user32
= GetModuleHandleA( "user32.dll" );
6790 HMODULE gdi32
= GetModuleHandleA("gdi32.dll");
6791 pGetAncestor
= (void *)GetProcAddress( user32
, "GetAncestor" );
6792 pGetWindowInfo
= (void *)GetProcAddress( user32
, "GetWindowInfo" );
6793 pGetWindowModuleFileNameA
= (void *)GetProcAddress( user32
, "GetWindowModuleFileNameA" );
6794 pGetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "GetLayeredWindowAttributes" );
6795 pSetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "SetLayeredWindowAttributes" );
6796 pUpdateLayeredWindow
= (void *)GetProcAddress( user32
, "UpdateLayeredWindow" );
6797 pGetMonitorInfoA
= (void *)GetProcAddress( user32
, "GetMonitorInfoA" );
6798 pMonitorFromPoint
= (void *)GetProcAddress( user32
, "MonitorFromPoint" );
6799 pGetWindowRgnBox
= (void *)GetProcAddress( user32
, "GetWindowRgnBox" );
6800 pGetGUIThreadInfo
= (void *)GetProcAddress( user32
, "GetGUIThreadInfo" );
6801 pGetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "GetProcessDefaultLayout" );
6802 pSetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "SetProcessDefaultLayout" );
6803 pFlashWindowEx
= (void *)GetProcAddress( user32
, "FlashWindowEx" );
6804 pGetLayout
= (void *)GetProcAddress( gdi32
, "GetLayout" );
6805 pSetLayout
= (void *)GetProcAddress( gdi32
, "SetLayout" );
6806 pMirrorRgn
= (void *)GetProcAddress( gdi32
, "MirrorRgn" );
6808 if (!RegisterWindowClasses()) assert(0);
6810 SetLastError(0xdeafbeef);
6811 GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC
);
6812 is_win9x
= (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
);
6814 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
6815 if (!hhook
) win_skip( "Cannot set CBT hook, skipping some tests\n" );
6817 /* make sure that these tests are executed first */
6818 test_FindWindowEx();
6821 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
6822 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
6823 WS_MAXIMIZEBOX
| WS_POPUP
,
6825 0, 0, GetModuleHandle(0), NULL
);
6826 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
6827 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
6828 WS_MAXIMIZEBOX
| WS_POPUP
,
6830 0, 0, GetModuleHandle(0), NULL
);
6832 assert( hwndMain2
);
6834 our_pid
= GetWindowThreadProcessId(hwndMain
, NULL
);
6836 /* Add the tests below this line */
6837 test_thick_child_size(hwndMain
);
6839 test_hwnd_message();
6840 test_nonclient_area(hwndMain
);
6842 test_GetWindowModuleFileName();
6845 test_capture_3(hwndMain
, hwndMain2
);
6848 test_FlashWindowEx();
6850 test_CreateWindow();
6851 test_parent_owner();
6852 test_enum_thread_windows();
6856 test_SetWindowPos(hwndMain
, hwndMain2
);
6857 test_SetMenu(hwndMain
);
6858 test_SetFocus(hwndMain
);
6859 test_SetActiveWindow(hwndMain
);
6862 test_children_zorder(hwndMain
);
6863 test_popup_zorder(hwndMain2
, hwndMain
, WS_POPUP
);
6864 test_popup_zorder(hwndMain2
, hwndMain
, 0);
6865 test_GetLastActivePopup();
6866 test_keyboard_input(hwndMain
);
6867 test_mouse_input(hwndMain
);
6868 test_validatergn(hwndMain
);
6869 test_nccalcscroll( hwndMain
);
6870 test_scrollwindow( hwndMain
);
6871 test_scrollvalidate( hwndMain
);
6872 test_scrolldc( hwndMain
);
6874 test_IsWindowUnicode();
6875 test_vis_rgn(hwndMain
);
6877 test_AdjustWindowRect();
6878 test_window_styles();
6879 test_dialog_styles();
6882 test_SetWindowLong();
6884 if (0) test_gettext(); /* crashes on NT4 */
6885 test_GetUpdateRect();
6887 test_layered_window();
6889 test_SetForegroundWindow(hwndMain
);
6890 test_shell_window();
6891 test_handles( hwndMain
);
6894 /* add the tests above this line */
6895 if (hhook
) UnhookWindowsHookEx(hhook
);
6897 DestroyWindow(hwndMain2
);
6898 DestroyWindow(hwndMain
);