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
37 #include "wine/test.h"
39 #ifndef SPI_GETDESKWALLPAPER
40 #define SPI_GETDESKWALLPAPER 0x0073
44 #define WM_SYSTIMER 0x0118
47 #define LONG_PTR INT_PTR
48 #define ULONG_PTR UINT_PTR
50 void dump_region(HRGN hrgn
);
52 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
53 static BOOL (WINAPI
*pGetWindowInfo
)(HWND
,WINDOWINFO
*);
54 static UINT (WINAPI
*pGetWindowModuleFileNameA
)(HWND
,LPSTR
,UINT
);
55 static BOOL (WINAPI
*pGetLayeredWindowAttributes
)(HWND
,COLORREF
*,BYTE
*,DWORD
*);
56 static BOOL (WINAPI
*pSetLayeredWindowAttributes
)(HWND
,COLORREF
,BYTE
,DWORD
);
57 static BOOL (WINAPI
*pUpdateLayeredWindow
)(HWND
,HDC
,POINT
*,SIZE
*,HDC
,POINT
*,COLORREF
,BLENDFUNCTION
*,DWORD
);
58 static BOOL (WINAPI
*pUpdateLayeredWindowIndirect
)(HWND
,const UPDATELAYEREDWINDOWINFO
*);
59 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
60 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
61 static int (WINAPI
*pGetWindowRgnBox
)(HWND
,LPRECT
);
62 static BOOL (WINAPI
*pGetGUIThreadInfo
)(DWORD
, GUITHREADINFO
*);
63 static BOOL (WINAPI
*pGetProcessDefaultLayout
)( DWORD
*layout
);
64 static BOOL (WINAPI
*pSetProcessDefaultLayout
)( DWORD layout
);
65 static BOOL (WINAPI
*pFlashWindow
)( HWND hwnd
, BOOL bInvert
);
66 static BOOL (WINAPI
*pFlashWindowEx
)( PFLASHWINFO pfwi
);
67 static DWORD (WINAPI
*pSetLayout
)(HDC hdc
, DWORD layout
);
68 static DWORD (WINAPI
*pGetLayout
)(HDC hdc
);
69 static BOOL (WINAPI
*pMirrorRgn
)(HWND hwnd
, HRGN hrgn
);
70 static BOOL (WINAPI
*pGetWindowDisplayAffinity
)(HWND hwnd
, DWORD
*affinity
);
71 static BOOL (WINAPI
*pSetWindowDisplayAffinity
)(HWND hwnd
, DWORD affinity
);
72 static BOOL (WINAPI
*pAdjustWindowRectExForDpi
)(LPRECT
,DWORD
,BOOL
,DWORD
,UINT
);
73 static BOOL (WINAPI
*pSystemParametersInfoForDpi
)(UINT
,UINT
,void*,UINT
,UINT
);
75 static BOOL test_lbuttondown_flag
;
76 static DWORD num_gettext_msgs
;
77 static DWORD num_settext_msgs
;
78 static HWND hwndMessage
;
79 static HWND hwndMain
, hwndMain2
;
81 static BOOL app_activated
, app_deactivated
;
83 static const char* szAWRClass
= "Winsize";
87 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
89 static void dump_minmax_info( const MINMAXINFO
*minmax
)
91 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
92 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
93 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
94 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
95 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
96 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
99 /* try to make sure pending X events have been processed before continuing */
100 static void flush_events( BOOL remove_messages
)
104 int min_timeout
= 100;
105 DWORD time
= GetTickCount() + diff
;
109 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
111 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
112 diff
= time
- GetTickCount();
117 static BOOL
wait_for_event(HANDLE event
, int timeout
)
119 DWORD end_time
= GetTickCount() + timeout
;
123 if(MsgWaitForMultipleObjects(1, &event
, FALSE
, timeout
, QS_ALLINPUT
) == WAIT_OBJECT_0
)
125 while(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
126 DispatchMessageA(&msg
);
127 timeout
= end_time
- GetTickCount();
133 /* check the values returned by the various parent/owner functions on a given window */
134 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
135 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
141 res
= pGetAncestor( hwnd
, GA_PARENT
);
142 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
144 res
= (HWND
)GetWindowLongPtrA( hwnd
, GWLP_HWNDPARENT
);
145 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
146 res
= GetParent( hwnd
);
147 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
148 res
= GetWindow( hwnd
, GW_OWNER
);
149 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
152 res
= pGetAncestor( hwnd
, GA_ROOT
);
153 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
154 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
155 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
159 #define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
160 static void check_wnd_state_(const char *file
, int line
,
161 HWND active
, HWND foreground
, HWND focus
, HWND capture
)
163 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
164 /* only check foreground if it belongs to the current thread */
165 /* foreground can be moved to a different app pretty much at any time */
166 if (foreground
&& GetForegroundWindow() &&
167 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
168 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
169 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
170 ok_(file
, line
)(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
173 /* same as above but without capture test */
174 #define check_active_state(a,b,c) check_active_state_(__FILE__,__LINE__,a,b,c)
175 static void check_active_state_(const char *file
, int line
,
176 HWND active
, HWND foreground
, HWND focus
)
178 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
179 /* only check foreground if it belongs to the current thread */
180 /* foreground can be moved to a different app pretty much at any time */
181 if (foreground
&& GetForegroundWindow() &&
182 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
183 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
184 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
187 static BOOL
ignore_message( UINT message
)
189 /* these are always ignored */
190 return (message
>= 0xc000 ||
191 message
== WM_GETICON
||
192 message
== WM_GETOBJECT
||
193 message
== WM_TIMER
||
194 message
== WM_SYSTIMER
||
195 message
== WM_TIMECHANGE
||
196 message
== WM_DEVICECHANGE
);
199 static BOOL CALLBACK
EnumChildProc( HWND hwndChild
, LPARAM lParam
)
202 if (*(LPINT
)lParam
> 1) return FALSE
;
206 /* will search for the given window */
207 static BOOL CALLBACK
EnumChildProc1( HWND hwndChild
, LPARAM lParam
)
209 if ((HWND
)lParam
== hwndChild
) return FALSE
;
213 static HWND
create_tool_window( LONG style
, HWND parent
)
215 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
216 0, 0, 100, 100, parent
, 0, 0, NULL
);
217 ok( ret
!= 0, "Creation failed\n" );
221 /* test parent and owner values for various combinations */
222 static void test_parent_owner(void)
225 HWND test
, owner
, ret
;
226 HWND desktop
= GetDesktopWindow();
227 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
230 if (winetest_debug
> 1)
231 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
233 /* child without parent, should fail */
234 SetLastError(0xdeadbeef);
235 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
236 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
237 ok( !test
, "WS_CHILD without parent created\n" );
238 ok( GetLastError() == ERROR_TLW_WITH_WSCHILD
, "CreateWindowExA error %u\n", GetLastError() );
241 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
242 style
= GetWindowLongA( desktop
, GWL_STYLE
);
243 ok( !SetWindowLongA( desktop
, GWL_STYLE
, WS_POPUP
), "Set GWL_STYLE on desktop succeeded\n" );
244 ok( !SetWindowLongA( desktop
, GWL_STYLE
, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
245 ok( GetWindowLongA( desktop
, GWL_STYLE
) == style
, "Desktop style changed\n" );
247 /* normal child window */
248 test
= create_tool_window( WS_CHILD
, hwndMain
);
249 if (winetest_debug
> 1) trace( "created child %p\n", test
);
250 check_parents( test
, hwndMain
, hwndMain
, hwndMain
, 0, hwndMain
, hwndMain
);
251 SetWindowLongA( test
, GWL_STYLE
, 0 );
252 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
253 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
254 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
255 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
256 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
257 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
258 DestroyWindow( test
);
260 /* normal child window with WS_MAXIMIZE */
261 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
262 DestroyWindow( test
);
264 /* normal child window with WS_THICKFRAME */
265 test
= create_tool_window( WS_CHILD
| WS_THICKFRAME
, hwndMain
);
266 DestroyWindow( test
);
268 /* popup window with WS_THICKFRAME */
269 test
= create_tool_window( WS_POPUP
| WS_THICKFRAME
, hwndMain
);
270 DestroyWindow( test
);
272 /* child of desktop */
273 test
= create_tool_window( WS_CHILD
, desktop
);
274 if (winetest_debug
> 1) trace( "created child of desktop %p\n", test
);
275 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
276 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
277 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
278 SetWindowLongA( test
, GWL_STYLE
, 0 );
279 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
280 DestroyWindow( test
);
282 /* child of desktop with WS_MAXIMIZE */
283 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, desktop
);
284 DestroyWindow( test
);
286 /* child of desktop with WS_MINIMIZE */
287 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, desktop
);
288 DestroyWindow( test
);
291 test
= create_tool_window( WS_CHILD
, child
);
292 if (winetest_debug
> 1) trace( "created child of child %p\n", test
);
293 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
294 SetWindowLongA( test
, GWL_STYLE
, 0 );
295 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
296 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
297 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
298 DestroyWindow( test
);
300 /* child of child with WS_MAXIMIZE */
301 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, child
);
302 DestroyWindow( test
);
304 /* child of child with WS_MINIMIZE */
305 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, child
);
306 DestroyWindow( test
);
308 /* not owned top-level window */
309 test
= create_tool_window( 0, 0 );
310 if (winetest_debug
> 1) trace( "created top-level %p\n", test
);
311 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
312 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
313 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
314 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
315 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
316 DestroyWindow( test
);
318 /* not owned top-level window with WS_MAXIMIZE */
319 test
= create_tool_window( WS_MAXIMIZE
, 0 );
320 DestroyWindow( test
);
322 /* owned top-level window */
323 test
= create_tool_window( 0, hwndMain
);
324 if (winetest_debug
> 1) trace( "created owned top-level %p\n", test
);
325 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
326 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
327 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
328 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
329 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
330 DestroyWindow( test
);
332 /* owned top-level window with WS_MAXIMIZE */
333 test
= create_tool_window( WS_MAXIMIZE
, hwndMain
);
334 DestroyWindow( test
);
336 /* not owned popup */
337 test
= create_tool_window( WS_POPUP
, 0 );
338 if (winetest_debug
> 1) trace( "created popup %p\n", test
);
339 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
340 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
341 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
342 SetWindowLongA( test
, GWL_STYLE
, 0 );
343 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
344 DestroyWindow( test
);
346 /* not owned popup with WS_MAXIMIZE */
347 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, 0 );
348 DestroyWindow( test
);
351 test
= create_tool_window( WS_POPUP
, hwndMain
);
352 if (winetest_debug
> 1) trace( "created owned popup %p\n", test
);
353 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
354 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
355 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
356 SetWindowLongA( test
, GWL_STYLE
, 0 );
357 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
358 DestroyWindow( test
);
360 /* owned popup with WS_MAXIMIZE */
361 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, hwndMain
);
362 DestroyWindow( test
);
364 /* top-level window owned by child (same as owned by top-level) */
365 test
= create_tool_window( 0, child
);
366 if (winetest_debug
> 1) trace( "created top-level owned by child %p\n", test
);
367 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
368 DestroyWindow( test
);
370 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
371 test
= create_tool_window( WS_MAXIMIZE
, child
);
372 DestroyWindow( test
);
374 /* popup owned by desktop (same as not owned) */
375 test
= create_tool_window( WS_POPUP
, desktop
);
376 if (winetest_debug
> 1) trace( "created popup owned by desktop %p\n", test
);
377 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
378 DestroyWindow( test
);
380 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
381 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, desktop
);
382 DestroyWindow( test
);
384 /* popup owned by child (same as owned by top-level) */
385 test
= create_tool_window( WS_POPUP
, child
);
386 if (winetest_debug
> 1) trace( "created popup owned by child %p\n", test
);
387 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
388 DestroyWindow( test
);
390 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
391 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, child
);
392 DestroyWindow( test
);
394 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
395 test
= create_tool_window( WS_POPUP
| WS_CHILD
, 0 );
396 if (winetest_debug
> 1) trace( "created WS_CHILD popup %p\n", test
);
397 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
398 DestroyWindow( test
);
400 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
401 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, 0 );
402 DestroyWindow( test
);
404 /* owned popup with WS_CHILD (same as WS_POPUP only) */
405 test
= create_tool_window( WS_POPUP
| WS_CHILD
, hwndMain
);
406 if (winetest_debug
> 1) trace( "created owned WS_CHILD popup %p\n", test
);
407 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
408 DestroyWindow( test
);
410 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
411 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
412 DestroyWindow( test
);
414 /******************** parent changes *************************/
417 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
418 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
419 ok( !ret
, "Set GWL_HWNDPARENT succeeded on desktop\n" );
420 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
421 ok( !SetParent( desktop
, hwndMain
), "SetParent succeeded on desktop\n" );
422 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
423 /* normal child window */
424 test
= create_tool_window( WS_CHILD
, hwndMain
);
425 if (winetest_debug
> 1) trace( "created child %p\n", test
);
427 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
428 ok( ret
== hwndMain
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain
);
429 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
431 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
432 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
433 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
435 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)desktop
);
436 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
437 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
439 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
440 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)test
);
441 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
442 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
444 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
445 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
446 check_parents( test
, desktop
, child
, desktop
, child
, test
, desktop
);
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, desktop
, 0, test
, desktop
);
451 DestroyWindow( test
);
453 /* not owned top-level window */
454 test
= create_tool_window( 0, 0 );
455 if (winetest_debug
> 1) trace( "created top-level %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
, 0, hwndMain2
, test
, test
);
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
, 0, child
, test
, test
);
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 /* not owned popup */
471 test
= create_tool_window( WS_POPUP
, 0 );
472 if (winetest_debug
> 1) trace( "created popup %p\n", test
);
474 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
475 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
476 check_parents( test
, desktop
, hwndMain2
, hwndMain2
, hwndMain2
, test
, hwndMain2
);
478 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
479 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
480 check_parents( test
, desktop
, child
, child
, child
, test
, hwndMain
);
482 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
483 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
484 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
485 DestroyWindow( test
);
487 /* normal child window */
488 test
= create_tool_window( WS_CHILD
, hwndMain
);
489 if (winetest_debug
> 1) trace( "created child %p\n", test
);
491 ret
= SetParent( test
, desktop
);
492 ok( ret
== hwndMain
, "SetParent return value %p expected %p\n", ret
, hwndMain
);
493 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
495 ret
= SetParent( test
, child
);
496 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
497 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
499 ret
= SetParent( test
, hwndMain2
);
500 ok( ret
== child
, "SetParent return value %p expected %p\n", ret
, child
);
501 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
502 DestroyWindow( test
);
504 /* not owned top-level window */
505 test
= create_tool_window( 0, 0 );
506 if (winetest_debug
> 1) trace( "created top-level %p\n", test
);
508 ret
= SetParent( test
, child
);
509 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
510 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
512 ShowWindow( test
, SW_SHOW
);
513 ret
= SetParent( test
, test
);
514 ok( ret
== NULL
, "SetParent return value %p expected %p\n", ret
, NULL
);
515 ok( GetWindowLongA( test
, GWL_STYLE
) & WS_VISIBLE
, "window is not visible after SetParent\n" );
516 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
517 DestroyWindow( test
);
520 test
= create_tool_window( WS_POPUP
, hwndMain2
);
521 if (winetest_debug
> 1) trace( "created owned popup %p\n", test
);
523 ret
= SetParent( test
, child
);
524 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
525 check_parents( test
, child
, child
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
527 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)hwndMain
);
528 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
529 check_parents( test
, hwndMain
, hwndMain
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
530 DestroyWindow( test
);
532 /**************** test owner destruction *******************/
534 /* owned child popup */
535 owner
= create_tool_window( 0, 0 );
536 test
= create_tool_window( WS_POPUP
, owner
);
537 if (winetest_debug
> 1) trace( "created owner %p and popup %p\n", owner
, test
);
538 ret
= SetParent( test
, child
);
539 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
540 check_parents( test
, child
, child
, owner
, owner
, hwndMain
, owner
);
541 /* window is now child of 'child' but owned by 'owner' */
542 DestroyWindow( owner
);
543 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
544 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
545 * while Win95, Win2k, WinXP do.
547 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
548 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
551 /* owned top-level popup */
552 owner
= create_tool_window( 0, 0 );
553 test
= create_tool_window( WS_POPUP
, owner
);
554 if (winetest_debug
> 1) trace( "created owner %p and popup %p\n", owner
, test
);
555 check_parents( test
, desktop
, owner
, owner
, owner
, test
, owner
);
556 DestroyWindow( owner
);
557 ok( !IsWindow(test
), "Window %p not destroyed by owner destruction\n", test
);
559 /* top-level popup owned by child */
560 owner
= create_tool_window( WS_CHILD
, hwndMain2
);
561 test
= create_tool_window( WS_POPUP
, 0 );
562 if (winetest_debug
> 1) trace( "created owner %p and popup %p\n", owner
, test
);
563 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)owner
);
564 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
565 check_parents( test
, desktop
, owner
, owner
, owner
, test
, hwndMain2
);
566 DestroyWindow( owner
);
567 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
568 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
569 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
570 * while Win95, Win2k, WinXP do.
572 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
576 DestroyWindow(child
);
579 owner
= create_tool_window( WS_OVERLAPPED
, 0 );
580 test
= create_tool_window( WS_POPUP
, desktop
);
582 ok( !GetWindow( test
, GW_OWNER
), "Wrong owner window\n" );
584 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
585 "EnumChildWindows should have returned FALSE\n" );
586 ok( numChildren
== 0, "numChildren should be 0 got %d\n", numChildren
);
588 SetWindowLongA( test
, GWL_STYLE
, (GetWindowLongA( test
, GWL_STYLE
) & ~WS_POPUP
) | WS_CHILD
);
589 ret
= SetParent( test
, owner
);
590 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
593 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
594 "EnumChildWindows should have returned TRUE\n" );
595 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
597 child
= create_tool_window( WS_CHILD
, owner
);
599 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
600 "EnumChildWindows should have returned FALSE\n" );
601 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
602 DestroyWindow( child
);
604 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
605 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
607 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
608 "EnumChildWindows should have returned TRUE\n" );
609 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
611 ret
= SetParent( child
, owner
);
612 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
613 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
615 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
616 "EnumChildWindows should have returned FALSE\n" );
617 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
619 ret
= SetParent( child
, NULL
);
620 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
621 ok( ret
== owner
, "SetParent return value %p expected %p\n", ret
, owner
);
623 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
624 "EnumChildWindows should have returned TRUE\n" );
625 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
627 /* even GW_OWNER == owner it's still a desktop's child */
628 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
629 "EnumChildWindows should have found %p and returned FALSE\n", child
);
631 DestroyWindow( child
);
632 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, NULL
);
634 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
635 "EnumChildWindows should have found %p and returned FALSE\n", child
);
637 DestroyWindow( child
);
638 DestroyWindow( test
);
639 DestroyWindow( owner
);
641 /* Test that owner window takes into account WS_CHILD flag even if parent is set by SetParent. */
642 owner
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, desktop
);
643 SetParent(owner
, hwndMain
);
644 check_parents( owner
, hwndMain
, hwndMain
, NULL
, NULL
, hwndMain
, owner
);
645 test
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
646 check_parents( test
, desktop
, owner
, NULL
, owner
, test
, test
);
647 DestroyWindow( owner
);
648 DestroyWindow( test
);
650 owner
= create_tool_window( WS_VISIBLE
| WS_CHILD
, desktop
);
651 SetParent(owner
, hwndMain
);
652 check_parents( owner
, hwndMain
, hwndMain
, hwndMain
, NULL
, hwndMain
, hwndMain
);
653 test
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
654 check_parents( test
, desktop
, hwndMain
, NULL
, hwndMain
, test
, test
);
655 DestroyWindow( owner
);
656 DestroyWindow( test
);
658 owner
= create_tool_window( WS_VISIBLE
| WS_POPUP
| WS_CHILD
, desktop
);
659 SetParent(owner
, hwndMain
);
660 check_parents( owner
, hwndMain
, hwndMain
, NULL
, NULL
, hwndMain
, owner
);
661 test
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
662 check_parents( test
, desktop
, owner
, NULL
, owner
, test
, test
);
663 DestroyWindow( owner
);
664 DestroyWindow( test
);
667 static BOOL CALLBACK
enum_proc( HWND hwnd
, LPARAM lParam
)
670 if (*(LPINT
)lParam
> 2) return FALSE
;
673 static DWORD CALLBACK
enum_thread( void *arg
)
680 if (pGetGUIThreadInfo
)
683 info
.cbSize
= sizeof(info
);
684 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
685 ok( ret
, "GetGUIThreadInfo failed without message queue\n" );
686 SetLastError( 0xdeadbeef );
687 info
.cbSize
= sizeof(info
) + 1;
688 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
689 ok( !ret
, "GetGUIThreadInfo succeeded with wrong size\n" );
690 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
693 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
); /* make sure we have a message queue */
696 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
697 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
698 ok( count
== 0, "count should be 0 got %d\n", count
);
700 hwnd
[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP
,
701 0, 0, 100, 100, 0, 0, 0, NULL
);
703 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
704 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
705 if (count
!= 2) /* Vista gives us two windows for the price of one */
707 ok( count
== 1, "count should be 1 got %d\n", count
);
708 hwnd
[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP
,
709 0, 0, 100, 100, 0, 0, 0, NULL
);
713 hwnd
[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP
,
714 0, 0, 100, 100, 0, 0, 0, NULL
);
716 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
717 ok( !ret
, "EnumThreadWindows should have returned FALSE\n" );
718 ok( count
== 3, "count should be 3 got %d\n", count
);
720 if (hwnd
[2]) DestroyWindow(hwnd
[2]);
721 DestroyWindow(hwnd
[1]);
722 DestroyWindow(hwnd
[0]);
726 /* test EnumThreadWindows in a separate thread */
727 static void test_enum_thread_windows(void)
730 HANDLE handle
= CreateThread( NULL
, 0, enum_thread
, 0, 0, &id
);
731 ok( !WaitForSingleObject( handle
, 10000 ), "wait failed\n" );
732 CloseHandle( handle
);
735 static struct wm_gettext_override_data
737 BOOL enabled
; /* when 1 bypasses default procedure */
738 BOOL dont_terminate
; /* don't null terminate returned string in WM_GETTEXT handler */
739 char *buff
; /* expected text buffer pointer */
740 WCHAR
*buffW
; /* same, for W test */
741 } g_wm_gettext_override
;
743 static LRESULT WINAPI
main_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
747 case WM_GETMINMAXINFO
:
749 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
752 case WM_WINDOWPOSCHANGING
:
754 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
755 if (!(winpos
->flags
& SWP_NOMOVE
))
757 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
758 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
760 if (!(winpos
->flags
& SWP_NOSIZE
))
762 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
763 winpos
->cx
== 32768, /* win7 doesn't truncate */
764 "bad winpos->cx %d\n", winpos
->cx
);
765 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
766 winpos
->cy
== 40000, /* win7 doesn't truncate */
767 "bad winpos->cy %d\n", winpos
->cy
);
771 case WM_WINDOWPOSCHANGED
:
774 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
775 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
776 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
778 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
779 winpos
->cx
== 32768, /* win7 doesn't truncate */
780 "bad winpos->cx %d\n", winpos
->cx
);
781 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
782 winpos
->cy
== 40000, /* win7 doesn't truncate */
783 "bad winpos->cy %d\n", winpos
->cy
);
785 GetWindowRect(hwnd
, &rc1
);
786 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
787 /* note: winpos coordinates are relative to parent */
788 MapWindowPoints(GetAncestor(hwnd
,GA_PARENT
), 0, (LPPOINT
)&rc2
, 2);
789 ok(EqualRect(&rc1
, &rc2
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1
),
790 wine_dbgstr_rect(&rc2
));
792 GetClientRect(hwnd
, &rc2
);
793 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
794 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
795 ok(EqualRect(&rc1
, &rc2
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1
),
796 wine_dbgstr_rect(&rc2
));
801 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
802 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
804 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
805 ok(got_getminmaxinfo
, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
807 ok(!got_getminmaxinfo
, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
811 if (test_lbuttondown_flag
)
813 ShowWindow((HWND
)wparam
, SW_SHOW
);
814 flush_events( FALSE
);
819 if (g_wm_gettext_override
.enabled
)
821 char *text
= (char*)lparam
;
822 ok(g_wm_gettext_override
.buff
== text
, "expected buffer %p, got %p\n", g_wm_gettext_override
.buff
, text
);
823 ok(*text
== 0, "expected empty string buffer %x\n", *text
);
826 else if (g_wm_gettext_override
.dont_terminate
)
828 char *text
= (char *)lparam
;
831 memcpy(text
, "text", 4);
841 if (wparam
) app_activated
= TRUE
;
842 else app_deactivated
= TRUE
;
846 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
849 static LRESULT WINAPI
main_window_procW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
855 if (g_wm_gettext_override
.enabled
)
857 WCHAR
*text
= (WCHAR
*)lparam
;
858 ok(g_wm_gettext_override
.buffW
== text
, "expected buffer %p, got %p\n", g_wm_gettext_override
.buffW
, text
);
859 ok(*text
== 0, "expected empty string buffer %x\n", *text
);
862 else if (g_wm_gettext_override
.dont_terminate
)
864 static const WCHAR textW
[] = {'t','e','x','t'};
865 WCHAR
*text
= (WCHAR
*)lparam
;
868 memcpy(text
, textW
, sizeof(textW
));
876 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
879 static LRESULT WINAPI
tool_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
883 case WM_GETMINMAXINFO
:
885 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
890 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
891 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
893 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
894 ok(got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
896 ok(!got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
901 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
904 static const WCHAR mainclassW
[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s','W',0};
906 static BOOL
RegisterWindowClasses(void)
911 cls
.style
= CS_DBLCLKS
;
912 cls
.lpfnWndProc
= main_window_procA
;
915 cls
.hInstance
= GetModuleHandleA(0);
917 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
918 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
919 cls
.lpszMenuName
= NULL
;
920 cls
.lpszClassName
= "MainWindowClass";
922 if(!RegisterClassA(&cls
)) return FALSE
;
924 clsW
.style
= CS_DBLCLKS
;
925 clsW
.lpfnWndProc
= main_window_procW
;
928 clsW
.hInstance
= GetModuleHandleA(0);
930 clsW
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
931 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
932 clsW
.lpszMenuName
= NULL
;
933 clsW
.lpszClassName
= mainclassW
;
935 if(!RegisterClassW(&clsW
)) return FALSE
;
938 cls
.lpfnWndProc
= tool_window_procA
;
941 cls
.hInstance
= GetModuleHandleA(0);
943 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
944 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
945 cls
.lpszMenuName
= NULL
;
946 cls
.lpszClassName
= "ToolWindowClass";
948 if(!RegisterClassA(&cls
)) return FALSE
;
953 static void verify_window_info(const char *hook
, HWND hwnd
, const WINDOWINFO
*info
)
955 RECT rcWindow
, rcClient
;
958 ok(IsWindow(hwnd
), "bad window handle %p in hook %s\n", hwnd
, hook
);
960 GetWindowRect(hwnd
, &rcWindow
);
961 ok(EqualRect(&rcWindow
, &info
->rcWindow
), "wrong rcWindow for %p in hook %s\n", hwnd
, hook
);
963 GetClientRect(hwnd
, &rcClient
);
964 /* translate to screen coordinates */
965 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rcClient
, 2);
966 ok(EqualRect(&rcClient
, &info
->rcClient
), "wrong rcClient for %p in hook %s\n", hwnd
, hook
);
968 ok(info
->dwStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_STYLE
),
969 "wrong dwStyle: %08x != %08x for %p in hook %s\n",
970 info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
), hwnd
, hook
);
971 /* Windows reports some undocumented exstyles in WINDOWINFO, but
972 * doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
974 ok((info
->dwExStyle
& ~0xe0000800) == (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
975 "wrong dwExStyle: %08x != %08x for %p in hook %s\n",
976 info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
), hwnd
, hook
);
977 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
978 if (GetForegroundWindow())
979 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04x != %04x active %p fg %p in hook %s\n",
980 info
->dwWindowStatus
, status
, GetActiveWindow(), GetForegroundWindow(), hook
);
982 /* win2k and XP return broken border info in GetWindowInfo most of
983 * the time, so there is no point in testing it.
988 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
989 "wrong cxWindowBorders %d != %d\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
990 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
991 ok(info
->cyWindowBorders
== border
,
992 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
994 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType for %p in hook %s\n",
996 ok(info
->wCreatorVersion
== 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
997 info
->wCreatorVersion
== 0x0500 /* Vista */,
998 "wrong wCreatorVersion %04x for %p in hook %s\n", info
->wCreatorVersion
, hwnd
, hook
);
1001 static void FixedAdjustWindowRectEx(RECT
* rc
, LONG style
, BOOL menu
, LONG exstyle
)
1003 AdjustWindowRectEx(rc
, style
, menu
, exstyle
);
1004 /* AdjustWindowRectEx does not include scroll bars */
1005 if (style
& WS_VSCROLL
)
1007 if(exstyle
& WS_EX_LEFTSCROLLBAR
)
1008 rc
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
1010 rc
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
1012 if (style
& WS_HSCROLL
)
1013 rc
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
1016 /* reimplement it to check that the Wine algorithm gives the correct result */
1017 static void wine_AdjustWindowRectEx( RECT
*rect
, LONG style
, BOOL menu
, LONG exStyle
)
1019 NONCLIENTMETRICSW ncm
;
1022 ncm
.cbSize
= offsetof( NONCLIENTMETRICSW
, iPaddedBorderWidth
);
1023 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0 );
1025 if ((exStyle
& (WS_EX_STATICEDGE
|WS_EX_DLGMODALFRAME
)) == WS_EX_STATICEDGE
)
1026 adjust
= 1; /* for the outer frame always present */
1027 else if ((exStyle
& WS_EX_DLGMODALFRAME
) || (style
& (WS_THICKFRAME
|WS_DLGFRAME
)))
1028 adjust
= 2; /* outer */
1030 if (style
& WS_THICKFRAME
) adjust
+= ncm
.iBorderWidth
; /* The resize border */
1031 if ((style
& (WS_BORDER
|WS_DLGFRAME
)) || (exStyle
& WS_EX_DLGMODALFRAME
))
1032 adjust
++; /* The other border */
1034 InflateRect (rect
, adjust
, adjust
);
1036 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1038 if (exStyle
& WS_EX_TOOLWINDOW
)
1039 rect
->top
-= ncm
.iSmCaptionHeight
+ 1;
1041 rect
->top
-= ncm
.iCaptionHeight
+ 1;
1043 if (menu
) rect
->top
-= ncm
.iMenuHeight
+ 1;
1045 if (exStyle
& WS_EX_CLIENTEDGE
)
1046 InflateRect(rect
, GetSystemMetrics(SM_CXEDGE
), GetSystemMetrics(SM_CYEDGE
));
1048 if (style
& WS_VSCROLL
)
1050 if((exStyle
& WS_EX_LEFTSCROLLBAR
) != 0)
1051 rect
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
1053 rect
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
1055 if (style
& WS_HSCROLL
) rect
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
1058 static void wine_AdjustWindowRectExForDpi( RECT
*rect
, LONG style
, BOOL menu
, LONG exStyle
, UINT dpi
)
1060 NONCLIENTMETRICSW ncm
;
1063 ncm
.cbSize
= sizeof(ncm
);
1064 pSystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0, dpi
);
1066 if ((exStyle
& (WS_EX_STATICEDGE
|WS_EX_DLGMODALFRAME
)) == WS_EX_STATICEDGE
)
1067 adjust
= 1; /* for the outer frame always present */
1068 else if ((exStyle
& WS_EX_DLGMODALFRAME
) || (style
& (WS_THICKFRAME
|WS_DLGFRAME
)))
1069 adjust
= 2; /* outer */
1071 if (style
& WS_THICKFRAME
) adjust
+= ncm
.iBorderWidth
+ ncm
.iPaddedBorderWidth
;
1073 if ((style
& (WS_BORDER
|WS_DLGFRAME
)) || (exStyle
& WS_EX_DLGMODALFRAME
))
1074 adjust
++; /* The other border */
1076 InflateRect (rect
, adjust
, adjust
);
1078 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1080 if (exStyle
& WS_EX_TOOLWINDOW
)
1081 rect
->top
-= ncm
.iSmCaptionHeight
+ 1;
1083 rect
->top
-= ncm
.iCaptionHeight
+ 1;
1085 if (menu
) rect
->top
-= ncm
.iMenuHeight
+ 1;
1087 if (exStyle
& WS_EX_CLIENTEDGE
)
1088 InflateRect(rect
, GetSystemMetrics(SM_CXEDGE
), GetSystemMetrics(SM_CYEDGE
));
1091 static void test_nonclient_area(HWND hwnd
)
1093 DWORD style
, exstyle
;
1094 RECT rc_window
, rc_client
, rc
;
1098 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1099 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1100 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
1102 GetWindowRect(hwnd
, &rc_window
);
1103 GetClientRect(hwnd
, &rc_client
);
1105 /* avoid some cases when things go wrong */
1106 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
1107 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
1110 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
1111 FixedAdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
1113 ok(EqualRect(&rc
, &rc_window
),
1114 "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=%s, calc=%s\n",
1115 style
, exstyle
, menu
, wine_dbgstr_rect(&rc_window
), wine_dbgstr_rect(&rc
));
1118 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
1119 wine_AdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
1120 ok(EqualRect(&rc
, &rc_window
),
1121 "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=%s, calc=%s\n",
1122 style
, exstyle
, menu
, wine_dbgstr_rect(&rc_window
), wine_dbgstr_rect(&rc
));
1126 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
1127 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
1128 ok(EqualRect(&rc
, &rc_client
),
1129 "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d client=%s, calc=%s\n",
1130 style
, exstyle
, menu
, wine_dbgstr_rect(&rc_client
), wine_dbgstr_rect(&rc
));
1132 /* NULL rectangle shouldn't crash */
1133 ret
= DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, 0);
1134 ok(ret
== 0, "NULL rectangle returned %ld instead of 0\n", ret
);
1136 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
1137 SetRect(&rc_client
, 0, 0, 250, 150);
1138 rc_window
= rc_client
;
1139 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
1140 FixedAdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
1143 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
1144 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
1145 ok(EqualRect(&rc
, &rc_client
),
1146 "synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, client=%s, calc=%s\n",
1147 style
, exstyle
, menu
, wine_dbgstr_rect(&rc_client
), wine_dbgstr_rect(&rc
));
1150 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
1152 static const char *CBT_code_name
[10] = {
1159 "HCBT_CLICKSKIPPED",
1163 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
1164 HWND hwnd
= (HWND
)wParam
;
1168 case HCBT_CREATEWND
:
1170 static const RECT rc_null
;
1173 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
1174 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
1179 info
.cbSize
= sizeof(WINDOWINFO
);
1180 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1181 verify_window_info(code_name
, hwnd
, &info
);
1184 /* WS_VISIBLE should be turned off yet */
1185 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
1186 ok(style
== GetWindowLongA(hwnd
, GWL_STYLE
),
1187 "style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
1188 GetWindowLongA(hwnd
, GWL_STYLE
), style
);
1192 /* Uncomment this once the test succeeds in all cases */
1193 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1195 ok(GetParent(hwnd
) == hwndMessage
,
1196 "wrong result from GetParent %p: message window %p\n",
1197 GetParent(hwnd
), hwndMessage
);
1200 ok(!GetParent(hwnd
), "GetParent should return 0 at this point\n");
1202 ok(!GetWindow(hwnd
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
1206 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
1207 * Win9x still has them set to 0.
1209 ok(GetWindow(hwnd
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
1210 ok(GetWindow(hwnd
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
1212 ok(!GetWindow(hwnd
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
1213 ok(!GetWindow(hwnd
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
1217 /* Uncomment this once the test succeeds in all cases */
1220 ok(pGetAncestor(hwnd
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
1221 ok(pGetAncestor(hwnd
, GA_ROOT
) == hwnd
,
1222 "GA_ROOT is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOT
), hwnd
);
1224 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1225 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwndMessage
,
1226 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
1228 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwnd
,
1229 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOTOWNER
), hwnd
);
1232 ok(GetWindowRect(hwnd
, &rc
), "GetWindowRect failed\n");
1233 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
1234 ok(GetClientRect(hwnd
, &rc
), "GetClientRect failed\n");
1235 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
1242 if (pGetWindowInfo
&& IsWindow(hwnd
))
1246 /* Win98 actually does check the info.cbSize and doesn't allow
1247 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
1248 * WinXP do not check it at all.
1250 info
.cbSize
= sizeof(WINDOWINFO
);
1251 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1252 verify_window_info(code_name
, hwnd
, &info
);
1255 /* window state is undefined */
1257 case HCBT_DESTROYWND
:
1263 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
1266 static const WCHAR winlogonW
[] =
1267 {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
1268 'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
1269 'W','i','n','l','o','g','o','n',0};
1270 static const WCHAR autorestartshellW
[] =
1271 {'A','u','t','o','R','e','s','t','a','r','t','S','h','e','l','l',0};
1273 static DWORD
get_autorestart(void)
1275 DWORD type
, val
, len
= sizeof(val
);
1276 REGSAM access
= KEY_ALL_ACCESS
|KEY_WOW64_64KEY
;
1280 if (RegCreateKeyExW( HKEY_LOCAL_MACHINE
, winlogonW
, 0, 0, 0, access
, NULL
, &hkey
, 0 )) return 0;
1281 res
= RegQueryValueExW( hkey
, autorestartshellW
, NULL
, &type
, (BYTE
*)&val
, &len
);
1282 RegCloseKey( hkey
);
1283 return (!res
&& type
== REG_DWORD
) ? val
: 0;
1286 static BOOL
set_autorestart( DWORD val
)
1288 REGSAM access
= KEY_ALL_ACCESS
|KEY_WOW64_64KEY
;
1292 if (RegCreateKeyExW( HKEY_LOCAL_MACHINE
, winlogonW
, 0, 0, 0, access
, NULL
, &hkey
, 0 )) return FALSE
;
1293 res
= RegSetValueExW( hkey
, autorestartshellW
, 0, REG_DWORD
, (BYTE
*)&val
, sizeof(val
) );
1294 RegCloseKey( hkey
);
1298 static void test_shell_window(void)
1301 DWORD error
, restart
= get_autorestart();
1302 HMODULE hinst
, hUser32
;
1303 BOOL (WINAPI
*SetShellWindow
)(HWND
);
1304 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
1305 HWND shellWindow
, nextWnd
;
1307 if (restart
&& !set_autorestart(0))
1309 skip("cannot disable automatic shell restart (needs admin rights\n");
1313 shellWindow
= GetShellWindow();
1314 hinst
= GetModuleHandleA(NULL
);
1315 hUser32
= GetModuleHandleA("user32");
1317 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
1323 GetWindowThreadProcessId(shellWindow
, &pid
);
1324 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
1327 skip( "cannot get access to shell process\n" );
1328 set_autorestart(restart
);
1332 SetLastError(0xdeadbeef);
1333 ret
= DestroyWindow(shellWindow
);
1334 error
= GetLastError();
1336 ok(!ret
, "DestroyWindow(shellWindow)\n");
1337 /* passes on Win XP, but not on Win98 */
1338 ok(error
==ERROR_ACCESS_DENIED
|| error
== 0xdeadbeef,
1339 "got %u after DestroyWindow(shellWindow)\n", error
);
1341 /* close old shell instance */
1342 ret
= TerminateProcess(hProcess
, 0);
1343 ok(ret
, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
1344 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
1345 CloseHandle(hProcess
);
1348 hwnd1
= CreateWindowExA(0, "#32770", "TEST1", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
1350 ret
= SetShellWindow(hwnd1
);
1351 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
1352 shellWindow
= GetShellWindow();
1353 ok(shellWindow
==hwnd1
, "wrong shell window: %p/%p\n", shellWindow
,hwnd1
);
1355 ret
= SetShellWindow(hwnd1
);
1356 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
1358 ret
= SetShellWindow(0);
1359 error
= GetLastError();
1360 /* passes on Win XP, but not on Win98
1361 ok(!ret, "reset shell window by SetShellWindow(0)\n");
1362 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
1364 ret
= SetShellWindow(hwnd1
);
1365 /* passes on Win XP, but not on Win98
1366 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
1368 SetWindowLongA(hwnd1
, GWL_EXSTYLE
, GetWindowLongA(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
1369 ret
= (GetWindowLongA(hwnd1
,GWL_EXSTYLE
) & WS_EX_TOPMOST
) != 0;
1370 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
1372 ret
= DestroyWindow(hwnd1
);
1373 ok(ret
, "DestroyWindow(hwnd1)\n");
1375 hwnd2
= CreateWindowExA(WS_EX_TOPMOST
, "#32770", "TEST2", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
1376 ret
= SetShellWindow(hwnd2
);
1377 ok(!ret
, "SetShellWindow(%p) with WS_EX_TOPMOST\n", hwnd2
);
1379 hwnd3
= CreateWindowExA(0, "#32770", "TEST3", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
1381 hwnd4
= CreateWindowExA(0, "#32770", "TEST4", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
1383 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1384 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4 %p: %p - expected %p\n", hwnd4
, nextWnd
, hwnd3
);
1386 ret
= SetShellWindow(hwnd4
);
1387 ok(ret
, "SetShellWindow(hwnd4)\n");
1388 shellWindow
= GetShellWindow();
1389 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected %p\n", shellWindow
, hwnd4
);
1391 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1392 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
1394 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1395 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1397 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1398 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
1400 ret
= SetShellWindow(hwnd3
);
1401 ok(!ret
, "SetShellWindow(hwnd3)\n");
1402 shellWindow
= GetShellWindow();
1403 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected %p\n", shellWindow
, hwnd4
);
1405 hwnd5
= CreateWindowExA(0, "#32770", "TEST5", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
1406 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1407 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
1411 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1412 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
1415 /* destroy test windows */
1416 DestroyWindow(hwnd2
);
1417 DestroyWindow(hwnd3
);
1418 DestroyWindow(hwnd4
);
1419 DestroyWindow(hwnd5
);
1420 set_autorestart(restart
);
1423 /************** MDI test ****************/
1425 static char mdi_lParam_test_message
[] = "just a test string";
1427 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT_PTR first_id
)
1429 MDICREATESTRUCTA mdi_cs
;
1430 HWND mdi_child
, hwnd
, exp_hwnd
;
1432 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1433 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
1434 HMENU frame_menu
= GetMenu(parent
);
1436 ok(frame_menu
!= NULL
, "Frame window didn't have a menu\n");
1438 mdi_cs
.szClass
= "MDI_child_Class_1";
1439 mdi_cs
.szTitle
= "MDI child";
1440 mdi_cs
.hOwner
= GetModuleHandleA(NULL
);
1441 mdi_cs
.x
= CW_USEDEFAULT
;
1442 mdi_cs
.y
= CW_USEDEFAULT
;
1443 mdi_cs
.cx
= CW_USEDEFAULT
;
1444 mdi_cs
.cy
= CW_USEDEFAULT
;
1446 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1447 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1448 ok(mdi_child
!= 0, "MDI child creation failed\n");
1449 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1450 ok(id
== first_id
, "wrong child id %ld\n", id
);
1451 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1452 exp_hwnd
= (GetWindowLongW(mdi_child
, GWL_STYLE
) & WS_VISIBLE
) ? mdi_child
: 0;
1453 ok(hwnd
== exp_hwnd
, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd
, hwnd
);
1454 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1455 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1457 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
1458 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1459 ok(mdi_child
!= 0, "MDI child creation failed\n");
1460 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1461 ok(id
== first_id
, "wrong child id %ld\n", id
);
1462 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1463 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1464 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1465 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1467 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
1468 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1469 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1471 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1475 ok(mdi_child
!= 0, "MDI child creation failed\n");
1476 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1477 ok(id
== first_id
, "wrong child id %ld\n", id
);
1478 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1479 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1480 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1481 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1482 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1485 /* test MDICREATESTRUCT A<->W mapping */
1486 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1488 mdi_cs
.szClass
= (LPCSTR
)classW
;
1489 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
1490 SetLastError(0xdeadbeef);
1491 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1492 ok(mdi_child
!= 0, "MDI child creation failed\n");
1493 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1494 ok(id
== first_id
, "wrong child id %ld\n", id
);
1495 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1496 exp_hwnd
= (GetWindowLongW(mdi_child
, GWL_STYLE
) & WS_VISIBLE
) ? mdi_child
: 0;
1497 ok(hwnd
== exp_hwnd
, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd
, hwnd
);
1498 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1499 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1500 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1502 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1504 CW_USEDEFAULT
, CW_USEDEFAULT
,
1505 CW_USEDEFAULT
, CW_USEDEFAULT
,
1506 mdi_client
, GetModuleHandleA(NULL
),
1507 (LPARAM
)mdi_lParam_test_message
);
1508 ok(mdi_child
!= 0, "MDI child creation failed\n");
1509 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1510 ok(id
== first_id
, "wrong child id %ld\n", id
);
1511 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1512 exp_hwnd
= (GetWindowLongW(mdi_child
, GWL_STYLE
) & WS_VISIBLE
) ? mdi_child
: 0;
1513 ok(hwnd
== exp_hwnd
, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd
, hwnd
);
1514 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1515 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1516 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1518 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1519 0x7fffffff, /* without WS_POPUP */
1520 CW_USEDEFAULT
, CW_USEDEFAULT
,
1521 CW_USEDEFAULT
, CW_USEDEFAULT
,
1522 mdi_client
, GetModuleHandleA(NULL
),
1523 (LPARAM
)mdi_lParam_test_message
);
1524 ok(mdi_child
!= 0, "MDI child creation failed\n");
1525 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1526 ok(id
== first_id
, "wrong child id %ld\n", id
);
1527 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1528 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1529 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1530 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1531 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1533 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1534 0xffffffff, /* with WS_POPUP */
1535 CW_USEDEFAULT
, CW_USEDEFAULT
,
1536 CW_USEDEFAULT
, CW_USEDEFAULT
,
1537 mdi_client
, GetModuleHandleA(NULL
),
1538 (LPARAM
)mdi_lParam_test_message
);
1539 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1541 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1545 ok(mdi_child
!= 0, "MDI child creation failed\n");
1546 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1547 ok(id
== first_id
, "wrong child id %ld\n", id
);
1548 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1549 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1550 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1551 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1552 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1555 /* test MDICREATESTRUCT A<->W mapping */
1556 SetLastError(0xdeadbeef);
1557 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1559 CW_USEDEFAULT
, CW_USEDEFAULT
,
1560 CW_USEDEFAULT
, CW_USEDEFAULT
,
1561 mdi_client
, GetModuleHandleA(NULL
),
1562 (LPARAM
)mdi_lParam_test_message
);
1563 ok(mdi_child
!= 0, "MDI child creation failed\n");
1564 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1565 ok(id
== first_id
, "wrong child id %ld\n", id
);
1566 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1567 exp_hwnd
= (GetWindowLongW(mdi_child
, GWL_STYLE
) & WS_VISIBLE
) ? mdi_child
: 0;
1568 ok(hwnd
== exp_hwnd
, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd
, hwnd
);
1569 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1570 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1571 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1573 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1575 CW_USEDEFAULT
, CW_USEDEFAULT
,
1576 CW_USEDEFAULT
, CW_USEDEFAULT
,
1577 mdi_client
, 0, GetModuleHandleA(NULL
),
1578 mdi_lParam_test_message
);
1579 ok(mdi_child
!= 0, "MDI child creation failed\n");
1580 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1581 ok(id
== first_id
, "wrong child id %ld\n", id
);
1582 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1583 exp_hwnd
= (GetWindowLongW(mdi_child
, GWL_STYLE
) & WS_VISIBLE
) ? mdi_child
: 0;
1584 ok(hwnd
== exp_hwnd
, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd
, hwnd
);
1585 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1586 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1587 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1589 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1591 CW_USEDEFAULT
, CW_USEDEFAULT
,
1592 CW_USEDEFAULT
, CW_USEDEFAULT
,
1593 mdi_client
, 0, GetModuleHandleA(NULL
),
1594 mdi_lParam_test_message
);
1595 ok(mdi_child
!= 0, "MDI child creation failed\n");
1596 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1597 ok(id
== first_id
, "wrong child id %ld\n", id
);
1598 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1599 exp_hwnd
= (GetWindowLongW(mdi_child
, GWL_STYLE
) & WS_VISIBLE
) ? mdi_child
: 0;
1600 ok(hwnd
== exp_hwnd
, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd
, hwnd
);
1601 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1602 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1604 ok(GetMenuItemCount(frame_menu
) == 4, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1605 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1606 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1608 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1609 0x7fffffff, /* without WS_POPUP */
1610 CW_USEDEFAULT
, CW_USEDEFAULT
,
1611 CW_USEDEFAULT
, CW_USEDEFAULT
,
1612 mdi_client
, 0, GetModuleHandleA(NULL
),
1613 mdi_lParam_test_message
);
1614 ok(mdi_child
!= 0, "MDI child creation failed\n");
1615 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1616 ok(id
== first_id
, "wrong child id %ld\n", id
);
1617 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1618 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1619 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1620 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1621 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1623 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1624 0xffffffff, /* with WS_POPUP */
1625 CW_USEDEFAULT
, CW_USEDEFAULT
,
1626 CW_USEDEFAULT
, CW_USEDEFAULT
,
1627 mdi_client
, 0, GetModuleHandleA(NULL
),
1628 mdi_lParam_test_message
);
1629 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1631 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1635 ok(mdi_child
!= 0, "MDI child creation failed\n");
1636 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1637 ok(id
== first_id
, "wrong child id %ld\n", id
);
1638 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1639 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1640 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1641 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1642 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1645 /* test MDICREATESTRUCT A<->W mapping */
1646 SetLastError(0xdeadbeef);
1647 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1649 CW_USEDEFAULT
, CW_USEDEFAULT
,
1650 CW_USEDEFAULT
, CW_USEDEFAULT
,
1651 mdi_client
, 0, GetModuleHandleA(NULL
),
1652 mdi_lParam_test_message
);
1653 ok(mdi_child
!= 0, "MDI child creation failed\n");
1654 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1655 ok(id
== first_id
, "wrong child id %ld\n", id
);
1656 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1657 exp_hwnd
= (GetWindowLongW(mdi_child
, GWL_STYLE
) & WS_VISIBLE
) ? mdi_child
: 0;
1658 ok(hwnd
== exp_hwnd
, "WM_MDIGETACTIVE should return %p, got %p\n", exp_hwnd
, hwnd
);
1659 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1660 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1661 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1663 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1665 CW_USEDEFAULT
, CW_USEDEFAULT
,
1666 CW_USEDEFAULT
, CW_USEDEFAULT
,
1667 parent
, 0, GetModuleHandleA(NULL
),
1668 mdi_lParam_test_message
);
1669 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1671 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1672 WS_CHILD
, /* without WS_POPUP */
1673 CW_USEDEFAULT
, CW_USEDEFAULT
,
1674 CW_USEDEFAULT
, CW_USEDEFAULT
,
1675 mdi_client
, 0, GetModuleHandleA(NULL
),
1676 mdi_lParam_test_message
);
1677 ok(mdi_child
!= 0, "MDI child creation failed\n");
1678 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1679 ok(id
== 0, "wrong child id %ld\n", id
);
1680 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1681 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1682 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1683 DestroyWindow(mdi_child
);
1685 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1686 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1687 CW_USEDEFAULT
, CW_USEDEFAULT
,
1688 CW_USEDEFAULT
, CW_USEDEFAULT
,
1689 mdi_client
, 0, GetModuleHandleA(NULL
),
1690 mdi_lParam_test_message
);
1691 ok(mdi_child
!= 0, "MDI child creation failed\n");
1692 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1693 ok(id
== 0, "wrong child id %ld\n", id
);
1694 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1695 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1696 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1697 DestroyWindow(mdi_child
);
1699 /* maximized child */
1700 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1701 WS_CHILD
| WS_MAXIMIZE
,
1702 CW_USEDEFAULT
, CW_USEDEFAULT
,
1703 CW_USEDEFAULT
, CW_USEDEFAULT
,
1704 mdi_client
, 0, GetModuleHandleA(NULL
),
1705 mdi_lParam_test_message
);
1706 ok(mdi_child
!= 0, "MDI child creation failed\n");
1707 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1708 ok(id
== 0, "wrong child id %ld\n", id
);
1709 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1710 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1711 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1712 DestroyWindow(mdi_child
);
1714 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1715 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1716 CW_USEDEFAULT
, CW_USEDEFAULT
,
1717 CW_USEDEFAULT
, CW_USEDEFAULT
,
1718 mdi_client
, 0, GetModuleHandleA(NULL
),
1719 mdi_lParam_test_message
);
1720 ok(mdi_child
!= 0, "MDI child creation failed\n");
1721 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1722 ok(id
== 0, "wrong child id %ld\n", id
);
1723 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1724 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1725 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1726 DestroyWindow(mdi_child
);
1728 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1729 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1730 CW_USEDEFAULT
, CW_USEDEFAULT
,
1731 CW_USEDEFAULT
, CW_USEDEFAULT
,
1732 mdi_client
, 0, GetModuleHandleA(NULL
),
1733 mdi_lParam_test_message
);
1734 ok(mdi_child
!= 0, "MDI child creation failed\n");
1735 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1736 ok(id
== 0, "wrong child id %ld\n", id
);
1737 hwnd
= (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1738 ok(!hwnd
, "WM_MDIGETACTIVE should return 0, got %p\n", hwnd
);
1739 ok(GetMenuItemCount(frame_menu
) == 0, "Got wrong frame menu item count: %u\n", GetMenuItemCount(frame_menu
));
1740 DestroyWindow(mdi_child
);
1743 static void test_MDI_child_stack(HWND mdi_client
)
1745 HWND child_1
, child_2
, child_3
, child_4
;
1747 MDICREATESTRUCTA cs
;
1749 cs
.szClass
= "MDI_child_Class_1";
1750 cs
.szTitle
= "MDI child";
1751 cs
.hOwner
= GetModuleHandleA(0);
1752 cs
.x
= CW_USEDEFAULT
;
1753 cs
.y
= CW_USEDEFAULT
;
1754 cs
.cx
= CW_USEDEFAULT
;
1755 cs
.cy
= CW_USEDEFAULT
;
1757 cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1759 child_1
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1760 ok(child_1
!= 0, "expected child_1 to be non NULL\n");
1761 child_2
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1762 ok(child_2
!= 0, "expected child_2 to be non NULL\n");
1763 child_3
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1764 ok(child_3
!= 0, "expected child_3 to be non NULL\n");
1765 child_4
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1766 ok(child_4
!= 0, "expected child_4 to be non NULL\n");
1768 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1769 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1770 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1771 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1772 ok(stack
[0] == child_4
&& stack
[1] == child_3
&&
1773 stack
[2] == child_2
&& stack
[3] == child_1
,
1774 "Unexpected initial order, should be: %p->%p->%p->%p\n",
1775 child_4
, child_3
, child_2
, child_1
);
1777 SendMessageA(mdi_client
, WM_MDINEXT
, (WPARAM
)child_3
, 0);
1779 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1780 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1781 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1782 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1783 ok(stack
[0] == child_2
&& stack
[1] == child_4
&&
1784 stack
[2] == child_1
&& stack
[3] == child_3
,
1785 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1786 child_2
, child_4
, child_1
, child_3
, stack
[0], stack
[1], stack
[2], stack
[3]);
1788 SendMessageA(mdi_client
, WM_MDINEXT
, (WPARAM
)child_1
, 1);
1790 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1791 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1792 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1793 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1794 ok(stack
[0] == child_4
&& stack
[1] == child_2
&&
1795 stack
[2] == child_1
&& stack
[3] == child_3
,
1796 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1797 child_4
, child_2
, child_1
, child_3
, stack
[0], stack
[1], stack
[2], stack
[3]);
1799 ShowWindow(child_4
, SW_MINIMIZE
);
1801 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1802 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1803 todo_wine
ok(stack
[0] == child_4
, "Expected %p, got %p\n", child_4
, stack
[0]);
1804 todo_wine
ok(stack
[1] == NULL
, "Expected NULL, got %p\n", stack
[1]);
1806 DestroyWindow(child_1
);
1807 DestroyWindow(child_2
);
1808 DestroyWindow(child_3
);
1809 DestroyWindow(child_4
);
1812 /**********************************************************************
1813 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1815 * Note: The rule here is that client rect of the maximized MDI child
1816 * is equal to the client rect of the MDI client window.
1818 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1822 GetClientRect( client
, &rect
);
1823 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1824 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1826 rect
.right
-= rect
.left
;
1827 rect
.bottom
-= rect
.top
;
1828 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1829 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1831 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1832 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1835 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1842 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1843 MDICREATESTRUCTA
*mdi_cs
= cs
->lpCreateParams
;
1845 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1846 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1848 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1849 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1850 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1851 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1852 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1854 /* MDICREATESTRUCT should have original values */
1855 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff || mdi_cs
->style
== WS_MAXIMIZE
,
1856 "mdi_cs->style does not match (%08x)\n", mdi_cs
->style
);
1857 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1858 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1859 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1860 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1862 /* CREATESTRUCT should have fixed values */
1863 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1864 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1866 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1867 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1868 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1870 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1872 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1874 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1875 ok(cs
->style
== style
,
1876 "cs->style does not match (%08x)\n", cs
->style
);
1880 LONG style
= mdi_cs
->style
;
1882 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1883 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1884 ok(cs
->style
== style
,
1885 "cs->style does not match (%08x)\n", cs
->style
);
1890 case WM_GETMINMAXINFO
:
1892 HWND client
= GetParent(hwnd
);
1894 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1895 MINMAXINFO my_minmax
;
1896 LONG style
, exstyle
;
1898 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1899 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1901 GetClientRect(client
, &rc
);
1903 GetClientRect(client
, &rc
);
1904 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1905 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1906 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1907 if (winetest_debug
> 1)
1909 trace("MDI child: calculated max window size = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1910 dump_minmax_info( minmax
);
1913 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1914 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1915 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1916 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1918 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1920 if (winetest_debug
> 1)
1922 trace("DefMDIChildProc returned:\n");
1923 dump_minmax_info( minmax
);
1926 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1927 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %d != %d\n",
1928 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1929 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %d != %d\n",
1930 minmax
->ptMaxSize
.y
, my_minmax
.ptMaxSize
.y
);
1935 case WM_MDIACTIVATE
:
1937 HWND active
, client
= GetParent(hwnd
);
1938 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1939 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
1940 if (hwnd
== (HWND
)lparam
) /* if we are being activated */
1941 ok (active
== (HWND
)lparam
, "new active %p != active %p\n", (HWND
)lparam
, active
);
1943 ok (active
== (HWND
)wparam
, "old active %p != active %p\n", (HWND
)wparam
, active
);
1947 return DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1950 static LRESULT WINAPI
mdi_child_wnd_proc_2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1957 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1959 if (winetest_debug
> 1)
1960 trace("%s: x %d, y %d, cx %d, cy %d\n", (msg
== WM_NCCREATE
) ? "WM_NCCREATE" : "WM_CREATE",
1961 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1963 ok(!(cs
->dwExStyle
& WS_EX_MDICHILD
), "WS_EX_MDICHILD should not be set\n");
1964 ok(cs
->lpCreateParams
== mdi_lParam_test_message
, "wrong cs->lpCreateParams\n");
1966 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_2"), "wrong class name\n");
1967 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1969 /* CREATESTRUCT should have fixed values */
1970 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1971 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1973 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1974 ok(cs
->cx
== 0, "%d != 0\n", cs
->cx
);
1975 ok(cs
->cy
== 0, "%d != 0\n", cs
->cy
);
1979 case WM_GETMINMAXINFO
:
1981 HWND parent
= GetParent(hwnd
);
1983 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1984 LONG style
, exstyle
;
1986 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1987 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1989 GetClientRect(parent
, &rc
);
1990 if (winetest_debug
> 1)
1992 trace("WM_GETMINMAXINFO: parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
1993 dump_minmax_info( minmax
);
1995 GetClientRect(parent
, &rc
);
1996 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1997 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1998 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
2000 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
2001 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
2002 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
2003 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
2007 case WM_WINDOWPOSCHANGED
:
2009 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
2012 GetWindowRect(hwnd
, &rc1
);
2013 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
2014 /* note: winpos coordinates are relative to parent */
2015 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
2016 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=%s pos=%s\n",
2017 wine_dbgstr_rect(&rc1
), wine_dbgstr_rect(&rc2
));
2018 GetWindowRect(hwnd
, &rc1
);
2019 GetClientRect(hwnd
, &rc2
);
2020 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
2021 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
2022 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=%s client=%s\n",
2023 wine_dbgstr_rect(&rc1
), wine_dbgstr_rect(&rc2
));
2026 case WM_WINDOWPOSCHANGING
:
2028 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
2029 WINDOWPOS my_winpos
= *winpos
;
2031 if (winetest_debug
> 1)
2032 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2033 (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
2034 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2035 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2037 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
2039 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
2040 "DefWindowProc should not change WINDOWPOS: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2041 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2042 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2047 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
2050 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2052 static HWND mdi_client
;
2059 case WM_WINDOWPOSCHANGED
:
2061 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
2064 GetWindowRect(hwnd
, &rc1
);
2065 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
2066 /* note: winpos coordinates are relative to parent */
2067 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
2068 ok(EqualRect(&rc1
, &rc2
), "rects %s %s do not match\n",
2069 wine_dbgstr_rect(&rc1
), wine_dbgstr_rect(&rc2
));
2071 GetWindowRect(hwnd
, &rc1
);
2072 GetClientRect(hwnd
, &rc2
);
2073 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
2074 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
2075 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
2078 case WM_WINDOWPOSCHANGING
:
2080 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
2081 WINDOWPOS my_winpos
= *winpos
;
2083 if (winetest_debug
> 1)
2084 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2085 (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
2086 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2087 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2089 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
2091 if (winetest_debug
> 1)
2092 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
2093 winpos
->hwnd
, winpos
->hwndInsertAfter
,
2094 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
2096 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
2097 "DefWindowProc should not change WINDOWPOS values\n");
2106 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
2109 static BOOL
mdi_RegisterWindowClasses(void)
2114 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
2117 cls
.hInstance
= GetModuleHandleA(0);
2119 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
2120 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
2121 cls
.lpszMenuName
= NULL
;
2122 cls
.lpszClassName
= "MDI_parent_Class";
2123 if(!RegisterClassA(&cls
)) return FALSE
;
2125 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
2126 cls
.lpszClassName
= "MDI_child_Class_1";
2127 if(!RegisterClassA(&cls
)) return FALSE
;
2129 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
2130 cls
.lpszClassName
= "MDI_child_Class_2";
2131 if(!RegisterClassA(&cls
)) return FALSE
;
2136 static void test_mdi(void)
2138 static const DWORD style
[] = { 0, WS_HSCROLL
, WS_VSCROLL
, WS_HSCROLL
| WS_VSCROLL
};
2139 HWND mdi_hwndMain
, mdi_client
, mdi_child
;
2140 CLIENTCREATESTRUCT client_cs
;
2144 HMENU frame_menu
, child_menu
;
2146 if (!mdi_RegisterWindowClasses()) assert(0);
2148 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
2149 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2150 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
2151 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
2152 GetDesktopWindow(), 0,
2153 GetModuleHandleA(NULL
), NULL
);
2154 assert(mdi_hwndMain
);
2156 frame_menu
= CreateMenu();
2158 GetClientRect(mdi_hwndMain
, &rc
);
2160 client_cs
.hWindowMenu
= 0;
2161 client_cs
.idFirstChild
= 1;
2163 for (i
= 0; i
< sizeof(style
)/sizeof(style
[0]); i
++)
2168 mdi_client
= CreateWindowExA(0, "mdiclient", NULL
,
2169 WS_CHILD
| style
[i
],
2170 0, 0, rc
.right
, rc
.bottom
,
2171 mdi_hwndMain
, 0, 0, &client_cs
);
2172 ok(mdi_client
!= 0, "MDI client creation failed\n");
2174 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
2176 CW_USEDEFAULT
, CW_USEDEFAULT
,
2177 CW_USEDEFAULT
, CW_USEDEFAULT
,
2179 mdi_lParam_test_message
);
2180 ok(mdi_child
!= 0, "MDI child creation failed\n");
2182 SendMessageW(mdi_child
, WM_SIZE
, SIZE_MAXIMIZED
, 0);
2183 SetMenu(mdi_hwndMain
, frame_menu
);
2185 ok(GetMenuItemCount(frame_menu
) == 0, "Frame menu should be empty after child maximize, but has %u\n",
2186 GetMenuItemCount(frame_menu
));
2188 child_menu
= CreateMenu();
2189 SendMessageW(mdi_client
, WM_MDISETMENU
, 0, (LPARAM
)child_menu
);
2191 ok(GetMenuItemCount(frame_menu
) == 0, "Frame menu should be empty after WM_MDISETMENU, but has %u\n",
2192 GetMenuItemCount(frame_menu
));
2194 SendMessageW(mdi_child
, WM_SIZE
, SIZE_RESTORED
, 0);
2196 ok(GetMenuItemCount(frame_menu
) == 0, "Frame menu should be empty after child restored, but has %u items\n",
2197 GetMenuItemCount(frame_menu
));
2199 SetMenu(mdi_hwndMain
, NULL
);
2201 si
.cbSize
= sizeof(si
);
2203 ret
= GetScrollInfo(mdi_client
, SB_HORZ
, &si
);
2204 if (style
[i
] & (WS_HSCROLL
| WS_VSCROLL
))
2206 ok(ret
, "style %#x: GetScrollInfo(SB_HORZ) failed\n", style
[i
]);
2207 ok(si
.nPage
== 0, "expected 0\n");
2208 ok(si
.nPos
== 0, "expected 0\n");
2209 ok(si
.nTrackPos
== 0, "expected 0\n");
2210 ok(si
.nMin
== 0, "expected 0\n");
2211 ok(si
.nMax
== 100, "expected 100\n");
2214 ok(!ret
, "style %#x: GetScrollInfo(SB_HORZ) should fail\n", style
[i
]);
2216 ret
= GetScrollInfo(mdi_client
, SB_VERT
, &si
);
2217 if (style
[i
] & (WS_HSCROLL
| WS_VSCROLL
))
2219 ok(ret
, "style %#x: GetScrollInfo(SB_VERT) failed\n", style
[i
]);
2220 ok(si
.nPage
== 0, "expected 0\n");
2221 ok(si
.nPos
== 0, "expected 0\n");
2222 ok(si
.nTrackPos
== 0, "expected 0\n");
2223 ok(si
.nMin
== 0, "expected 0\n");
2224 ok(si
.nMax
== 100, "expected 100\n");
2227 ok(!ret
, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style
[i
]);
2229 SetWindowPos(mdi_child
, 0, -100, -100, 0, 0, SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOSIZE
);
2231 si
.cbSize
= sizeof(si
);
2233 ret
= GetScrollInfo(mdi_client
, SB_HORZ
, &si
);
2234 if (style
[i
] & (WS_HSCROLL
| WS_VSCROLL
))
2236 ok(ret
, "style %#x: GetScrollInfo(SB_HORZ) failed\n", style
[i
]);
2237 ok(si
.nPage
== 0, "expected 0\n");
2238 ok(si
.nPos
== 0, "expected 0\n");
2239 ok(si
.nTrackPos
== 0, "expected 0\n");
2240 ok(si
.nMin
== 0, "expected 0\n");
2241 ok(si
.nMax
== 100, "expected 100\n");
2244 ok(!ret
, "style %#x: GetScrollInfo(SB_HORZ) should fail\n", style
[i
]);
2246 ret
= GetScrollInfo(mdi_client
, SB_VERT
, &si
);
2247 if (style
[i
] & (WS_HSCROLL
| WS_VSCROLL
))
2249 ok(ret
, "style %#x: GetScrollInfo(SB_VERT) failed\n", style
[i
]);
2250 ok(si
.nPage
== 0, "expected 0\n");
2251 ok(si
.nPos
== 0, "expected 0\n");
2252 ok(si
.nTrackPos
== 0, "expected 0\n");
2253 ok(si
.nMin
== 0, "expected 0\n");
2254 ok(si
.nMax
== 100, "expected 100\n");
2257 ok(!ret
, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style
[i
]);
2260 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
2262 if (msg
.message
== WM_MOUSEMOVE
|| msg
.message
== WM_PAINT
)
2264 DispatchMessageA(&msg
);
2268 if (msg
.message
== 0x003f) /* WM_MDICALCCHILDSCROLL ??? */
2270 ok(msg
.hwnd
== mdi_client
, "message 0x003f should be posted to mdiclient\n");
2274 ok(msg
.hwnd
!= mdi_client
, "message %04x should not be posted to mdiclient\n", msg
.message
);
2275 DispatchMessageA(&msg
);
2277 ok(gotit
, "message 0x003f should appear after SetWindowPos\n");
2279 si
.cbSize
= sizeof(si
);
2281 ret
= GetScrollInfo(mdi_client
, SB_HORZ
, &si
);
2282 if (style
[i
] & (WS_HSCROLL
| WS_VSCROLL
))
2284 ok(ret
, "style %#x: GetScrollInfo(SB_HORZ) failed\n", style
[i
]);
2286 ok(si
.nPage
!= 0, "expected !0\n");
2287 ok(si
.nPos
== 0, "expected 0\n");
2288 ok(si
.nTrackPos
== 0, "expected 0\n");
2289 ok(si
.nMin
!= 0, "expected !0\n");
2290 ok(si
.nMax
!= 100, "expected !100\n");
2293 ok(!ret
, "style %#x: GetScrollInfo(SB_HORZ) should fail\n", style
[i
]);
2295 ret
= GetScrollInfo(mdi_client
, SB_VERT
, &si
);
2296 if (style
[i
] & (WS_HSCROLL
| WS_VSCROLL
))
2298 ok(ret
, "style %#x: GetScrollInfo(SB_VERT) failed\n", style
[i
]);
2300 ok(si
.nPage
!= 0, "expected !0\n");
2301 ok(si
.nPos
== 0, "expected 0\n");
2302 ok(si
.nTrackPos
== 0, "expected 0\n");
2303 ok(si
.nMin
!= 0, "expected !0\n");
2304 ok(si
.nMax
!= 100, "expected !100\n");
2307 ok(!ret
, "style %#x: GetScrollInfo(SB_VERT) should fail\n", style
[i
]);
2309 DestroyMenu(child_menu
);
2310 DestroyWindow(mdi_child
);
2311 DestroyWindow(mdi_client
);
2314 SetMenu(mdi_hwndMain
, frame_menu
);
2316 mdi_client
= CreateWindowExA(0, "mdiclient", NULL
,
2318 0, 0, rc
.right
, rc
.bottom
,
2319 mdi_hwndMain
, 0, 0, &client_cs
);
2320 ok(mdi_client
!= 0, "MDI client creation failed\n");
2322 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
2324 CW_USEDEFAULT
, CW_USEDEFAULT
,
2325 CW_USEDEFAULT
, CW_USEDEFAULT
,
2327 mdi_lParam_test_message
);
2328 ok(mdi_child
!= 0, "MDI child creation failed\n");
2330 SendMessageW(mdi_child
, WM_SIZE
, SIZE_MAXIMIZED
, 0);
2331 ok(GetMenuItemCount(frame_menu
) == 4, "Frame menu should have 4 items after child maximize, but has %u\n",
2332 GetMenuItemCount(frame_menu
));
2334 child_menu
= CreateMenu();
2335 SendMessageW(mdi_client
, WM_MDISETMENU
, 0, (LPARAM
)child_menu
);
2337 ok(GetMenuItemCount(frame_menu
) == 4, "Frame menu should have 4 items after WM_MDISETMENU, but has %u\n",
2338 GetMenuItemCount(frame_menu
));
2340 SendMessageW(mdi_child
, WM_SIZE
, SIZE_RESTORED
, 0);
2342 ok(GetMenuItemCount(frame_menu
) == 0, "Frame menu should be empty after child restored, but has %u items\n",
2343 GetMenuItemCount(frame_menu
));
2345 DestroyMenu(child_menu
);
2346 DestroyWindow(mdi_child
);
2347 DestroyWindow(mdi_client
);
2349 /* MDIClient without MDIS_ALLCHILDSTYLES */
2350 mdi_client
= CreateWindowExA(0, "mdiclient",
2352 WS_CHILD
/*| WS_VISIBLE*/,
2353 /* tests depend on a not zero MDIClient size */
2354 0, 0, rc
.right
, rc
.bottom
,
2355 mdi_hwndMain
, 0, GetModuleHandleA(NULL
),
2358 test_MDI_create(mdi_hwndMain
, mdi_client
, client_cs
.idFirstChild
);
2359 DestroyWindow(mdi_client
);
2361 /* MDIClient with MDIS_ALLCHILDSTYLES */
2362 mdi_client
= CreateWindowExA(0, "mdiclient",
2364 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
2365 /* tests depend on a not zero MDIClient size */
2366 0, 0, rc
.right
, rc
.bottom
,
2367 mdi_hwndMain
, 0, GetModuleHandleA(NULL
),
2370 test_MDI_create(mdi_hwndMain
, mdi_client
, client_cs
.idFirstChild
);
2371 DestroyWindow(mdi_client
);
2373 /* Test child window stack management */
2374 mdi_client
= CreateWindowExA(0, "mdiclient",
2377 0, 0, rc
.right
, rc
.bottom
,
2378 mdi_hwndMain
, 0, GetModuleHandleA(NULL
),
2381 test_MDI_child_stack(mdi_client
);
2382 DestroyWindow(mdi_client
);
2384 while(GetMessage(&msg, 0, 0, 0))
2386 TranslateMessage(&msg);
2387 DispatchMessage(&msg);
2390 DestroyWindow(mdi_hwndMain
);
2393 static void test_icons(void)
2397 HICON icon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
2398 HICON icon2
= LoadIconA(0, (LPCSTR
)IDI_QUESTION
);
2399 HICON small_icon
= LoadImageA(0, (LPCSTR
)IDI_APPLICATION
, IMAGE_ICON
,
2400 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
2403 cls
.cbSize
= sizeof(cls
);
2405 cls
.lpfnWndProc
= DefWindowProcA
;
2409 cls
.hIcon
= LoadIconA(0, (LPCSTR
)IDI_HAND
);
2410 cls
.hIconSm
= small_icon
;
2411 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
2412 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
2413 cls
.lpszMenuName
= NULL
;
2414 cls
.lpszClassName
= "IconWindowClass";
2416 RegisterClassExA(&cls
);
2418 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
2419 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
2422 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2423 ok( res
== 0, "wrong big icon %p/0\n", res
);
2424 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
2425 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
2426 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2427 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
2428 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
2429 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
2430 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2431 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
2433 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2434 ok( res
== 0, "wrong small icon %p/0\n", res
);
2435 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL2
, 0 );
2436 ok( (res
&& res
!= small_icon
&& res
!= icon2
) || broken(!res
), "wrong small2 icon %p\n", res
);
2437 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
2438 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
2439 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2440 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
2441 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL2
, 0 );
2442 ok( res
== icon
|| broken(!res
), "wrong small2 icon after set %p/%p\n", res
, icon
);
2443 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
2444 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
2445 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2446 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
2447 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL2
, 0 );
2448 ok( res
== small_icon
|| broken(!res
), "wrong small2 icon after set %p/%p\n", res
, small_icon
);
2450 /* make sure the big icon hasn't changed */
2451 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2452 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
2454 DestroyWindow( hwnd
);
2457 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2459 if (msg
== WM_NCCALCSIZE
)
2461 RECT
*rect
= (RECT
*)lparam
;
2462 /* first time around increase the rectangle, next time decrease it */
2463 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
2464 else InflateRect( rect
, -10, -10 );
2467 return DefWindowProcA( hwnd
, msg
, wparam
, lparam
);
2470 static void test_SetWindowPos(HWND hwnd
, HWND hwnd2
)
2472 RECT orig_win_rc
, rect
;
2474 HWND hwnd_grandchild
, hwnd_child
, hwnd_child2
;
2479 SetRect(&rect
, 111, 222, 333, 444);
2480 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
2481 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
2482 "wrong window rect %s\n", wine_dbgstr_rect(&rect
));
2484 SetRect(&rect
, 111, 222, 333, 444);
2485 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
2486 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
2487 "wrong window rect %s\n", wine_dbgstr_rect(&rect
));
2489 GetWindowRect(hwnd
, &orig_win_rc
);
2491 old_proc
= SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
2492 ret
= SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
2493 ok(ret
, "Got %d\n", ret
);
2494 GetWindowRect( hwnd
, &rect
);
2495 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
2496 "invalid window rect %s\n", wine_dbgstr_rect(&rect
));
2497 GetClientRect( hwnd
, &rect
);
2498 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2499 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
2500 "invalid client rect %s\n", wine_dbgstr_rect(&rect
));
2502 ret
= SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
2503 ok(ret
, "Got %d\n", ret
);
2504 GetWindowRect( hwnd
, &rect
);
2505 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
2506 "invalid window rect %s\n", wine_dbgstr_rect(&rect
));
2507 GetClientRect( hwnd
, &rect
);
2508 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2509 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
2510 "invalid client rect %s\n", wine_dbgstr_rect(&rect
));
2512 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2513 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2514 ok(ret
, "Got %d\n", ret
);
2515 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, old_proc
);
2517 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
2518 ok(ret
, "Got %d\n", ret
);
2519 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
2520 ok(ret
, "Got %d\n", ret
);
2522 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
2523 ok(ret
, "Got %d\n", ret
);
2524 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
2525 ok(ret
, "Got %d\n", ret
);
2527 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2528 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2529 ok(ret
, "Got %d\n", ret
);
2531 hwnd_desktop
= GetDesktopWindow();
2532 ok(!!hwnd_desktop
, "Failed to get hwnd_desktop window (%d).\n", GetLastError());
2533 hwnd_child
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2534 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2535 hwnd_grandchild
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd_child
);
2536 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2537 hwnd_child2
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2538 ok(!!hwnd_child2
, "Failed to create second child window (%d)\n", GetLastError());
2540 ret
= SetWindowPos(hwnd
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2541 ok(ret
, "Got %d\n", ret
);
2542 check_active_state(hwnd
, hwnd
, hwnd
);
2544 ret
= SetWindowPos(hwnd2
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2545 ok(ret
, "Got %d\n", ret
);
2546 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2548 /* Returns TRUE also for windows that are not siblings */
2549 ret
= SetWindowPos(hwnd_child
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2550 ok(ret
, "Got %d\n", ret
);
2551 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2553 ret
= SetWindowPos(hwnd2
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2554 ok(ret
, "Got %d\n", ret
);
2555 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2557 /* Does not seem to do anything even without passing flags, still returns TRUE */
2558 GetWindowRect(hwnd_child
, &rc1
);
2559 ret
= SetWindowPos(hwnd_child
, hwnd2
, 1, 2, 3, 4, 0);
2560 ok(ret
, "Got %d\n", ret
);
2561 GetWindowRect(hwnd_child
, &rc2
);
2562 ok(EqualRect(&rc1
, &rc2
), "%s != %s\n", wine_dbgstr_rect(&rc1
), wine_dbgstr_rect(&rc2
));
2563 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2565 /* Same thing the other way around. */
2566 GetWindowRect(hwnd2
, &rc1
);
2567 ret
= SetWindowPos(hwnd2
, hwnd_child
, 1, 2, 3, 4, 0);
2568 ok(ret
, "Got %d\n", ret
);
2569 GetWindowRect(hwnd2
, &rc2
);
2570 ok(EqualRect(&rc1
, &rc2
), "%s != %s\n", wine_dbgstr_rect(&rc1
), wine_dbgstr_rect(&rc2
));
2571 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2573 /* .. and with these windows. */
2574 GetWindowRect(hwnd_grandchild
, &rc1
);
2575 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, 0);
2576 ok(ret
, "Got %d\n", ret
);
2577 GetWindowRect(hwnd_grandchild
, &rc2
);
2578 ok(EqualRect(&rc1
, &rc2
), "%s != %s\n", wine_dbgstr_rect(&rc1
), wine_dbgstr_rect(&rc2
));
2579 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2581 /* Add SWP_NOZORDER and it will be properly resized. */
2582 GetWindowRect(hwnd_grandchild
, &rc1
);
2583 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, SWP_NOZORDER
);
2584 ok(ret
, "Got %d\n", ret
);
2585 GetWindowRect(hwnd_grandchild
, &rc2
);
2586 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2587 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2588 "(%d,%d)-(%d,%d) != %s\n", rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6,
2589 wine_dbgstr_rect(&rc2
));
2590 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2592 /* Given a sibling window, the window is properly resized. */
2593 GetWindowRect(hwnd_child
, &rc1
);
2594 ret
= SetWindowPos(hwnd_child
, hwnd_child2
, 1, 2, 3, 4, 0);
2595 ok(ret
, "Got %d\n", ret
);
2596 GetWindowRect(hwnd_child
, &rc2
);
2597 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2598 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2599 "(%d,%d)-(%d,%d) != %s\n", rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6,
2600 wine_dbgstr_rect(&rc2
));
2601 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2603 /* Involving the desktop window changes things. */
2604 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2605 ok(!ret
, "Got %d\n", ret
);
2606 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2608 GetWindowRect(hwnd_child
, &rc1
);
2609 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, 0);
2610 ok(!ret
, "Got %d\n", ret
);
2611 GetWindowRect(hwnd_child
, &rc2
);
2612 ok(EqualRect(&rc1
, &rc2
), "%s != %s\n", wine_dbgstr_rect(&rc1
), wine_dbgstr_rect(&rc2
));
2613 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2615 ret
= SetWindowPos(hwnd_desktop
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2616 ok(!ret
, "Got %d\n", ret
);
2617 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2619 ret
= SetWindowPos(hwnd_desktop
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2620 ok(!ret
, "Got %d\n", ret
);
2621 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2623 ret
= SetWindowPos(hwnd
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2624 ok(!ret
, "Got %d\n", ret
);
2625 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2627 DestroyWindow(hwnd_grandchild
);
2628 DestroyWindow(hwnd_child
);
2629 DestroyWindow(hwnd_child2
);
2631 hwnd_child
= create_tool_window(WS_CHILD
|WS_POPUP
|WS_SYSMENU
, hwnd2
);
2632 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2633 ret
= SetWindowPos(hwnd_child
, NULL
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2634 ok(ret
, "Got %d\n", ret
);
2635 flush_events( TRUE
);
2636 todo_wine
check_active_state(hwnd2
, hwnd2
, hwnd2
);
2637 DestroyWindow(hwnd_child
);
2640 static void test_SetMenu(HWND parent
)
2647 hMenu
= CreateMenu();
2650 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2653 /* fails on (at least) Wine, NT4, XP SP2 */
2654 test_nonclient_area(parent
);
2656 ret
= GetMenu(parent
);
2657 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2658 /* test whether we can destroy a menu assigned to a window */
2659 retok
= DestroyMenu(hMenu
);
2660 ok( retok
, "DestroyMenu error %d\n", GetLastError());
2661 retok
= IsMenu(hMenu
);
2662 ok(!retok
, "menu handle should be not valid after DestroyMenu\n");
2663 ret
= GetMenu(parent
);
2664 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2665 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2666 test_nonclient_area(parent
);
2668 hMenu
= CreateMenu();
2672 ret
= GetMenu(parent
);
2673 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2675 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2676 test_nonclient_area(parent
);
2677 ret
= GetMenu(parent
);
2678 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2680 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2683 /* fails on (at least) Wine, NT4, XP SP2 */
2684 test_nonclient_area(parent
);
2686 ret
= GetMenu(parent
);
2687 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2689 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2690 test_nonclient_area(parent
);
2691 ret
= GetMenu(parent
);
2692 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2695 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
2698 ret
= GetMenu(child
);
2699 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2701 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2702 test_nonclient_area(child
);
2703 ret
= GetMenu(child
);
2704 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2706 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
2707 test_nonclient_area(child
);
2708 ret
= GetMenu(child
);
2709 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2711 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
2712 test_nonclient_area(child
);
2713 ret
= GetMenu(child
);
2714 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2716 style
= GetWindowLongA(child
, GWL_STYLE
);
2717 SetWindowLongA(child
, GWL_STYLE
, style
| WS_POPUP
);
2718 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
2719 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
2720 SetWindowLongA(child
, GWL_STYLE
, style
);
2722 SetWindowLongA(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
2723 ok(!SetMenu(child
, hMenu
), "SetMenu on an overlapped child window should fail\n");
2724 SetWindowLongA(child
, GWL_STYLE
, style
);
2726 DestroyWindow(child
);
2730 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
2732 HWND child
[5], hwnd
;
2737 hwnd
= GetWindow(parent
, GW_CHILD
);
2738 ok(!hwnd
, "have to start without children to perform the test\n");
2740 for (i
= 0; i
< total
; i
++)
2742 if (style
[i
] & DS_CONTROL
)
2744 child
[i
] = CreateWindowExA(0, (LPCSTR
)MAKEINTATOM(32770), "", style
[i
] & ~WS_VISIBLE
,
2745 0,0,0,0, parent
, (HMENU
)i
, 0, NULL
);
2746 if (style
[i
] & WS_VISIBLE
)
2747 ShowWindow(child
[i
], SW_SHOW
);
2749 SetWindowPos(child
[i
], HWND_BOTTOM
, 0,0,10,10, SWP_NOACTIVATE
);
2752 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
2753 parent
, (HMENU
)i
, 0, NULL
);
2754 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
2757 hwnd
= GetWindow(parent
, GW_CHILD
);
2758 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
2759 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
2760 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
2762 for (i
= 0; i
< total
; i
++)
2764 ok(child
[order
[i
]] == hwnd
, "Z order of child #%ld is wrong\n", i
);
2765 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
2768 for (i
= 0; i
< total
; i
++)
2769 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
2772 static void test_children_zorder(HWND parent
)
2774 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
2776 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
2778 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
2779 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
2780 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
2781 const int complex_order_1
[1] = { 0 };
2782 const int complex_order_2
[2] = { 1, 0 };
2783 const int complex_order_3
[3] = { 1, 0, 2 };
2784 const int complex_order_4
[4] = { 1, 0, 2, 3 };
2785 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
2786 const DWORD complex_style_6
[3] = { WS_CHILD
| WS_VISIBLE
,
2787 WS_CHILD
| WS_CLIPSIBLINGS
| DS_CONTROL
| WS_VISIBLE
,
2788 WS_CHILD
| WS_VISIBLE
};
2789 const int complex_order_6
[3] = { 0, 1, 2 };
2791 /* simple WS_CHILD */
2792 test_window_tree(parent
, simple_style
, simple_order
, 5);
2794 /* complex children styles */
2795 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
2796 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
2797 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
2798 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
2799 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
2801 /* another set of complex children styles */
2802 test_window_tree(parent
, complex_style_6
, complex_order_6
, 3);
2805 #define check_z_order(hwnd, next, prev, owner, topmost) \
2806 check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
2809 static void check_z_order_debug(HWND hwnd
, HWND next
, HWND prev
, HWND owner
,
2810 BOOL topmost
, const char *file
, int line
)
2815 test
= GetWindow(hwnd
, GW_HWNDNEXT
);
2816 /* skip foreign windows */
2817 while (test
&& test
!= next
&&
2818 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2819 UlongToHandle(GetWindowLongPtrA(test
, GWLP_HINSTANCE
)) != GetModuleHandleA(NULL
) ||
2820 GetWindow(test
, GW_OWNER
) == next
))
2822 test
= GetWindow(test
, GW_HWNDNEXT
);
2824 ok_(file
, line
)(next
== test
, "%p: expected next %p, got %p\n", hwnd
, next
, test
);
2826 test
= GetWindow(hwnd
, GW_HWNDPREV
);
2827 /* skip foreign windows */
2828 while (test
&& test
!= prev
&&
2829 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2830 UlongToHandle(GetWindowLongPtrA(test
, GWLP_HINSTANCE
)) != GetModuleHandleA(NULL
) ||
2831 GetWindow(test
, GW_OWNER
) == hwnd
))
2833 test
= GetWindow(test
, GW_HWNDPREV
);
2835 ok_(file
, line
)(prev
== test
, "%p: expected prev %p, got %p\n", hwnd
, prev
, test
);
2837 test
= GetWindow(hwnd
, GW_OWNER
);
2838 ok_(file
, line
)(owner
== test
, "%p: expected owner %p, got %p\n", hwnd
, owner
, test
);
2840 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
2841 ok_(file
, line
)(!(ex_style
& WS_EX_TOPMOST
) == !topmost
, "%p: expected %stopmost\n",
2842 hwnd
, topmost
? "" : "NOT ");
2845 static void test_popup_zorder(HWND hwnd_D
, HWND hwnd_E
, DWORD style
)
2847 HWND hwnd_A
, hwnd_B
, hwnd_C
, hwnd_F
;
2849 /* Give current thread foreground state otherwise the tests may fail. */
2850 if (!SetForegroundWindow(hwnd_D
))
2852 skip("SetForegroundWindow not working\n");
2856 SetWindowPos(hwnd_E
, hwnd_D
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2858 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2859 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2861 hwnd_F
= CreateWindowExA(0, "MainWindowClass", "Owner window",
2862 WS_OVERLAPPED
| WS_CAPTION
,
2864 0, 0, GetModuleHandleA(NULL
), NULL
);
2865 check_z_order(hwnd_F
, hwnd_D
, 0, 0, FALSE
);
2867 SetWindowPos(hwnd_F
, hwnd_E
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2868 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2869 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2870 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2872 hwnd_C
= CreateWindowExA(0, "MainWindowClass", NULL
,
2875 hwnd_F
, 0, GetModuleHandleA(NULL
), NULL
);
2876 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2877 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2878 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2879 check_z_order(hwnd_C
, hwnd_D
, 0, hwnd_F
, FALSE
);
2881 hwnd_B
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2884 hwnd_F
, 0, GetModuleHandleA(NULL
), NULL
);
2885 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2886 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2887 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2888 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2889 check_z_order(hwnd_B
, hwnd_C
, 0, hwnd_F
, TRUE
);
2891 hwnd_A
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2894 0, 0, GetModuleHandleA(NULL
), NULL
);
2895 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2896 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2897 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2898 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2899 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2900 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2902 if (winetest_debug
> 1)
2903 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
);
2905 /* move hwnd_F and its popups up */
2906 SetWindowPos(hwnd_F
, HWND_TOP
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2907 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2908 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2909 check_z_order(hwnd_F
, hwnd_D
, hwnd_C
, 0, FALSE
);
2910 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2911 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2912 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2914 /* move hwnd_F and its popups down */
2915 #if 0 /* enable once Wine is fixed to pass this test */
2916 SetWindowPos(hwnd_F
, HWND_BOTTOM
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2917 check_z_order(hwnd_F
, 0, hwnd_C
, 0, FALSE
);
2918 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2919 check_z_order(hwnd_B
, hwnd_C
, hwnd_E
, hwnd_F
, FALSE
);
2920 check_z_order(hwnd_E
, hwnd_B
, hwnd_D
, 0, FALSE
);
2921 check_z_order(hwnd_D
, hwnd_E
, hwnd_A
, 0, FALSE
);
2922 check_z_order(hwnd_A
, hwnd_D
, 0, 0, TRUE
);
2925 /* make hwnd_C owned by a topmost window */
2926 DestroyWindow( hwnd_C
);
2927 hwnd_C
= CreateWindowExA(0, "MainWindowClass", NULL
,
2930 hwnd_A
, 0, GetModuleHandleA(NULL
), NULL
);
2931 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2932 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2933 check_z_order(hwnd_F
, hwnd_D
, hwnd_B
, 0, FALSE
);
2934 check_z_order(hwnd_B
, hwnd_F
, hwnd_A
, hwnd_F
, TRUE
);
2935 check_z_order(hwnd_A
, hwnd_B
, hwnd_C
, 0, TRUE
);
2936 check_z_order(hwnd_C
, hwnd_A
, 0, hwnd_A
, TRUE
);
2938 DestroyWindow(hwnd_A
);
2939 DestroyWindow(hwnd_B
);
2940 DestroyWindow(hwnd_C
);
2941 DestroyWindow(hwnd_F
);
2944 static void test_vis_rgn( HWND hwnd
)
2946 RECT win_rect
, rgn_rect
;
2947 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
2950 ShowWindow(hwnd
,SW_SHOW
);
2951 hdc
= GetDC( hwnd
);
2952 ok( GetRandomRgn( hdc
, hrgn
, SYSRGN
) != 0, "GetRandomRgn failed\n" );
2953 GetWindowRect( hwnd
, &win_rect
);
2954 GetRgnBox( hrgn
, &rgn_rect
);
2955 ok( win_rect
.left
<= rgn_rect
.left
&&
2956 win_rect
.top
<= rgn_rect
.top
&&
2957 win_rect
.right
>= rgn_rect
.right
&&
2958 win_rect
.bottom
>= rgn_rect
.bottom
,
2959 "rgn %s not inside win %s\n", wine_dbgstr_rect(&rgn_rect
), wine_dbgstr_rect(&win_rect
));
2960 ReleaseDC( hwnd
, hdc
);
2963 static LRESULT WINAPI
set_focus_on_activate_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
2965 if (msg
== WM_ACTIVATE
&& LOWORD(wp
) == WA_ACTIVE
)
2967 HWND child
= GetWindow(hwnd
, GW_CHILD
);
2968 ok(child
!= 0, "couldn't find child window\n");
2970 ok(GetFocus() == child
, "Focus should be on child %p\n", child
);
2973 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
2976 static void test_SetFocus(HWND hwnd
)
2978 HWND child
, child2
, ret
;
2979 WNDPROC old_wnd_proc
;
2981 /* check if we can set focus to non-visible windows */
2983 ShowWindow(hwnd
, SW_SHOW
);
2986 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2987 ok( GetWindowLongA(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
2988 ShowWindow(hwnd
, SW_HIDE
);
2991 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
2992 ok( !(GetWindowLongA(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
2993 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2996 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
2997 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2998 ShowWindow(child
, SW_SHOW
);
2999 ok( GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
3000 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
3001 ShowWindow(child
, SW_HIDE
);
3002 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
3003 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
3004 ShowWindow(child
, SW_SHOW
);
3005 child2
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, child
, 0, 0, NULL
);
3007 ShowWindow(child2
, SW_SHOW
);
3009 ShowWindow(child
, SW_HIDE
);
3010 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
3011 ok( GetFocus() == child2
, "Focus should be on %p, not %p\n", child2
, GetFocus() );
3012 ShowWindow(child
, SW_SHOW
);
3014 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
3015 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
3016 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
3018 ShowWindow(child
, SW_HIDE
);
3020 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
3021 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
3022 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
3023 ShowWindow(child
, SW_HIDE
);
3024 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
3026 ShowWindow(hwnd
, SW_SHOW
);
3027 ShowWindow(child
, SW_SHOW
);
3029 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
3030 SetLastError(0xdeadbeef);
3031 EnableWindow(hwnd
, FALSE
);
3032 ok(GetLastError() == 0xdeadbeef, "got error %u in EnableWindow call\n", GetLastError());
3033 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
3034 EnableWindow(hwnd
, TRUE
);
3036 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3037 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
3038 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3040 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
3041 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
3042 ShowWindow(hwnd
, SW_RESTORE
);
3043 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3044 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
3045 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
3046 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3047 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
3048 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
3049 old_wnd_proc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)set_focus_on_activate_proc
);
3050 ShowWindow(hwnd
, SW_RESTORE
);
3051 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3053 ok( GetFocus() == child
, "Focus should be on child %p, not %p\n", child
, GetFocus() );
3054 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)old_wnd_proc
);
3057 SetParent( child
, GetDesktopWindow());
3058 SetParent( child2
, child
);
3059 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3060 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
3061 ret
= SetFocus( child2
);
3062 ok( ret
== 0, "SetFocus %p should fail\n", child2
);
3063 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3064 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
3065 ret
= SetFocus( child
);
3066 ok( ret
== 0, "SetFocus %p should fail\n", child
);
3067 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3068 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
3069 SetWindowLongW( child
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
3071 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
3072 ok( GetFocus() == child2
, "Focus should be on child2 %p\n", child2
);
3074 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
3075 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
3077 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
3078 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
3080 DestroyWindow( child2
);
3081 DestroyWindow( child
);
3084 static void test_SetActiveWindow(HWND hwnd
)
3088 flush_events( TRUE
);
3089 ShowWindow(hwnd
, SW_HIDE
);
3092 check_wnd_state(0, 0, 0, 0);
3094 ShowWindow(hwnd
, SW_SHOW
);
3095 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3097 ret
= SetActiveWindow(0);
3098 ok(ret
== hwnd
, "SetActiveWindow returned %p instead of %p\n", ret
, hwnd
);
3099 if (!GetActiveWindow()) /* doesn't always work on vista */
3101 check_wnd_state(0, 0, 0, 0);
3102 ret
= SetActiveWindow(hwnd
);
3103 ok(ret
== 0, "SetActiveWindow returned %p instead of 0\n", ret
);
3105 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3107 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
3108 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3110 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
3111 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3113 ShowWindow(hwnd
, SW_HIDE
);
3114 check_wnd_state(0, 0, 0, 0);
3116 /* Invisible window. */
3117 SetActiveWindow(hwnd
);
3118 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3120 ShowWindow(hwnd
, SW_SHOW
);
3121 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3123 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
3124 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3126 SetActiveWindow(hwnd
);
3127 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3129 DestroyWindow(hwnd2
);
3130 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3132 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
3133 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3135 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
3136 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3138 DestroyWindow(hwnd2
);
3139 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3141 /* try to activate the desktop */
3142 SetLastError(0xdeadbeef);
3143 ret
= SetActiveWindow(GetDesktopWindow());
3144 ok(ret
== NULL
, "expected NULL, got %p\n", ret
);
3146 ok(GetLastError() == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", GetLastError());
3147 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3149 /* activating a child should activate the parent */
3150 hwnd2
= CreateWindowExA(0, "MainWindowClass", "Child window", WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, GetModuleHandleA(NULL
), NULL
);
3151 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3152 ret
= SetActiveWindow(hwnd2
);
3153 ok(ret
== hwnd
, "expected %p, got %p\n", hwnd
, ret
);
3154 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3155 ret
= SetActiveWindow(0);
3156 ok(ret
== hwnd
, "expected %p, got %p\n", hwnd
, ret
);
3157 if (!GetActiveWindow())
3159 ret
= SetActiveWindow(hwnd2
);
3160 ok(ret
== NULL
, "expected NULL, got %p\n", ret
);
3162 check_active_state(hwnd
, hwnd
, hwnd
);
3164 DestroyWindow(hwnd2
);
3167 struct create_window_thread_params
3170 HANDLE window_created
;
3171 HANDLE test_finished
;
3174 static DWORD WINAPI
create_window_thread(void *param
)
3176 struct create_window_thread_params
*p
= param
;
3180 p
->window
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
3182 ret
= SetEvent(p
->window_created
);
3183 ok(ret
, "SetEvent failed, last error %#x.\n", GetLastError());
3185 res
= WaitForSingleObject(p
->test_finished
, INFINITE
);
3186 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
3188 DestroyWindow(p
->window
);
3192 static void test_SetForegroundWindow(HWND hwnd
)
3194 struct create_window_thread_params thread_params
;
3202 flush_events( TRUE
);
3203 ShowWindow(hwnd
, SW_HIDE
);
3206 check_wnd_state(0, 0, 0, 0);
3208 ShowWindow(hwnd
, SW_SHOW
);
3209 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3211 hwnd2
= SetActiveWindow(0);
3212 ok(hwnd2
== hwnd
, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2
, hwnd
);
3213 if (GetActiveWindow() == hwnd
) /* doesn't always work on vista */
3214 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3216 check_wnd_state(0, 0, 0, 0);
3218 ret
= SetForegroundWindow(hwnd
);
3221 skip( "SetForegroundWindow not working\n" );
3224 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3226 SetLastError(0xdeadbeef);
3227 ret
= SetForegroundWindow(0);
3228 ok(!ret
, "SetForegroundWindow returned TRUE instead of FALSE\n");
3229 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
,
3230 "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
3231 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3233 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
3234 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3236 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
3237 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3239 hwnd2
= GetForegroundWindow();
3240 ok(hwnd2
== hwnd
, "Wrong foreground window %p\n", hwnd2
);
3241 ret
= SetForegroundWindow( GetDesktopWindow() );
3242 ok(ret
, "SetForegroundWindow(desktop) error: %d\n", GetLastError());
3243 hwnd2
= GetForegroundWindow();
3244 ok(hwnd2
!= hwnd
, "Wrong foreground window %p\n", hwnd2
);
3246 ShowWindow(hwnd
, SW_HIDE
);
3247 check_wnd_state(0, 0, 0, 0);
3249 /* Invisible window. */
3250 ret
= SetForegroundWindow(hwnd
);
3251 ok(ret
, "SetForegroundWindow returned FALSE instead of TRUE\n");
3252 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3254 ShowWindow(hwnd
, SW_SHOW
);
3255 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3257 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
3258 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3260 DestroyWindow(hwnd2
);
3261 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3263 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
3264 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3266 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
3267 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3269 DestroyWindow(hwnd2
);
3270 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3272 hwnd2
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
3273 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3275 thread_params
.window_created
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
3276 ok(!!thread_params
.window_created
, "CreateEvent failed, last error %#x.\n", GetLastError());
3277 thread_params
.test_finished
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
3278 ok(!!thread_params
.test_finished
, "CreateEvent failed, last error %#x.\n", GetLastError());
3279 thread
= CreateThread(NULL
, 0, create_window_thread
, &thread_params
, 0, &tid
);
3280 ok(!!thread
, "Failed to create thread, last error %#x.\n", GetLastError());
3281 res
= WaitForSingleObject(thread_params
.window_created
, INFINITE
);
3282 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
3283 check_wnd_state(hwnd2
, thread_params
.window
, hwnd2
, 0);
3285 SetForegroundWindow(hwnd2
);
3286 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3288 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
3289 if (0) check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3290 todo_wine
ok(GetActiveWindow() == hwnd2
, "Expected active window %p, got %p.\n", hwnd2
, GetActiveWindow());
3291 todo_wine
ok(GetFocus() == hwnd2
, "Expected focus window %p, got %p.\n", hwnd2
, GetFocus());
3293 SetForegroundWindow(hwnd
);
3294 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3295 style
= GetWindowLongA(hwnd2
, GWL_STYLE
) | WS_CHILD
;
3296 ok(SetWindowLongA(hwnd2
, GWL_STYLE
, style
), "SetWindowLong failed\n");
3297 ok(SetForegroundWindow(hwnd2
), "SetForegroundWindow failed\n");
3298 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
3300 SetForegroundWindow(hwnd
);
3301 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3302 ok(SetWindowLongA(hwnd2
, GWL_STYLE
, style
& (~WS_POPUP
)), "SetWindowLong failed\n");
3303 ok(!SetForegroundWindow(hwnd2
), "SetForegroundWindow failed\n");
3304 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3306 SetEvent(thread_params
.test_finished
);
3307 WaitForSingleObject(thread
, INFINITE
);
3308 CloseHandle(thread_params
.test_finished
);
3309 CloseHandle(thread_params
.window_created
);
3310 CloseHandle(thread
);
3311 DestroyWindow(hwnd2
);
3314 static WNDPROC old_button_proc
;
3316 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3321 key_state
= GetKeyState(VK_LBUTTON
);
3322 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
3324 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
3326 if (msg
== WM_LBUTTONDOWN
)
3330 check_wnd_state(button
, button
, button
, button
);
3332 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3335 check_wnd_state(button
, button
, button
, button
);
3337 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
3339 check_wnd_state(button
, button
, button
, button
);
3341 DestroyWindow(hwnd
);
3343 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3346 check_wnd_state(button
, button
, button
, button
);
3348 /* button wnd proc should release capture on WM_KILLFOCUS if it does
3349 * match internal button state.
3351 SendMessageA(button
, WM_KILLFOCUS
, 0, 0);
3352 check_wnd_state(button
, button
, button
, 0);
3354 ShowWindow(hwnd
, SW_SHOW
);
3355 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3357 capture
= SetCapture(hwnd
);
3358 ok(capture
== 0, "SetCapture() = %p\n", capture
);
3360 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
3362 DestroyWindow(hwnd
);
3364 check_wnd_state(button
, 0, button
, 0);
3370 static void test_capture_1(void)
3372 HWND button
, capture
;
3374 capture
= GetCapture();
3375 ok(capture
== 0, "GetCapture() = %p\n", capture
);
3377 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3380 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
3382 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
3384 capture
= SetCapture(button
);
3385 ok(capture
== 0, "SetCapture() = %p\n", capture
);
3386 check_wnd_state(button
, 0, button
, button
);
3388 DestroyWindow(button
);
3389 /* old active window test depends on previously executed window
3390 * activation tests, and fails under NT4.
3391 check_wnd_state(oldActive, 0, oldFocus, 0);*/
3394 static void test_capture_2(void)
3396 HWND button
, hwnd
, capture
, oldFocus
, oldActive
;
3398 oldFocus
= GetFocus();
3399 oldActive
= GetActiveWindow();
3400 check_wnd_state(oldActive
, 0, oldFocus
, 0);
3402 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3405 check_wnd_state(button
, button
, button
, 0);
3407 capture
= SetCapture(button
);
3408 ok(capture
== 0, "SetCapture() = %p\n", capture
);
3410 check_wnd_state(button
, button
, button
, button
);
3412 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
3413 * internal button state.
3415 SendMessageA(button
, WM_KILLFOCUS
, 0, 0);
3416 check_wnd_state(button
, button
, button
, button
);
3418 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3421 check_wnd_state(button
, button
, button
, button
);
3423 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
3425 check_wnd_state(button
, button
, button
, button
);
3427 DestroyWindow(hwnd
);
3429 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3432 check_wnd_state(button
, button
, button
, button
);
3434 ShowWindow(hwnd
, SW_SHOW
);
3436 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
3438 capture
= SetCapture(hwnd
);
3439 ok(capture
== button
, "SetCapture() = %p\n", capture
);
3441 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
3443 DestroyWindow(hwnd
);
3444 check_wnd_state(button
, button
, button
, 0);
3446 DestroyWindow(button
);
3447 check_wnd_state(oldActive
, 0, oldFocus
, 0);
3450 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
3454 ShowWindow(hwnd1
, SW_HIDE
);
3455 ShowWindow(hwnd2
, SW_HIDE
);
3457 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
3458 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
3461 check_wnd_state(0, 0, 0, hwnd1
);
3464 check_wnd_state(0, 0, 0, hwnd2
);
3466 ShowWindow(hwnd1
, SW_SHOW
);
3467 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
3469 ret
= ReleaseCapture();
3470 ok (ret
, "releasecapture did not return TRUE.\n");
3471 ret
= ReleaseCapture();
3472 ok (ret
, "releasecapture did not return TRUE after second try.\n");
3475 static LRESULT CALLBACK
test_capture_4_proc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3478 HWND cap_wnd
, cap_wnd2
, set_cap_wnd
;
3482 case WM_CAPTURECHANGED
:
3484 /* now try to release capture from menu. this should fail */
3485 if (pGetGUIThreadInfo
)
3487 memset(>i
, 0, sizeof(GUITHREADINFO
));
3488 gti
.cbSize
= sizeof(GUITHREADINFO
);
3489 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
3490 ok(status
, "GetGUIThreadInfo() failed!\n");
3491 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
3493 cap_wnd
= GetCapture();
3495 ok(cap_wnd
== (HWND
)lParam
, "capture window %p does not match lparam %lx\n", cap_wnd
, lParam
);
3496 todo_wine
ok(cap_wnd
== hWnd
, "capture window %p does not match hwnd %p\n", cap_wnd
, hWnd
);
3498 /* check that re-setting the capture for the menu fails */
3499 set_cap_wnd
= SetCapture(cap_wnd
);
3500 ok(!set_cap_wnd
, "SetCapture should have failed!\n");
3503 DestroyWindow(hWnd
);
3507 /* check that SetCapture fails for another window and that it does not touch the error code */
3508 set_cap_wnd
= SetCapture(hWnd
);
3509 ok(!set_cap_wnd
, "SetCapture should have failed!\n");
3511 /* check that ReleaseCapture fails and does not touch the error code */
3512 status
= ReleaseCapture();
3513 ok(!status
, "ReleaseCapture should have failed!\n");
3515 /* check that thread info did not change */
3516 if (pGetGUIThreadInfo
)
3518 memset(>i
, 0, sizeof(GUITHREADINFO
));
3519 gti
.cbSize
= sizeof(GUITHREADINFO
);
3520 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
3521 ok(status
, "GetGUIThreadInfo() failed!\n");
3522 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
3525 /* verify that no capture change took place */
3526 cap_wnd2
= GetCapture();
3527 ok(cap_wnd2
== cap_wnd
, "Capture changed!\n");
3529 /* we are done. kill the window */
3530 DestroyWindow(hWnd
);
3534 return( DefWindowProcA( hWnd
, msg
, wParam
, lParam
) );
3539 /* Test that no-one can mess around with the current capture while a menu is open */
3540 static void test_capture_4(void)
3546 HINSTANCE hInstance
= GetModuleHandleA( NULL
);
3549 if (!pGetGUIThreadInfo
)
3551 win_skip("GetGUIThreadInfo is not available\n");
3554 wclass
.lpszClassName
= "TestCapture4Class";
3555 wclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
3556 wclass
.lpfnWndProc
= test_capture_4_proc
;
3557 wclass
.hInstance
= hInstance
;
3558 wclass
.hIcon
= LoadIconA( 0, (LPCSTR
)IDI_APPLICATION
);
3559 wclass
.hCursor
= LoadCursorA( 0, (LPCSTR
)IDC_ARROW
);
3560 wclass
.hbrBackground
= (HBRUSH
)( COLOR_WINDOW
+ 1 );
3561 wclass
.lpszMenuName
= 0;
3562 wclass
.cbClsExtra
= 0;
3563 wclass
.cbWndExtra
= 0;
3564 aclass
= RegisterClassA( &wclass
);
3565 ok( aclass
, "RegisterClassA failed with error %d\n", GetLastError());
3566 hwnd
= CreateWindowA( wclass
.lpszClassName
, "MenuTest",
3567 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0,
3568 400, 200, NULL
, NULL
, hInstance
, NULL
);
3569 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
3571 hmenu
= CreatePopupMenu();
3573 ret
= AppendMenuA( hmenu
, MF_STRING
, 1, "winetest2");
3574 ok( ret
, "AppendMenuA has failed!\n");
3576 /* set main window to have initial capture */
3579 /* create popup (it will self-destruct) */
3580 ret
= TrackPopupMenu(hmenu
, TPM_RETURNCMD
, 100, 100, 0, hwnd
, NULL
);
3581 ok( ret
== 0, "TrackPopupMenu returned %d expected zero\n", ret
);
3585 DestroyWindow(hwnd
);
3588 /* PeekMessage wrapper that ignores the messages we don't care about */
3589 static BOOL
peek_message( MSG
*msg
)
3594 ret
= PeekMessageA(msg
, 0, 0, 0, PM_REMOVE
);
3595 } while (ret
&& ignore_message(msg
->message
));
3599 static void test_keyboard_input(HWND hwnd
)
3604 flush_events( TRUE
);
3605 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_SHOWWINDOW
);
3607 flush_events( TRUE
);
3609 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
3612 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3614 flush_events( TRUE
);
3616 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3617 ret
= peek_message(&msg
);
3618 ok( ret
, "no message available\n");
3619 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3620 ret
= peek_message(&msg
);
3621 ok( !ret
, "message %04x available\n", msg
.message
);
3623 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3625 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3626 ret
= peek_message(&msg
);
3627 ok(ret
, "no message available\n");
3628 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3629 ret
= peek_message(&msg
);
3630 ok( !ret
, "message %04x available\n", msg
.message
);
3632 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3634 keybd_event(VK_SPACE
, 0, 0, 0);
3635 if (!peek_message(&msg
))
3637 skip( "keybd_event didn't work, skipping keyboard test\n" );
3640 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3641 ret
= peek_message(&msg
);
3642 ok( !ret
, "message %04x available\n", msg
.message
);
3645 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3647 flush_events( TRUE
);
3649 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3650 ret
= peek_message(&msg
);
3651 ok(ret
, "no message available\n");
3652 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3653 ret
= peek_message(&msg
);
3654 ok( !ret
, "message %04x available\n", msg
.message
);
3656 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3658 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3659 ret
= peek_message(&msg
);
3660 ok(ret
, "no message available\n");
3661 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3662 ret
= peek_message(&msg
);
3663 ok( !ret
, "message %04x available\n", msg
.message
);
3665 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3667 keybd_event(VK_SPACE
, 0, 0, 0);
3668 ret
= peek_message(&msg
);
3669 ok(ret
, "no message available\n");
3670 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3671 ret
= peek_message(&msg
);
3672 ok( !ret
, "message %04x available\n", msg
.message
);
3675 static BOOL
wait_for_message( MSG
*msg
)
3681 ret
= peek_message(msg
);
3684 if (msg
->message
== WM_PAINT
) DispatchMessageA(msg
);
3687 else if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
3689 if (!ret
) msg
->message
= 0;
3693 static void test_mouse_input(HWND hwnd
)
3698 HWND popup
, child
= NULL
;
3703 ShowWindow(hwnd
, SW_SHOWNORMAL
);
3705 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3707 GetWindowRect(hwnd
, &rc
);
3709 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
3710 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
3713 ShowWindow(popup
, SW_SHOW
);
3714 UpdateWindow(popup
);
3715 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3717 GetWindowRect(popup
, &rc
);
3719 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
3720 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
3724 if (x
!= pt
.x
|| y
!= pt
.y
)
3726 skip( "failed to set mouse position, skipping mouse input tests\n" );
3730 flush_events( TRUE
);
3732 /* Check that setting the same position may generate WM_MOUSEMOVE */
3735 ret
= peek_message(&msg
);
3738 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n",
3739 msg
.hwnd
, msg
.message
);
3740 ok(msg
.pt
.x
== x
&& msg
.pt
.y
== y
, "wrong message coords (%d,%d)/(%d,%d)\n",
3741 x
, y
, msg
.pt
.x
, msg
.pt
.y
);
3744 /* force the system to update its internal queue mouse position,
3745 * otherwise it won't generate relative mouse movements below.
3747 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3748 flush_events( TRUE
);
3751 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3752 flush_events( FALSE
);
3753 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
3754 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
3756 if (ignore_message(msg
.message
)) continue;
3757 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
,
3758 "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3759 DispatchMessageA(&msg
);
3761 ret
= peek_message(&msg
);
3762 ok( !ret
, "message %04x available\n", msg
.message
);
3764 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3765 ShowWindow(popup
, SW_HIDE
);
3766 ret
= wait_for_message( &msg
);
3768 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3769 flush_events( TRUE
);
3771 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3772 ShowWindow(hwnd
, SW_HIDE
);
3773 ret
= wait_for_message( &msg
);
3774 ok( !ret
, "message %04x available\n", msg
.message
);
3775 flush_events( TRUE
);
3777 /* test mouse clicks */
3779 ShowWindow(hwnd
, SW_SHOW
);
3780 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3781 flush_events( TRUE
);
3782 ShowWindow(popup
, SW_SHOW
);
3783 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3784 flush_events( TRUE
);
3786 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3787 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3788 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3789 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3791 ret
= wait_for_message( &msg
);
3794 skip( "simulating mouse click doesn't work, skipping mouse button tests\n" );
3797 if (msg
.message
== WM_MOUSEMOVE
) /* win2k has an extra WM_MOUSEMOVE here */
3799 ret
= wait_for_message( &msg
);
3800 ok(ret
, "no message available\n");
3803 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3804 msg
.hwnd
, popup
, msg
.message
);
3806 ret
= wait_for_message( &msg
);
3807 ok(ret
, "no message available\n");
3808 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3809 msg
.hwnd
, popup
, msg
.message
);
3811 ret
= wait_for_message( &msg
);
3812 ok(ret
, "no message available\n");
3813 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p/%p message %04x\n",
3814 msg
.hwnd
, popup
, msg
.message
);
3816 ret
= wait_for_message( &msg
);
3817 ok(ret
, "no message available\n");
3818 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3819 msg
.hwnd
, popup
, msg
.message
);
3821 ret
= peek_message(&msg
);
3822 ok(!ret
, "message %04x available\n", msg
.message
);
3824 ShowWindow(popup
, SW_HIDE
);
3825 flush_events( TRUE
);
3827 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3828 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3829 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3830 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3832 ret
= wait_for_message( &msg
);
3833 ok(ret
, "no message available\n");
3834 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3835 msg
.hwnd
, hwnd
, msg
.message
);
3836 ret
= wait_for_message( &msg
);
3837 ok(ret
, "no message available\n");
3838 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3839 msg
.hwnd
, hwnd
, msg
.message
);
3841 test_lbuttondown_flag
= TRUE
;
3842 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
3843 test_lbuttondown_flag
= FALSE
;
3845 ret
= wait_for_message( &msg
);
3846 ok(ret
, "no message available\n");
3847 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3848 msg
.hwnd
, popup
, msg
.message
);
3849 ok(peek_message(&msg
), "no message available\n");
3850 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3851 msg
.hwnd
, popup
, msg
.message
);
3852 ok(peek_message(&msg
), "no message available\n");
3854 /* Test WM_MOUSEACTIVATE */
3855 #define TEST_MOUSEACTIVATE(A,B) \
3856 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
3857 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
3859 TEST_MOUSEACTIVATE(HTERROR
,MA_ACTIVATE
);
3860 TEST_MOUSEACTIVATE(HTTRANSPARENT
,MA_ACTIVATE
);
3861 TEST_MOUSEACTIVATE(HTNOWHERE
,MA_ACTIVATE
);
3862 TEST_MOUSEACTIVATE(HTCLIENT
,MA_ACTIVATE
);
3863 TEST_MOUSEACTIVATE(HTCAPTION
,MA_ACTIVATE
);
3864 TEST_MOUSEACTIVATE(HTSYSMENU
,MA_ACTIVATE
);
3865 TEST_MOUSEACTIVATE(HTSIZE
,MA_ACTIVATE
);
3866 TEST_MOUSEACTIVATE(HTMENU
,MA_ACTIVATE
);
3867 TEST_MOUSEACTIVATE(HTHSCROLL
,MA_ACTIVATE
);
3868 TEST_MOUSEACTIVATE(HTVSCROLL
,MA_ACTIVATE
);
3869 TEST_MOUSEACTIVATE(HTMINBUTTON
,MA_ACTIVATE
);
3870 TEST_MOUSEACTIVATE(HTMAXBUTTON
,MA_ACTIVATE
);
3871 TEST_MOUSEACTIVATE(HTLEFT
,MA_ACTIVATE
);
3872 TEST_MOUSEACTIVATE(HTRIGHT
,MA_ACTIVATE
);
3873 TEST_MOUSEACTIVATE(HTTOP
,MA_ACTIVATE
);
3874 TEST_MOUSEACTIVATE(HTTOPLEFT
,MA_ACTIVATE
);
3875 TEST_MOUSEACTIVATE(HTTOPRIGHT
,MA_ACTIVATE
);
3876 TEST_MOUSEACTIVATE(HTBOTTOM
,MA_ACTIVATE
);
3877 TEST_MOUSEACTIVATE(HTBOTTOMLEFT
,MA_ACTIVATE
);
3878 TEST_MOUSEACTIVATE(HTBOTTOMRIGHT
,MA_ACTIVATE
);
3879 TEST_MOUSEACTIVATE(HTBORDER
,MA_ACTIVATE
);
3880 TEST_MOUSEACTIVATE(HTOBJECT
,MA_ACTIVATE
);
3881 TEST_MOUSEACTIVATE(HTCLOSE
,MA_ACTIVATE
);
3882 TEST_MOUSEACTIVATE(HTHELP
,MA_ACTIVATE
);
3884 ShowWindow(popup
, SW_HIDE
);
3886 /* Test sending double click to the non-client area, while capturing the window after
3887 the first click has been processed. Use a child window to ensure that Wine's graphics
3888 driver isn't managing the non-client area. */
3890 GetWindowRect(hwnd
, &rc
);
3891 child
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_VISIBLE
,
3892 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
3894 GetWindowRect(child
, &rc
);
3896 UpdateWindow(child
);
3897 SetCursorPos( rc
.left
+ 5, rc
.top
+ 5 );
3898 flush_events( TRUE
);
3900 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3901 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3902 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3903 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3905 ret
= wait_for_message( &msg
);
3906 ok(ret
, "no message available\n");
3908 ok(msg
.hwnd
== child
&& msg
.message
== WM_NCMOUSEMOVE
, "hwnd %p/%p message %04x\n",
3909 msg
.hwnd
, child
, msg
.message
);
3911 if (msg
.message
== WM_NCMOUSEMOVE
)
3912 ret
= wait_for_message( &msg
);
3913 ok(ret
, "no message available\n");
3914 ok(msg
.hwnd
== child
&& msg
.message
== WM_NCLBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3915 msg
.hwnd
, child
, msg
.message
);
3916 ok(msg
.wParam
== HTSYSMENU
, "wparam %ld\n", msg
.wParam
);
3918 ret
= wait_for_message( &msg
);
3919 ok(ret
, "no message available\n");
3920 ok(msg
.hwnd
== child
&& msg
.message
== WM_NCLBUTTONUP
, "hwnd %p/%p message %04x\n",
3921 msg
.hwnd
, child
, msg
.message
);
3923 SetCapture( child
);
3925 ret
= wait_for_message( &msg
);
3926 ok(ret
, "no message available\n");
3927 ok(msg
.hwnd
== child
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p/%p message %04x\n",
3928 msg
.hwnd
, child
, msg
.message
);
3929 ok(msg
.wParam
== MK_LBUTTON
, "wparam %ld\n", msg
.wParam
);
3931 ret
= wait_for_message( &msg
);
3932 ok(ret
, "no message available\n");
3934 ok(msg
.hwnd
== child
&& (msg
.message
== WM_NCMOUSELEAVE
|| broken(msg
.message
== WM_LBUTTONUP
)),
3935 "hwnd %p/%p message %04x\n", msg
.hwnd
, child
, msg
.message
);
3937 if (msg
.message
== WM_NCMOUSELEAVE
)
3938 ret
= wait_for_message( &msg
);
3939 ok(ret
, "no message available\n");
3940 ok(msg
.hwnd
== child
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3941 msg
.hwnd
, child
, msg
.message
);
3943 ret
= peek_message(&msg
);
3944 ok(!ret
, "message %04x available\n", msg
.message
);
3947 flush_events( TRUE
);
3949 if (child
) DestroyWindow(child
);
3950 DestroyWindow(popup
);
3952 SetWindowPos(hwnd
, HWND_NOTOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3955 static void test_validatergn(HWND hwnd
)
3961 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
3962 ShowWindow(hwnd
, SW_SHOW
);
3963 UpdateWindow( hwnd
);
3964 /* test that ValidateRect validates children*/
3965 InvalidateRect( child
, NULL
, 1);
3966 GetWindowRect( child
, &rc
);
3967 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3968 ret
= GetUpdateRect( child
, &rc2
, 0);
3969 ok( ret
== 1, "Expected GetUpdateRect to return non-zero, got %d\n", ret
);
3970 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
3971 "Update rectangle is empty!\n");
3972 ValidateRect( hwnd
, &rc
);
3973 ret
= GetUpdateRect( child
, &rc2
, 0);
3974 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3975 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3976 "Update rectangle %s is not empty!\n", wine_dbgstr_rect(&rc2
));
3978 /* now test ValidateRgn */
3979 InvalidateRect( child
, NULL
, 1);
3980 GetWindowRect( child
, &rc
);
3981 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3982 rgn
= CreateRectRgnIndirect( &rc
);
3983 ValidateRgn( hwnd
, rgn
);
3984 ret
= GetUpdateRect( child
, &rc2
, 0);
3985 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3986 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3987 "Update rectangle %s is not empty!\n", wine_dbgstr_rect(&rc2
));
3990 DestroyWindow( child
);
3993 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
3996 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
3997 GetWindowRect( hwnd
, prc
);
3999 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
4000 if (winetest_debug
> 1)
4001 trace("window rect is %s, nccalc rect is %s\n", wine_dbgstr_rect(&rc
), wine_dbgstr_rect(prc
));
4004 static void test_nccalcscroll(HWND parent
)
4007 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
4008 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
4009 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
4010 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
4011 10, 10, 200, 200, parent
, 0, 0, NULL
);
4012 ShowWindow( parent
, SW_SHOW
);
4013 UpdateWindow( parent
);
4015 /* test window too low for a horizontal scroll bar */
4016 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
4017 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %s\n", sbheight
,
4018 wine_dbgstr_rect(&rc1
));
4020 /* test window just high enough for a horizontal scroll bar */
4021 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
4022 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be 1 size is %s\n", wine_dbgstr_rect(&rc1
));
4024 /* test window too narrow for a vertical scroll bar */
4025 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
4026 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %s\n", sbwidth
- 1,
4027 wine_dbgstr_rect(&rc1
));
4029 /* test window just wide enough for a vertical scroll bar */
4030 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
4031 ok( rc1
.right
- rc1
.left
== 0, "Width should be 0 size is %s\n", wine_dbgstr_rect(&rc1
));
4033 /* same test, but with client edge: not enough width */
4034 SetWindowLongA( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLongA( hwnd
, GWL_EXSTYLE
));
4035 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
4036 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
4037 "Width should be %d size is %s\n", sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
4038 wine_dbgstr_rect(&rc1
));
4040 DestroyWindow( hwnd
);
4043 static void test_SetParent(void)
4045 HWND desktop
= GetDesktopWindow();
4047 HWND ret
, parent
, child1
, child2
, child3
, child4
, sibling
, popup
;
4050 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
4051 100, 100, 200, 200, 0, 0, 0, NULL
);
4052 assert(parent
!= 0);
4053 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
4054 0, 0, 50, 50, parent
, 0, 0, NULL
);
4055 assert(child1
!= 0);
4056 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
4057 0, 0, 50, 50, child1
, 0, 0, NULL
);
4058 assert(child2
!= 0);
4059 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
4060 0, 0, 50, 50, child2
, 0, 0, NULL
);
4061 assert(child3
!= 0);
4062 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
4063 0, 0, 50, 50, child3
, 0, 0, NULL
);
4064 assert(child4
!= 0);
4066 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
4067 parent
, child1
, child2
, child3
, child4
);
4069 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
4070 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
4071 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
4072 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
4073 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
4075 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
4076 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
4077 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
4078 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
4079 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
4081 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
4082 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
4083 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
4084 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
4085 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
4086 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
4087 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
4088 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
4089 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
4091 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
4092 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
4093 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
4094 ret
= SetParent(parent
, child2
);
4095 todo_wine
ok( !ret
|| broken( ret
!= 0 ), "SetParent should fail\n");
4096 if (ret
) /* nt4, win2k */
4098 ret
= SetParent(parent
, child3
);
4099 ok(ret
!= 0, "SetParent should not fail\n");
4100 ret
= SetParent(child2
, parent
);
4101 ok(!ret
, "SetParent should fail\n");
4102 ret
= SetParent(parent
, child4
);
4103 ok(ret
!= 0, "SetParent should not fail\n");
4104 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
4105 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
4106 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
4107 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
4108 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
4112 ret
= SetParent(parent
, child3
);
4113 ok(ret
!= 0, "SetParent should not fail\n");
4114 ret
= SetParent(child2
, parent
);
4115 ok(!ret
, "SetParent should fail\n");
4116 ret
= SetParent(parent
, child4
);
4117 ok(!ret
, "SetParent should fail\n");
4118 check_parents(parent
, child3
, child3
, 0, 0, child2
, parent
);
4119 check_parents(child1
, parent
, parent
, parent
, 0, child2
, parent
);
4120 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
4121 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
4122 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
4125 hMenu
= CreateMenu();
4126 sibling
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
4127 100, 100, 200, 200, 0, hMenu
, 0, NULL
);
4128 assert(sibling
!= 0);
4130 ok(SetParent(sibling
, parent
) != 0, "SetParent should not fail\n");
4131 ok(GetMenu(sibling
) == hMenu
, "SetParent should not remove menu\n");
4133 ok(SetParent(parent
, desktop
) != 0, "SetParent should not fail\n");
4134 ok(SetParent(child4
, child3
) != 0, "SetParent should not fail\n");
4135 ok(SetParent(child3
, child2
) != 0, "SetParent should not fail\n");
4136 ok(SetParent(child2
, child1
) != 0, "SetParent should not fail\n");
4137 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
4138 SetWindowLongW(child4
, GWL_STYLE
, WS_CHILD
);
4139 ok(IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
4140 ok(IsChild(child2
, child4
), "wrong parent/child %p/%p\n", child2
, child4
);
4141 ok(!IsChild(child1
, child4
), "wrong parent/child %p/%p\n", child1
, child4
);
4142 SetWindowLongW(child2
, GWL_STYLE
, WS_CHILD
);
4143 ok(IsChild(child1
, child4
), "wrong parent/child %p/%p\n", child1
, child4
);
4144 ok(IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
4146 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
4148 ok(!IsWindow(parent
), "parent still exists\n");
4149 ok(!IsWindow(sibling
), "sibling still exists\n");
4150 ok(!IsWindow(child1
), "child1 still exists\n");
4151 ok(!IsWindow(child2
), "child2 still exists\n");
4152 ok(!IsWindow(child3
), "child3 still exists\n");
4153 ok(!IsWindow(child4
), "child4 still exists\n");
4155 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
4156 100, 100, 200, 200, 0, 0, 0, NULL
);
4157 assert(parent
!= 0);
4158 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
4159 0, 0, 50, 50, parent
, 0, 0, NULL
);
4160 assert(child1
!= 0);
4161 popup
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
4162 0, 0, 50, 50, 0, 0, 0, NULL
);
4165 trace("parent %p, child %p, popup %p\n", parent
, child1
, popup
);
4167 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
4168 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
4169 check_parents(popup
, desktop
, 0, 0, 0, popup
, popup
);
4171 SetActiveWindow(parent
);
4173 check_active_state(parent
, 0, parent
);
4175 ret
= SetParent(popup
, child1
);
4176 ok(ret
== desktop
, "expected %p, got %p\n", desktop
, ret
);
4177 check_parents(popup
, child1
, child1
, 0, 0, parent
, popup
);
4178 check_active_state(popup
, 0, popup
);
4180 SetActiveWindow(parent
);
4182 check_active_state(popup
, 0, popup
);
4184 EnableWindow(child1
, FALSE
);
4185 check_active_state(popup
, 0, popup
);
4187 check_active_state(parent
, 0, parent
);
4189 check_active_state(popup
, 0, popup
);
4190 EnableWindow(child1
, TRUE
);
4192 ShowWindow(child1
, SW_MINIMIZE
);
4194 check_active_state(parent
, 0, parent
);
4196 check_active_state(popup
, 0, popup
);
4197 ShowWindow(child1
, SW_HIDE
);
4199 SetActiveWindow(parent
);
4201 check_active_state(parent
, 0, parent
);
4203 bret
= SetForegroundWindow(popup
);
4204 ok(bret
, "SetForegroundWindow() failed\n");
4205 check_active_state(popup
, popup
, popup
);
4207 ShowWindow(parent
, SW_SHOW
);
4208 SetActiveWindow(popup
);
4209 ok(DestroyWindow(popup
), "DestroyWindow() failed\n");
4210 check_active_state(parent
, parent
, parent
);
4212 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
4214 ok(!IsWindow(parent
), "parent still exists\n");
4215 ok(!IsWindow(child1
), "child1 still exists\n");
4216 ok(!IsWindow(popup
), "popup still exists\n");
4219 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4221 LPCREATESTRUCTA lpcs
;
4228 lpcs
= (LPCREATESTRUCTA
)lparam
;
4229 lpss
= lpcs
->lpCreateParams
;
4232 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
4233 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
4234 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
4235 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
4237 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
4239 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
4240 "Ex style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
4241 lpss
->styleOld
, lpcs
->dwExStyle
);
4243 ok(lpss
->styleNew
== lpcs
->style
,
4244 "Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
4245 lpss
->styleNew
, lpcs
->style
);
4249 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4252 static ATOM atomStyleCheckClass
;
4254 static void register_style_check_class(void)
4262 GetModuleHandleA(NULL
),
4264 LoadCursorA(0, (LPCSTR
)IDC_ARROW
),
4265 (HBRUSH
)(COLOR_BTNFACE
+1),
4270 atomStyleCheckClass
= RegisterClassA(&wc
);
4271 assert(atomStyleCheckClass
);
4274 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
4276 DWORD dwActualStyle
;
4277 DWORD dwActualExStyle
;
4280 HWND hwndParent
= NULL
;
4282 ss
.styleNew
= dwStyleIn
;
4283 ss
.styleOld
= dwExStyleIn
;
4285 if (dwStyleIn
& WS_CHILD
)
4287 hwndParent
= CreateWindowExA(0, (LPCSTR
)MAKEINTATOM(atomStyleCheckClass
), NULL
,
4288 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
4291 hwnd
= CreateWindowExA(dwExStyleIn
, (LPCSTR
)MAKEINTATOM(atomStyleCheckClass
), NULL
,
4292 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
4295 flush_events( TRUE
);
4297 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
4298 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4299 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
4300 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
4302 /* try setting the styles explicitly */
4303 SetWindowLongA( hwnd
, GWL_EXSTYLE
, dwExStyleIn
);
4304 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
4305 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4306 /* WS_EX_WINDOWEDGE can't always be changed */
4307 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
4308 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
4309 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
4310 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
4312 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
4313 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
4314 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
4316 SetWindowLongA( hwnd
, GWL_STYLE
, dwStyleIn
);
4317 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
4318 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4319 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
4320 if ((dwStyleIn
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
) dwStyleOut
= dwStyleIn
;
4321 else dwStyleOut
= dwStyleIn
| WS_CLIPSIBLINGS
;
4322 /* WS_EX_WINDOWEDGE can't always be changed */
4323 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
4324 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
4325 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
4326 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
4328 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
4329 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
4330 /* FIXME: Remove the condition below once Wine is fixed */
4331 todo_wine_if (dwActualExStyle
!= dwExStyleOut
)
4332 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
4334 DestroyWindow(hwnd
);
4335 if (hwndParent
) DestroyWindow(hwndParent
);
4338 /* tests what window styles the window manager automatically adds */
4339 static void test_window_styles(void)
4341 register_style_check_class();
4343 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
4344 check_window_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
4345 check_window_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
4346 check_window_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
4347 check_window_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
4348 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
4349 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
4350 check_window_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
4351 check_window_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
4352 check_window_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
4353 check_window_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
4354 check_window_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
4355 check_window_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
4356 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4357 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4358 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4359 check_window_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4360 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4361 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4362 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4363 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4364 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
4365 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4366 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4367 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
4368 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4369 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4370 check_window_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4371 check_window_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4372 check_window_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4373 check_window_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4374 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
4375 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
4377 if (pGetLayeredWindowAttributes
)
4379 check_window_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
);
4380 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_WINDOWEDGE
);
4381 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
4382 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
);
4386 static INT_PTR WINAPI
empty_dlg_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4391 static INT_PTR WINAPI
empty_dlg_proc3(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4393 if (msg
== WM_INITDIALOG
)
4401 HWND parent
, grand_parent
;
4402 DLGTEMPLATE
*dlg_data
;
4405 static INT_PTR WINAPI
empty_dlg_proc2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4407 if (msg
== WM_INITDIALOG
)
4409 DWORD style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4410 struct dialog_param
*param
= (struct dialog_param
*)lparam
;
4411 BOOL parent_is_child
;
4414 parent_is_child
= (GetWindowLongA(param
->parent
, GWL_STYLE
) & (WS_POPUP
| WS_CHILD
)) == WS_CHILD
;
4416 ok(IsWindowEnabled(hwnd
), "wrong state for %p\n", hwnd
);
4417 if (parent_is_child
)
4419 ok(IsWindowEnabled(param
->parent
), "wrong state for %08x\n", style
);
4420 disabled_hwnd
= param
->grand_parent
;
4424 ok(!IsWindowEnabled(param
->parent
), "wrong state for %08x\n", style
);
4425 disabled_hwnd
= param
->parent
;
4428 if (param
->grand_parent
)
4430 if (parent_is_child
)
4431 ok(!IsWindowEnabled(param
->grand_parent
), "wrong state for %08x\n", style
);
4433 ok(IsWindowEnabled(param
->grand_parent
), "wrong state for %08x\n", style
);
4436 DialogBoxIndirectParamA(GetModuleHandleA(NULL
), param
->dlg_data
, disabled_hwnd
, empty_dlg_proc3
, 0);
4437 ok(IsWindowEnabled(disabled_hwnd
), "wrong state for %08x\n", style
);
4439 ok(IsWindowEnabled(hwnd
), "wrong state for %p\n", hwnd
);
4440 ok(IsWindowEnabled(param
->parent
), "wrong state for %p\n", param
->parent
);
4441 if (param
->grand_parent
)
4442 ok(IsWindowEnabled(param
->grand_parent
), "wrong state for %p (%08x)\n", param
->grand_parent
, style
);
4444 DialogBoxIndirectParamA(GetModuleHandleA(NULL
), param
->dlg_data
, hwnd
, empty_dlg_proc3
, 0);
4445 ok(IsWindowEnabled(hwnd
), "wrong state for %p\n", hwnd
);
4446 ok(IsWindowEnabled(param
->parent
), "wrong state for %p\n", param
->parent
);
4447 if (param
->grand_parent
)
4448 ok(IsWindowEnabled(param
->grand_parent
), "wrong state for %p (%08x)\n", param
->grand_parent
, style
);
4450 param
->dlg_data
->style
|= WS_CHILD
;
4451 DialogBoxIndirectParamA(GetModuleHandleA(NULL
), param
->dlg_data
, hwnd
, empty_dlg_proc3
, 0);
4452 ok(IsWindowEnabled(hwnd
), "wrong state for %p (%08x)\n", hwnd
, style
);
4459 static void check_dialog_style(DWORD style_in
, DWORD ex_style_in
, DWORD style_out
, DWORD ex_style_out
)
4469 DWORD style
, ex_style
;
4470 HWND hwnd
, grand_parent
= 0, parent
= 0;
4471 struct dialog_param param
;
4473 if (style_in
& WS_CHILD
)
4475 grand_parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
4476 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
4477 ok(grand_parent
!= 0, "grand_parent creation failed\n");
4480 parent
= CreateWindowExA(0, "static", NULL
, style_in
,
4481 0, 0, 0, 0, grand_parent
, NULL
, NULL
, NULL
);
4482 ok(parent
!= 0, "parent creation failed, style %#x\n", style_in
);
4484 dlg_data
.dt
.style
= style_in
;
4485 dlg_data
.dt
.dwExtendedStyle
= ex_style_in
;
4486 dlg_data
.dt
.cdit
= 0;
4489 dlg_data
.dt
.cx
= 100;
4490 dlg_data
.dt
.cy
= 100;
4491 dlg_data
.menu_name
= 0;
4492 dlg_data
.class_id
= 0;
4493 dlg_data
.class_atom
= 0;
4494 dlg_data
.caption
[0] = 0;
4496 hwnd
= CreateDialogIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, parent
, empty_dlg_proc
, 0);
4497 ok(hwnd
!= 0, "dialog creation failed, style %#x, exstyle %#x\n", style_in
, ex_style_in
);
4499 flush_events( TRUE
);
4501 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4502 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4503 ok(style
== (style_out
| DS_3DLOOK
), "got %#x\n", style
);
4504 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4506 ok(IsWindowEnabled(parent
), "wrong parent state (dialog style %#x)\n", style_in
);
4508 /* try setting the styles explicitly */
4509 SetWindowLongA(hwnd
, GWL_EXSTYLE
, ex_style_in
);
4510 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4511 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4512 ok(style
== (style_out
| DS_3DLOOK
), "got %#x\n", style
);
4513 /* WS_EX_WINDOWEDGE can't always be changed */
4514 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
4515 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4516 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
4517 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4519 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
4520 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4522 SetWindowLongA(hwnd
, GWL_STYLE
, style_in
);
4523 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4524 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4525 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
4526 if ((style_in
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
) style_out
= style_in
;
4527 else style_out
= style_in
| WS_CLIPSIBLINGS
;
4528 ok(style
== style_out
, "expected style %#x, got %#x\n", style_out
, style
);
4529 /* WS_EX_WINDOWEDGE can't always be changed */
4530 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
4531 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4532 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
4533 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4535 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
4536 /* FIXME: Remove the condition below once Wine is fixed */
4537 todo_wine_if (ex_style
!= ex_style_out
)
4538 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4540 DestroyWindow(hwnd
);
4542 param
.parent
= parent
;
4543 param
.grand_parent
= grand_parent
;
4544 param
.dlg_data
= &dlg_data
.dt
;
4545 DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, parent
, empty_dlg_proc2
, (LPARAM
)¶m
);
4547 ok(IsWindowEnabled(parent
), "wrong parent state (dialog style %#x)\n", style_in
);
4549 ok(IsWindowEnabled(grand_parent
), "wrong grand parent state (dialog style %#x)\n", style_in
);
4551 DestroyWindow(parent
);
4552 DestroyWindow(grand_parent
);
4555 static void test_dialog_styles(void)
4557 check_dialog_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4558 check_dialog_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4559 check_dialog_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4560 check_dialog_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4561 check_dialog_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4562 check_dialog_style(DS_CONTROL
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
|DS_CONTROL
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4563 check_dialog_style(WS_CAPTION
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4564 check_dialog_style(WS_BORDER
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4565 check_dialog_style(WS_DLGFRAME
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4566 check_dialog_style(WS_BORDER
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4567 check_dialog_style(WS_DLGFRAME
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4568 check_dialog_style(WS_CAPTION
|WS_SYSMENU
, 0, WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4569 check_dialog_style(WS_SYSMENU
, 0, WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4570 check_dialog_style(WS_CAPTION
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4571 check_dialog_style(WS_SYSMENU
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4572 check_dialog_style(WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4573 check_dialog_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4574 check_dialog_style(WS_CHILD
, 0, WS_CHILD
, 0);
4575 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
4576 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
4577 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
4578 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
4579 check_dialog_style(WS_CHILD
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4580 check_dialog_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
4581 check_dialog_style(WS_CHILD
|WS_BORDER
, 0, WS_CHILD
|WS_BORDER
, 0);
4582 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
4583 check_dialog_style(WS_CHILD
|WS_BORDER
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4584 check_dialog_style(WS_CHILD
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4585 check_dialog_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
4586 check_dialog_style(WS_CHILD
|WS_SYSMENU
, 0, WS_CHILD
|WS_SYSMENU
, 0);
4587 check_dialog_style(WS_CHILD
|WS_CAPTION
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4588 check_dialog_style(WS_CHILD
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4589 check_dialog_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4590 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4591 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4592 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4593 check_dialog_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4594 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4595 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4596 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4597 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4598 check_dialog_style(WS_CHILD
|WS_POPUP
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4599 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
, 0, WS_CHILD
|WS_POPUP
|WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4600 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_BORDER
, 0, WS_CHILD
|WS_POPUP
|WS_BORDER
|WS_CLIPSIBLINGS
, 0);
4601 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4602 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_BORDER
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4603 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4604 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4605 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_SYSMENU
, 0, WS_CHILD
|WS_POPUP
|WS_SYSMENU
|WS_CLIPSIBLINGS
, 0);
4606 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4607 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4608 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4609 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
4610 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4611 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4612 check_dialog_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
|WS_EX_CONTROLPARENT
);
4613 check_dialog_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4614 check_dialog_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4615 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4616 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4617 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4618 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4619 check_dialog_style(WS_POPUP
|DS_CONTROL
, 0, WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4620 check_dialog_style(WS_POPUP
|WS_CAPTION
, 0, WS_POPUP
|WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4621 check_dialog_style(WS_POPUP
|WS_BORDER
, 0, WS_POPUP
|WS_BORDER
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4622 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4623 check_dialog_style(WS_POPUP
|WS_BORDER
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4624 check_dialog_style(WS_POPUP
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4625 check_dialog_style(WS_POPUP
|WS_CAPTION
|WS_SYSMENU
, 0, WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4626 check_dialog_style(WS_POPUP
|WS_SYSMENU
, 0, WS_POPUP
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4627 check_dialog_style(WS_POPUP
|WS_CAPTION
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4628 check_dialog_style(WS_POPUP
|WS_SYSMENU
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4629 check_dialog_style(WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4630 check_dialog_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4631 check_dialog_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4633 if (pGetLayeredWindowAttributes
)
4635 check_dialog_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4636 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
);
4637 check_dialog_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
4638 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4642 struct dlg_parent_param
4652 static INT_PTR WINAPI
parent_dlg_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4654 if (msg
== WM_INITDIALOG
) {
4655 struct dlg_parent_param
*param
= (void*)lparam
;
4656 check_parents(hwnd
, param
->ga_parent
, param
->gwl_parent
, param
->get_parent
, param
->owner
,
4657 param
->root
? param
->root
: hwnd
, param
->ga_root_owner
? param
->ga_root_owner
: hwnd
);
4659 ok(!IsWindowEnabled(param
->gwl_parent
), "parent is not disabled\n");
4661 ok(IsWindowEnabled(param
->gwl_parent
), "parent is not enabled\n");
4667 static INT_PTR WINAPI
reparent_dlg_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4669 if (msg
== WM_INITDIALOG
) {
4670 ok(!IsWindowEnabled(GetParent(hwnd
)), "parent is not disabled\n");
4671 SetParent(hwnd
, (HWND
)lparam
);
4677 static INT_PTR WINAPI
reparent_owned_dlg_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4679 if (msg
== WM_INITDIALOG
) {
4680 HWND new_parent
= (HWND
)lparam
;
4681 HWND owner
= GetWindow(hwnd
, GW_OWNER
);
4682 ok(!IsWindowEnabled(owner
), "owner is not disabled\n");
4683 SetWindowLongA(hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) | WS_CHILD
);
4684 SetParent(hwnd
, new_parent
);
4685 ok(GetParent(hwnd
) == new_parent
, "GetParent(hwnd) = %p, expected %p\n", GetParent(hwnd
), new_parent
);
4686 PostMessageA(hwnd
, WM_QUIT
, 0, 0);
4692 static LRESULT WINAPI
reparent_dialog_owner_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4694 if (msg
== WM_ENTERIDLE
) {
4695 HWND dialog
= (HWND
)lparam
;
4696 HWND owner
= GetParent(dialog
);
4697 /* EndDialog will enable owner */
4698 EnableWindow(owner
, FALSE
);
4699 EndDialog(dialog
, 2);
4700 ok(IsWindowEnabled(owner
), "owner is not enabled\n");
4701 /* ...but it won't be enabled on dialog exit */
4702 EnableWindow(owner
, FALSE
);
4704 return DefWindowProcA( hwnd
, msg
, wparam
, lparam
);
4707 static LRESULT WINAPI
post_quit_dialog_owner_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4709 if (msg
== WM_ENTERIDLE
) {
4710 HWND dialog
= (HWND
)lparam
;
4711 PostMessageA(dialog
, WM_QUIT
, 0, 0);
4713 return DefWindowProcA( hwnd
, msg
, wparam
, lparam
);
4716 static LRESULT WINAPI
destroy_dialog_owner_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4718 if (msg
== WM_ENTERIDLE
) {
4719 HWND dialog
= (HWND
)lparam
;
4720 DestroyWindow(dialog
);
4722 return DefWindowProcA( hwnd
, msg
, wparam
, lparam
);
4725 static void test_dialog_parent(void)
4727 HWND dialog
, parent
, child
, child2
, other
, desktop
= GetDesktopWindow();
4728 struct dlg_parent_param param
;
4739 dlg_data
.dt
.dwExtendedStyle
= 0;
4740 dlg_data
.dt
.cdit
= 0;
4743 dlg_data
.dt
.cx
= 100;
4744 dlg_data
.dt
.cy
= 100;
4745 dlg_data
.menu_name
= 0;
4746 dlg_data
.class_id
= 0;
4747 dlg_data
.class_atom
= 0;
4748 dlg_data
.caption
[0] = 0;
4750 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
4751 /* Create a child without WS_CHILD flag. It's a valid owner window. */
4752 child
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
4753 SetParent(child
, parent
);
4754 /* Regular child. If passed as an owner, its parent will be true owner window. */
4755 child2
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, child
, NULL
, NULL
, NULL
);
4757 /* When dialog is created with WS_CHILD style, its parent depends on function used to create it. */
4758 dlg_data
.dt
.style
= WS_CHILD
;
4760 /* CreateDialogIndirectParam uses passed parent as dialog parent. */
4761 dialog
= CreateDialogIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, empty_dlg_proc
, 0);
4762 ok(dialog
!= 0, "dialog creation failed\n");
4763 check_parents(dialog
, child2
, child2
, child2
, NULL
, parent
, child
);
4765 ok(IsWindowEnabled(child2
), "child2 is disabled\n");
4766 EnableWindow(child2
, FALSE
);
4767 EndDialog(dialog
, 0);
4768 ok(IsWindowEnabled(child2
), "child2 is not enabled\n");
4769 DestroyWindow(dialog
);
4771 /* DialogBoxIndirectParam uses the first parent of passed owner that's not a child window as dialog
4772 * parent (like in case of dialog with owner). */
4773 param
.ga_parent
= param
.gwl_parent
= param
.get_parent
= child
;
4775 param
.root
= parent
;
4776 param
.ga_root_owner
= child
;
4777 ret
= DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, parent_dlg_proc
, (LPARAM
)¶m
);
4778 ok(ret
== 2, "DialogBoxIndirectParam returned %ld\n", ret
);
4780 /* Dialogs without WS_CHILD behave as expected, they use passed owner just like CreateWindow does. */
4781 dlg_data
.dt
.style
= WS_OVERLAPPEDWINDOW
;
4783 dialog
= CreateDialogIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, empty_dlg_proc
, 0);
4784 ok(dialog
!= 0, "dialog creation failed\n");
4785 check_parents(dialog
, desktop
, child
, NULL
, child
, dialog
, dialog
);
4787 ok(IsWindowEnabled(child
), "child is disabled\n");
4788 EnableWindow(child
, FALSE
);
4789 EndDialog(dialog
, 0);
4790 ok(IsWindowEnabled(child
), "child is not enabled\n");
4791 DestroyWindow(dialog
);
4793 param
.ga_parent
= desktop
;
4794 param
.gwl_parent
= child
;
4795 param
.get_parent
= NULL
;
4796 param
.owner
= child
;
4797 param
.root
= param
.ga_root_owner
= NULL
;
4798 ret
= DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, parent_dlg_proc
, (LPARAM
)¶m
);
4799 ok(ret
== 2, "DialogBoxIndirectParam returned %ld\n", ret
);
4801 other
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
4802 SetWindowLongPtrA(child
, GWLP_WNDPROC
, (ULONG_PTR
)reparent_dialog_owner_proc
);
4804 /* When dialog is created with WS_CHILD|WS_POPUP style, we have an owner. */
4805 dlg_data
.dt
.style
= WS_CHILD
|WS_POPUP
;
4807 dialog
= CreateDialogIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, empty_dlg_proc
, 0);
4808 ok(dialog
!= 0, "dialog creation failed\n");
4809 check_parents(dialog
, desktop
, child
, child
, child
, dialog
, child
);
4811 ok(IsWindowEnabled(child
), "child is disabled\n");
4812 EnableWindow(child
, FALSE
);
4813 EndDialog(dialog
, 0);
4814 ok(IsWindowEnabled(child
), "child is not enabled\n");
4815 DestroyWindow(dialog
);
4817 param
.ga_parent
= desktop
;
4818 param
.gwl_parent
= param
.get_parent
= child
;
4819 param
.owner
= child
;
4821 param
.ga_root_owner
= child
;
4822 ret
= DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, parent_dlg_proc
, (LPARAM
)¶m
);
4823 ok(ret
== 2, "DialogBoxIndirectParam returned %ld\n", ret
);
4825 /* If we change parent in WM_INITDIALOG for WS_CHILD dialog WM_ENTERIDLE is still sent to the original
4826 * parent. EndDialog will enable the new parent. */
4827 EnableWindow(child
, TRUE
);
4828 EnableWindow(other
, FALSE
);
4829 dlg_data
.dt
.style
= WS_CHILD
;
4830 ret
= DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, reparent_dlg_proc
, (LPARAM
)other
);
4831 ok(ret
== 2, "DialogBoxIndirectParam returned %ld\n", ret
);
4832 ok(!IsWindowEnabled(other
), "other is not disabled\n");
4833 ok(!IsWindowEnabled(child
), "child is not disabled\n");
4834 ok(IsWindowEnabled(child2
), "child2 is not enabled\n");
4835 EnableWindow(child
, TRUE
);
4837 /* If we change parent and style in WM_INITDIALOG for dialog with an owner to make it true child
4838 * (thus GetParent() will return the new parent instead of an owner), WM_ENTERIDLE is still sent
4839 * to the original parent. EndDialog will enable the new parent. */
4840 EnableWindow(other
, FALSE
);
4841 dlg_data
.dt
.style
= WS_OVERLAPPED
;
4842 ret
= DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, child2
, reparent_owned_dlg_proc
, (LPARAM
)other
);
4843 ok(ret
== 1, "DialogBoxIndirectParam returned %ld\n", ret
);
4844 ok(!IsWindowEnabled(other
), "other is not disabled\n");
4845 ok(!IsWindowEnabled(child
), "child is not disabled\n");
4846 ok(IsWindowEnabled(child2
), "child2 is not enabled\n");
4847 EnableWindow(child
, TRUE
);
4848 EnableWindow(other
, TRUE
);
4850 /* Quit dialog message loop by sending WM_QUIT message. Dialog owner is not enabled. */
4851 SetWindowLongPtrA(child
, GWLP_WNDPROC
, (ULONG_PTR
)post_quit_dialog_owner_proc
);
4852 ret
= DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, other
, empty_dlg_proc
, 0);
4853 ok(ret
== 1, "DialogBoxIndirectParam returned %ld\n", ret
);
4854 ok(!IsWindowEnabled(other
), "other is enabled\n");
4855 EnableWindow(other
, TRUE
);
4857 /* Quit dialog message loop by destroying the window. Dialog owner is not enabled. */
4858 SetWindowLongPtrA(child
, GWLP_WNDPROC
, (ULONG_PTR
)destroy_dialog_owner_proc
);
4859 ret
= DialogBoxIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, other
, empty_dlg_proc
, 0);
4860 ok(ret
== 1, "DialogBoxIndirectParam returned %ld\n", ret
);
4861 ok(!IsWindowEnabled(other
), "other is enabled\n");
4862 EnableWindow(other
, TRUE
);
4864 DestroyWindow(other
);
4865 DestroyWindow(parent
);
4868 static void test_scrollwindow( HWND hwnd
)
4874 ShowWindow( hwnd
, SW_SHOW
);
4875 UpdateWindow( hwnd
);
4876 flush_events( TRUE
);
4877 GetClientRect( hwnd
, &rc
);
4879 /* test ScrollWindow(Ex) with no clip rectangle */
4880 /* paint the lower half of the window black */
4882 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4883 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4884 /* paint the upper half of the window white */
4885 rc2
.bottom
= rc2
.top
;
4887 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
4888 /* scroll lower half up */
4890 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4891 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, NULL
, NULL
, NULL
, SW_ERASE
);
4892 flush_events(FALSE
);
4893 /* expected: black should have scrolled to the upper half */
4894 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
4895 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4896 /* Repeat that test of ScrollWindow(Ex) now with clip rectangle */
4897 /* paint the lower half of the window black */
4899 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4900 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4901 /* paint the upper half of the window white */
4902 rc2
.bottom
= rc2
.top
;
4904 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
4905 /* scroll lower half up */
4907 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4909 rc3
.left
= rc3
.right
/ 4;
4910 rc3
.right
-= rc3
.right
/ 4;
4911 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, &rc3
, NULL
, NULL
, SW_ERASE
);
4912 flush_events(FALSE
);
4913 /* expected: black should have scrolled to the upper half */
4914 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
4915 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4918 ReleaseDC( hwnd
, hdc
);
4921 static void test_scrollvalidate( HWND parent
)
4924 HRGN hrgn
=CreateRectRgn(0,0,0,0);
4925 HRGN exprgn
, tmprgn
, clipping
;
4926 RECT rc
, rcu
, cliprc
;
4927 /* create two overlapping child windows. The visual region
4928 * of hwnd1 is clipped by the overlapping part of
4929 * hwnd2 because of the WS_CLIPSIBLING style */
4932 clipping
= CreateRectRgn(0,0,0,0);
4933 tmprgn
= CreateRectRgn(0,0,0,0);
4934 exprgn
= CreateRectRgn(0,0,0,0);
4935 hwnd2
= CreateWindowExA(0, "static", NULL
,
4936 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4937 75, 30, 100, 100, parent
, 0, 0, NULL
);
4938 hwnd1
= CreateWindowExA(0, "static", NULL
,
4939 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4940 25, 50, 100, 100, parent
, 0, 0, NULL
);
4941 ShowWindow( parent
, SW_SHOW
);
4942 UpdateWindow( parent
);
4943 GetClientRect( hwnd1
, &rc
);
4945 SetRectRgn( clipping
, 10, 10, 90, 90);
4946 hdc
= GetDC( hwnd1
);
4947 /* for a visual touch */
4948 TextOutA( hdc
, 0,10, "0123456789", 10);
4949 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4950 /* create a region with what is expected */
4951 SetRectRgn( exprgn
, 39,0,49,74);
4952 SetRectRgn( tmprgn
, 88,79,98,93);
4953 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4954 SetRectRgn( tmprgn
, 0,93,98,98);
4955 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4956 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4957 if (!EqualRgn( exprgn
, hrgn
))
4959 trace("update rect is %s\n", wine_dbgstr_rect(&rcu
));
4962 /* now with clipping region */
4963 SelectClipRgn( hdc
, clipping
);
4964 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4965 /* create a region with what is expected */
4966 SetRectRgn( exprgn
, 39,10,49,74);
4967 SetRectRgn( tmprgn
, 80,79,90,85);
4968 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4969 SetRectRgn( tmprgn
, 10,85,90,90);
4970 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4971 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4972 if (!EqualRgn( exprgn
, hrgn
))
4974 trace("update rect is %s\n", wine_dbgstr_rect(&rcu
));
4977 ReleaseDC( hwnd1
, hdc
);
4979 /* test scrolling a rect by more than its size */
4980 DestroyWindow( hwnd2
);
4981 ValidateRect( hwnd1
, NULL
);
4982 SetRect( &rc
, 40,40, 50,50);
4983 InvalidateRect( hwnd1
, &rc
, 1);
4984 ScrollWindowEx( hwnd1
, -20, 0, &rc
, NULL
, hrgn
, &rcu
,
4985 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4986 SetRectRgn( exprgn
, 20, 40, 30, 50);
4987 SetRectRgn( tmprgn
, 40, 40, 50, 50);
4988 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4989 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4990 if (!EqualRgn( exprgn
, hrgn
)) dump_region(hrgn
);
4991 ok( rcu
.left
== 20 && rcu
.top
== 40 && rcu
.right
== 50 && rcu
.bottom
== 50,
4992 "unexpected update rect: %s\n", wine_dbgstr_rect(&rcu
));
4994 /* test scrolling a window with an update region */
4995 ValidateRect( hwnd1
, NULL
);
4996 SetRect( &rc
, 40,40, 50,50);
4997 InvalidateRect( hwnd1
, &rc
, 1);
4998 GetClientRect( hwnd1
, &rc
);
5000 ScrollWindowEx( hwnd1
, -10, 0, &rc
, &cliprc
, hrgn
, &rcu
,
5001 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
5002 SetRectRgn( exprgn
, 88,0,98,98);
5003 SetRectRgn( tmprgn
, 30, 40, 50, 50);
5004 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
5005 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
5006 if (!EqualRgn( exprgn
, hrgn
)) dump_region(hrgn
);
5008 /* clear an update region */
5009 UpdateWindow( hwnd1
);
5011 SetRect( &rc
, 0,40, 100,60);
5012 SetRect( &cliprc
, 0,0, 100,100);
5013 ScrollWindowEx( hwnd1
, 0, -25, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
5014 SetRectRgn( exprgn
, 0, 40, 98, 60 );
5015 ok( EqualRgn( exprgn
, hrgn
), "wrong update region in excessive scroll\n");
5016 if (!EqualRgn( exprgn
, hrgn
)) dump_region(hrgn
);
5018 /* now test ScrollWindowEx with a combination of
5019 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
5020 /* make hwnd2 the child of hwnd1 */
5021 hwnd2
= CreateWindowExA(0, "static", NULL
,
5022 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
5023 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
5024 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
5025 GetClientRect( hwnd1
, &rc
);
5028 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
5029 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
5030 ValidateRect( hwnd1
, NULL
);
5031 ValidateRect( hwnd2
, NULL
);
5032 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
5033 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
5034 SetRectRgn( exprgn
, 88,0,98,88);
5035 SetRectRgn( tmprgn
, 0,88,98,98);
5036 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
5037 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
5038 if (!EqualRgn( exprgn
, hrgn
)) dump_region(hrgn
);
5040 /* SW_SCROLLCHILDREN */
5041 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5042 ValidateRect( hwnd1
, NULL
);
5043 ValidateRect( hwnd2
, NULL
);
5044 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
5045 /* expected region is the same as in previous test */
5046 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
5047 if (!EqualRgn( exprgn
, hrgn
)) dump_region(hrgn
);
5049 /* no SW_SCROLLCHILDREN */
5050 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
5051 ValidateRect( hwnd1
, NULL
);
5052 ValidateRect( hwnd2
, NULL
);
5053 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
5054 /* expected region is the same as in previous test */
5055 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
5056 if (!EqualRgn( exprgn
, hrgn
)) dump_region(hrgn
);
5058 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
5059 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
5060 ValidateRect( hwnd1
, NULL
);
5061 ValidateRect( hwnd2
, NULL
);
5062 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
5063 SetRectRgn( exprgn
, 88,0,98,20);
5064 SetRectRgn( tmprgn
, 20,20,98,30);
5065 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
5066 SetRectRgn( tmprgn
, 20,30,30,88);
5067 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
5068 SetRectRgn( tmprgn
, 0,88,30,98);
5069 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
5070 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
5071 if (!EqualRgn( exprgn
, hrgn
)) dump_region(hrgn
);
5074 DeleteObject( hrgn
);
5075 DeleteObject( exprgn
);
5076 DeleteObject( tmprgn
);
5077 DestroyWindow( hwnd1
);
5078 DestroyWindow( hwnd2
);
5081 /* couple of tests of return values of scrollbar functions
5082 * called on a scrollbarless window */
5083 static void test_scroll(void)
5088 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
5089 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
5090 100, 100, 200, 200, 0, 0, 0, NULL
);
5092 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
5093 ok( ret
, "GetScrollRange failed\n" );
5094 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
5095 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
5096 si
.cbSize
= sizeof( si
);
5097 si
.fMask
= SIF_PAGE
;
5098 si
.nPage
= 0xdeadbeef;
5099 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
5100 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
5101 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
5103 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
5104 ok( ret
, "GetScrollRange returns FALSE\n");
5105 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
5106 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
5107 si
.cbSize
= sizeof( si
);
5108 si
.fMask
= SIF_PAGE
;
5109 si
.nPage
= 0xdeadbeef;
5110 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
5111 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
5112 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
5114 DestroyWindow( hwnd
);
5117 static void test_scrolldc( HWND parent
)
5120 HRGN exprgn
, tmprgn
, hrgn
;
5121 RECT rc
, rc2
, rcu
, cliprc
;
5125 hrgn
= CreateRectRgn(0,0,0,0);
5126 tmprgn
= CreateRectRgn(0,0,0,0);
5127 exprgn
= CreateRectRgn(0,0,0,0);
5129 hwnd1
= CreateWindowExA(0, "static", NULL
,
5130 WS_CHILD
| WS_VISIBLE
,
5131 25, 50, 100, 100, parent
, 0, 0, NULL
);
5132 ShowWindow( parent
, SW_SHOW
);
5133 UpdateWindow( parent
);
5134 flush_events( TRUE
);
5135 GetClientRect( hwnd1
, &rc
);
5136 hdc
= GetDC( hwnd1
);
5137 /* paint the upper half of the window black */
5139 rc2
.bottom
= ( rc
.top
+ rc
.bottom
) /2;
5140 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
5141 /* clip region is the lower half */
5143 cliprc
.top
= (rc
.top
+ rc
.bottom
) /2;
5144 /* test whether scrolled pixels are properly clipped */
5145 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
5146 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
5147 /* this scroll should not cause any visible changes */
5148 ScrollDC( hdc
, 5, -20, &rc
, &cliprc
, hrgn
, &rcu
);
5149 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
5150 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
5151 /* test with NULL clip rect */
5152 ScrollDC( hdc
, 20, -20, &rc
, NULL
, hrgn
, &rcu
);
5153 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
5154 SetRect(&rc2
, 0, 0, 100, 100);
5155 ok(EqualRect(&rcu
, &rc2
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rcu
),
5156 wine_dbgstr_rect(&rc2
));
5157 if (!EqualRect(&rcu
, &rc2
))
5159 trace("update rect: %s\n", wine_dbgstr_rect(&rcu
));
5163 SetRectRgn( exprgn
, 0, 0, 20, 80);
5164 SetRectRgn( tmprgn
, 0, 80, 100, 100);
5165 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
5166 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
5167 if (!EqualRgn(exprgn
, hrgn
)) dump_region(exprgn
);
5168 /* test clip rect > scroll rect */
5169 FillRect( hdc
, &rc
, GetStockObject(WHITE_BRUSH
));
5171 InflateRect( &rc2
, -(rc
.right
-rc
.left
)/4, -(rc
.bottom
-rc
.top
)/4);
5172 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
5173 ScrollDC( hdc
, 10, 10, &rc2
, &rc
, hrgn
, &rcu
);
5174 SetRectRgn( exprgn
, 25, 25, 75, 35);
5175 SetRectRgn( tmprgn
, 25, 35, 35, 75);
5176 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
5177 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
5178 if (!EqualRgn(exprgn
, hrgn
))
5180 trace("update rect: %s\n", wine_dbgstr_rect(&rcu
));
5184 ReleaseDC(hwnd1
, hdc
);
5186 DeleteObject(exprgn
);
5187 DeleteObject(tmprgn
);
5188 DestroyWindow(hwnd1
);
5191 static void test_params(void)
5196 ok(!IsWindow(0), "IsWindow(0)\n");
5197 ok(!IsWindow(HWND_BROADCAST
), "IsWindow(HWND_BROADCAST)\n");
5198 ok(!IsWindow(HWND_TOPMOST
), "IsWindow(HWND_TOPMOST)\n");
5200 /* Just a param check */
5201 if (pGetMonitorInfoA
)
5203 SetLastError(0xdeadbeef);
5204 rc
= GetWindowTextA(hwndMain2
, NULL
, 1024);
5205 ok( rc
==0, "GetWindowText: rc=%d err=%d\n",rc
,GetLastError());
5209 /* Skips actually on Win95 and NT4 */
5210 win_skip("Test would crash on Win95\n");
5213 SetLastError(0xdeadbeef);
5214 hwnd
=CreateWindowA("LISTBOX", "TestList",
5215 (LBS_STANDARD
& ~LBS_SORT
),
5217 NULL
, (HMENU
)1, NULL
, 0);
5219 ok(!hwnd
|| broken(hwnd
!= NULL
), /* w2k3 sp2 */
5220 "CreateWindow with invalid menu handle should fail\n");
5222 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
,
5223 "wrong last error value %d\n", GetLastError());
5226 static void test_AWRwindow(LPCSTR
class, LONG style
, LONG exStyle
, BOOL menu
)
5230 hwnd
= CreateWindowExA(exStyle
, class, class, style
,
5236 ok(hwnd
!= NULL
, "Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style
, exStyle
);
5238 ShowWindow(hwnd
, SW_SHOW
);
5240 test_nonclient_area(hwnd
);
5243 DestroyWindow(hwnd
);
5246 static BOOL
AWR_init(void)
5250 class.style
= CS_HREDRAW
| CS_VREDRAW
;
5251 class.lpfnWndProc
= DefWindowProcA
;
5252 class.cbClsExtra
= 0;
5253 class.cbWndExtra
= 0;
5254 class.hInstance
= 0;
5255 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
5256 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5257 class.hbrBackground
= 0;
5258 class.lpszMenuName
= 0;
5259 class.lpszClassName
= szAWRClass
;
5261 if (!RegisterClassA(&class)) {
5262 ok(FALSE
, "RegisterClass failed\n");
5266 hmenu
= CreateMenu();
5269 ok(hmenu
!= 0, "Failed to create menu\n");
5270 ok(AppendMenuA(hmenu
, MF_STRING
, 1, "Test!"), "Failed to create menu item\n");
5276 static void test_AWR_window_size(BOOL menu
)
5278 static const DWORD styles
[] = {
5279 WS_POPUP
, WS_MAXIMIZE
, WS_BORDER
, WS_DLGFRAME
, WS_CAPTION
, WS_SYSMENU
,
5280 WS_THICKFRAME
, WS_MINIMIZEBOX
, WS_MAXIMIZEBOX
, WS_HSCROLL
, WS_VSCROLL
5282 static const DWORD exStyles
[] = {
5283 WS_EX_CLIENTEDGE
, WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
, WS_EX_APPWINDOW
,
5284 WS_EX_DLGMODALFRAME
, WS_EX_DLGMODALFRAME
| WS_EX_STATICEDGE
5289 /* A exhaustive check of all the styles takes too long
5290 * so just do a (hopefully representative) sample
5292 for (i
= 0; i
< COUNTOF(styles
); ++i
)
5293 test_AWRwindow(szAWRClass
, styles
[i
], 0, menu
);
5294 for (i
= 0; i
< COUNTOF(exStyles
); ++i
) {
5295 test_AWRwindow(szAWRClass
, WS_POPUP
, exStyles
[i
], menu
);
5296 test_AWRwindow(szAWRClass
, WS_THICKFRAME
, exStyles
[i
], menu
);
5300 static void test_AWR_flags(void)
5302 static const DWORD styles
[] = { WS_POPUP
, WS_BORDER
, WS_DLGFRAME
, WS_THICKFRAME
};
5303 static const DWORD exStyles
[] = { WS_EX_CLIENTEDGE
, WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
,
5304 WS_EX_APPWINDOW
, WS_EX_DLGMODALFRAME
, WS_EX_STATICEDGE
};
5306 DWORD i
, j
, k
, style
, exstyle
;
5309 for (i
= 0; i
< (1 << COUNTOF(styles
)); i
++)
5311 for (k
= style
= 0; k
< COUNTOF(styles
); k
++) if (i
& (1 << k
)) style
|= styles
[k
];
5313 for (j
= 0; j
< (1 << COUNTOF(exStyles
)); j
++)
5315 for (k
= exstyle
= 0; k
< COUNTOF(exStyles
); k
++) if (j
& (1 << k
)) exstyle
|= exStyles
[k
];
5316 SetRect( &rect
, 100, 100, 200, 200 );
5318 AdjustWindowRectEx( &rect
, style
, FALSE
, exstyle
);
5319 wine_AdjustWindowRectEx( &rect2
, style
, FALSE
, exstyle
);
5320 ok( EqualRect( &rect
, &rect2
), "%08x %08x rects do not match: win %s wine %s\n",
5321 style
, exstyle
, wine_dbgstr_rect( &rect
), wine_dbgstr_rect( &rect2
));
5322 if (pAdjustWindowRectExForDpi
)
5324 pAdjustWindowRectExForDpi( &rect
, style
, FALSE
, exstyle
, 192 );
5325 wine_AdjustWindowRectExForDpi( &rect2
, style
, FALSE
, exstyle
, 192 );
5326 ok( EqualRect( &rect
, &rect2
), "%08x %08x rects do not match: win %s wine %s\n",
5327 style
, exstyle
, wine_dbgstr_rect( &rect
), wine_dbgstr_rect( &rect2
));
5334 #define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
5336 static void test_AdjustWindowRect(void)
5341 SHOWSYSMETRIC(SM_CYCAPTION
);
5342 SHOWSYSMETRIC(SM_CYSMCAPTION
);
5343 SHOWSYSMETRIC(SM_CYMENU
);
5344 SHOWSYSMETRIC(SM_CXEDGE
);
5345 SHOWSYSMETRIC(SM_CYEDGE
);
5346 SHOWSYSMETRIC(SM_CXVSCROLL
);
5347 SHOWSYSMETRIC(SM_CYHSCROLL
);
5348 SHOWSYSMETRIC(SM_CXFRAME
);
5349 SHOWSYSMETRIC(SM_CYFRAME
);
5350 SHOWSYSMETRIC(SM_CXDLGFRAME
);
5351 SHOWSYSMETRIC(SM_CYDLGFRAME
);
5352 SHOWSYSMETRIC(SM_CXBORDER
);
5353 SHOWSYSMETRIC(SM_CYBORDER
);
5355 test_AWR_window_size(FALSE
);
5356 test_AWR_window_size(TRUE
);
5361 #undef SHOWSYSMETRIC
5364 /* Global variables to trigger exit from loop */
5365 static int redrawComplete
, WMPAINT_count
;
5367 static LRESULT WINAPI
redraw_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
5373 if (WMPAINT_count
> 10 && redrawComplete
== 0) {
5375 BeginPaint(hwnd
, &ps
);
5376 EndPaint(hwnd
, &ps
);
5381 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
5384 /* Ensure we exit from RedrawNow regardless of invalidated area */
5385 static void test_redrawnow(void)
5391 cls
.style
= CS_DBLCLKS
;
5392 cls
.lpfnWndProc
= redraw_window_procA
;
5395 cls
.hInstance
= GetModuleHandleA(0);
5397 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5398 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5399 cls
.lpszMenuName
= NULL
;
5400 cls
.lpszClassName
= "RedrawWindowClass";
5401 ret
= RegisterClassA(&cls
);
5402 ok(ret
, "Failed to register a test class.\n");
5404 hwndMain
= CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
5405 CW_USEDEFAULT
, 0, 100, 100, NULL
, NULL
, 0, NULL
);
5407 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
5408 ShowWindow(hwndMain
, SW_SHOW
);
5409 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
5410 RedrawWindow(hwndMain
, NULL
,NULL
,RDW_UPDATENOW
| RDW_ALLCHILDREN
);
5411 ok( WMPAINT_count
== 1,
5412 "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
5413 redrawComplete
= TRUE
;
5414 ok( WMPAINT_count
< 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count
);
5417 DestroyWindow( hwndMain
);
5420 struct parentdc_stat
{
5426 struct parentdc_test
{
5427 struct parentdc_stat main
, main_todo
;
5428 struct parentdc_stat child1
, child1_todo
;
5429 struct parentdc_stat child2
, child2_todo
;
5432 static LRESULT WINAPI
parentdc_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
5437 struct parentdc_stat
*t
= (struct parentdc_stat
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
5442 GetClientRect(hwnd
, &rc
);
5444 GetWindowRect(hwnd
, &rc
);
5445 if (winetest_debug
> 1)
5446 trace("WM_PAINT: hwnd %p, client rect %s, window rect %s\n", hwnd
,
5447 wine_dbgstr_rect(&t
->client
), wine_dbgstr_rect(&rc
));
5448 BeginPaint(hwnd
, &ps
);
5449 t
->paint
= ps
.rcPaint
;
5450 GetClipBox(ps
.hdc
, &rc
);
5452 if (winetest_debug
> 1)
5453 trace("clip rect %s, paint rect %s\n", wine_dbgstr_rect(&rc
),
5454 wine_dbgstr_rect(&ps
.rcPaint
));
5455 EndPaint(hwnd
, &ps
);
5458 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
5461 static void zero_parentdc_stat(struct parentdc_stat
*t
)
5463 SetRectEmpty(&t
->client
);
5464 SetRectEmpty(&t
->clip
);
5465 SetRectEmpty(&t
->paint
);
5468 static void zero_parentdc_test(struct parentdc_test
*t
)
5470 zero_parentdc_stat(&t
->main
);
5471 zero_parentdc_stat(&t
->child1
);
5472 zero_parentdc_stat(&t
->child2
);
5475 #define parentdc_field_ok(t, w, r, f, got) \
5476 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
5477 ": expected %d, got %d\n", \
5480 #define parentdc_todo_field_ok(t, w, r, f, got) \
5481 todo_wine_if (t.w##_todo.r.f) \
5482 parentdc_field_ok(t, w, r, f, got);
5484 #define parentdc_rect_ok(t, w, r, got) \
5485 parentdc_todo_field_ok(t, w, r, left, got); \
5486 parentdc_todo_field_ok(t, w, r, top, got); \
5487 parentdc_todo_field_ok(t, w, r, right, got); \
5488 parentdc_todo_field_ok(t, w, r, bottom, got);
5490 #define parentdc_win_ok(t, w, got) \
5491 parentdc_rect_ok(t, w, client, got); \
5492 parentdc_rect_ok(t, w, clip, got); \
5493 parentdc_rect_ok(t, w, paint, got);
5495 #define parentdc_ok(t, got) \
5496 parentdc_win_ok(t, main, got); \
5497 parentdc_win_ok(t, child1, got); \
5498 parentdc_win_ok(t, child2, got);
5500 static void test_csparentdc(void)
5502 WNDCLASSA clsMain
, cls
;
5503 HWND hwndMain
, hwnd1
, hwnd2
;
5507 struct parentdc_test test_answer
;
5509 #define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
5510 const struct parentdc_test test1
=
5512 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo
,
5513 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5514 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5517 const struct parentdc_test test2
=
5519 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo
,
5520 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
5521 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
5524 const struct parentdc_test test3
=
5526 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
5527 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
5528 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
5531 const struct parentdc_test test4
=
5533 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo
,
5534 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo
,
5535 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
5538 const struct parentdc_test test5
=
5540 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo
,
5541 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5542 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
5545 const struct parentdc_test test6
=
5547 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
5548 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
5549 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
5552 const struct parentdc_test test7
=
5554 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
5555 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
5556 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
5560 clsMain
.style
= CS_DBLCLKS
;
5561 clsMain
.lpfnWndProc
= parentdc_window_procA
;
5562 clsMain
.cbClsExtra
= 0;
5563 clsMain
.cbWndExtra
= 0;
5564 clsMain
.hInstance
= GetModuleHandleA(0);
5566 clsMain
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5567 clsMain
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5568 clsMain
.lpszMenuName
= NULL
;
5569 clsMain
.lpszClassName
= "ParentDcMainWindowClass";
5570 ret
= RegisterClassA(&clsMain
);
5571 ok(ret
, "Failed to register a test class.\n");
5573 cls
.style
= CS_DBLCLKS
| CS_PARENTDC
;
5574 cls
.lpfnWndProc
= parentdc_window_procA
;
5577 cls
.hInstance
= GetModuleHandleA(0);
5579 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5580 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5581 cls
.lpszMenuName
= NULL
;
5582 cls
.lpszClassName
= "ParentDcWindowClass";
5583 ret
= RegisterClassA(&cls
);
5584 ok(ret
, "Failed to register a test class.\n");
5586 SetRect(&rc
, 0, 0, 150, 150);
5587 AdjustWindowRectEx(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
, 0);
5588 hwndMain
= CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
5589 CW_USEDEFAULT
, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, NULL
, NULL
, 0, NULL
);
5590 SetWindowLongPtrA(hwndMain
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.main
);
5591 hwnd1
= CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD
,
5592 20, 20, 40, 40, hwndMain
, NULL
, 0, NULL
);
5593 SetWindowLongPtrA(hwnd1
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child1
);
5594 hwnd2
= CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD
,
5595 40, 40, 40, 40, hwndMain
, NULL
, 0, NULL
);
5596 SetWindowLongPtrA(hwnd2
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child2
);
5597 ShowWindow(hwndMain
, SW_SHOW
);
5598 ShowWindow(hwnd1
, SW_SHOW
);
5599 ShowWindow(hwnd2
, SW_SHOW
);
5600 SetWindowPos(hwndMain
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
5601 flush_events( TRUE
);
5603 zero_parentdc_test(&test_answer
);
5604 InvalidateRect(hwndMain
, NULL
, TRUE
);
5605 flush_events( TRUE
);
5606 parentdc_ok(test1
, test_answer
);
5608 zero_parentdc_test(&test_answer
);
5609 SetRect(&rc
, 0, 0, 50, 50);
5610 InvalidateRect(hwndMain
, &rc
, TRUE
);
5611 flush_events( TRUE
);
5612 parentdc_ok(test2
, test_answer
);
5614 zero_parentdc_test(&test_answer
);
5615 SetRect(&rc
, 0, 0, 10, 10);
5616 InvalidateRect(hwndMain
, &rc
, TRUE
);
5617 flush_events( TRUE
);
5618 parentdc_ok(test3
, test_answer
);
5620 zero_parentdc_test(&test_answer
);
5621 SetRect(&rc
, 40, 40, 50, 50);
5622 InvalidateRect(hwndMain
, &rc
, TRUE
);
5623 flush_events( TRUE
);
5624 parentdc_ok(test4
, test_answer
);
5626 zero_parentdc_test(&test_answer
);
5627 SetRect(&rc
, 20, 20, 60, 60);
5628 InvalidateRect(hwndMain
, &rc
, TRUE
);
5629 flush_events( TRUE
);
5630 parentdc_ok(test5
, test_answer
);
5632 zero_parentdc_test(&test_answer
);
5633 SetRect(&rc
, 0, 0, 10, 10);
5634 InvalidateRect(hwnd1
, &rc
, TRUE
);
5635 flush_events( TRUE
);
5636 parentdc_ok(test6
, test_answer
);
5638 zero_parentdc_test(&test_answer
);
5639 SetRect(&rc
, -5, -5, 65, 65);
5640 InvalidateRect(hwnd1
, &rc
, TRUE
);
5641 flush_events( TRUE
);
5642 parentdc_ok(test7
, test_answer
);
5644 DestroyWindow(hwndMain
);
5645 DestroyWindow(hwnd1
);
5646 DestroyWindow(hwnd2
);
5649 static LRESULT WINAPI
def_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
5651 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
5654 static LRESULT WINAPI
def_window_procW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
5656 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
5659 static void test_IsWindowUnicode(void)
5661 static const char ansi_class_nameA
[] = "ansi class name";
5662 static const WCHAR ansi_class_nameW
[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
5663 static const char unicode_class_nameA
[] = "unicode class name";
5664 static const WCHAR unicode_class_nameW
[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
5670 memset(&classW
, 0, sizeof(classW
));
5671 classW
.hInstance
= GetModuleHandleA(0);
5672 classW
.lpfnWndProc
= def_window_procW
;
5673 classW
.lpszClassName
= unicode_class_nameW
;
5674 RegisterClassW(&classW
);
5676 memset(&classA
, 0, sizeof(classA
));
5677 classA
.hInstance
= GetModuleHandleA(0);
5678 classA
.lpfnWndProc
= def_window_procA
;
5679 classA
.lpszClassName
= ansi_class_nameA
;
5680 atom
= RegisterClassA(&classA
);
5683 /* unicode class: window proc */
5684 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
5685 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5688 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5689 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5690 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5691 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5692 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5694 DestroyWindow(hwnd
);
5696 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
5697 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5700 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5701 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5702 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5703 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5704 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5706 DestroyWindow(hwnd
);
5708 /* ansi class: window proc */
5709 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
5710 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5713 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5714 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5715 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5716 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5717 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5719 DestroyWindow(hwnd
);
5721 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
5722 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5725 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5726 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5727 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5728 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5729 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5731 DestroyWindow(hwnd
);
5733 /* unicode class: class proc */
5734 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
5735 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5738 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5739 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5740 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5741 /* do not restore class window proc back to unicode */
5743 DestroyWindow(hwnd
);
5745 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
5746 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5749 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5750 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5751 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5753 DestroyWindow(hwnd
);
5755 /* ansi class: class proc */
5756 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
5757 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5760 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5761 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5762 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5763 /* do not restore class window proc back to ansi */
5765 DestroyWindow(hwnd
);
5767 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
5768 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5771 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5772 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5773 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5775 DestroyWindow(hwnd
);
5778 static LRESULT CALLBACK
minmax_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
5782 if (msg
!= WM_GETMINMAXINFO
)
5783 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5785 minmax
= (MINMAXINFO
*)lp
;
5787 if ((GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
5789 minmax
->ptReserved
.x
= 0;
5790 minmax
->ptReserved
.y
= 0;
5791 minmax
->ptMaxSize
.x
= 400;
5792 minmax
->ptMaxSize
.y
= 400;
5793 minmax
->ptMaxPosition
.x
= 300;
5794 minmax
->ptMaxPosition
.y
= 300;
5795 minmax
->ptMaxTrackSize
.x
= 200;
5796 minmax
->ptMaxTrackSize
.y
= 200;
5797 minmax
->ptMinTrackSize
.x
= 100;
5798 minmax
->ptMinTrackSize
.y
= 100;
5801 DefWindowProcA(hwnd
, msg
, wp
, lp
);
5805 static int expected_cx
, expected_cy
;
5806 static RECT expected_rect
, broken_rect
;
5808 static LRESULT CALLBACK
winsizes_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
5812 case WM_GETMINMAXINFO
:
5815 GetWindowRect( hwnd
, &rect
);
5816 ok( !rect
.left
&& !rect
.top
&& !rect
.right
&& !rect
.bottom
, "wrong rect %s\n",
5817 wine_dbgstr_rect( &rect
));
5818 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5823 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
5825 GetWindowRect( hwnd
, &rect
);
5826 ok( cs
->cx
== expected_cx
|| broken(cs
->cx
== (short)expected_cx
),
5827 "%p msg %x wrong x size %d/%d\n", hwnd
, msg
, cs
->cx
, expected_cx
);
5828 ok( cs
->cy
== expected_cy
|| broken(cs
->cy
== (short)expected_cy
),
5829 "%p msg %x wrong y size %d/%d\n", hwnd
, msg
, cs
->cy
, expected_cy
);
5830 ok( (rect
.right
- rect
.left
== expected_rect
.right
- expected_rect
.left
&&
5831 rect
.bottom
- rect
.top
== expected_rect
.bottom
- expected_rect
.top
) ||
5832 (rect
.right
- rect
.left
== min( 65535, expected_rect
.right
- expected_rect
.left
) &&
5833 rect
.bottom
- rect
.top
== min( 65535, expected_rect
.bottom
- expected_rect
.top
)) ||
5834 broken( rect
.right
- rect
.left
== broken_rect
.right
- broken_rect
.left
&&
5835 rect
.bottom
- rect
.top
== broken_rect
.bottom
- broken_rect
.top
) ||
5836 broken( rect
.right
- rect
.left
== (short)broken_rect
.right
- (short)broken_rect
.left
&&
5837 rect
.bottom
- rect
.top
== (short)broken_rect
.bottom
- (short)broken_rect
.top
),
5838 "%p msg %x wrong rect %s / %s\n", hwnd
, msg
, wine_dbgstr_rect( &rect
),
5839 wine_dbgstr_rect( &expected_rect
));
5840 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5844 RECT rect
, *r
= (RECT
*)lp
;
5845 GetWindowRect( hwnd
, &rect
);
5846 ok( EqualRect( &rect
, r
), "passed rect %s doesn't match window rect %s\n",
5847 wine_dbgstr_rect( r
), wine_dbgstr_rect( &rect
));
5848 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5851 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5855 static void test_CreateWindow(void)
5864 #define expect_menu(window, menu) \
5865 SetLastError(0xdeadbeef); \
5866 res = (GetMenu(window) == (HMENU)menu); \
5867 ok(res, "GetMenu error %d\n", GetLastError())
5869 #define expect_style(window, style)\
5870 ok((ULONG)GetWindowLongA(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLongA(window, GWL_STYLE))
5872 #define expect_ex_style(window, ex_style)\
5873 ok((ULONG)GetWindowLongA(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLongA(window, GWL_EXSTYLE))
5875 hmenu
= CreateMenu();
5877 parent
= GetDesktopWindow();
5878 assert(parent
!= 0);
5880 SetLastError(0xdeadbeef);
5881 res
= IsMenu(hmenu
);
5882 ok(res
, "IsMenu error %d\n", GetLastError());
5885 SetLastError(0xdeadbeef);
5886 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
,
5887 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5888 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5889 expect_menu(hwnd
, 1);
5890 expect_style(hwnd
, WS_CHILD
);
5891 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5892 DestroyWindow(hwnd
);
5894 SetLastError(0xdeadbeef);
5895 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_CAPTION
,
5896 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5897 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5898 expect_menu(hwnd
, 1);
5899 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
5900 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5901 DestroyWindow(hwnd
);
5903 SetLastError(0xdeadbeef);
5904 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
5905 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5906 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5907 expect_menu(hwnd
, 1);
5908 expect_style(hwnd
, WS_CHILD
);
5909 expect_ex_style(hwnd
, 0);
5910 DestroyWindow(hwnd
);
5912 SetLastError(0xdeadbeef);
5913 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_CAPTION
,
5914 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5915 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5916 expect_menu(hwnd
, 1);
5917 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
5918 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5919 DestroyWindow(hwnd
);
5922 SetLastError(0xdeadbeef);
5923 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5924 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5925 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5926 expect_menu(hwnd
, hmenu
);
5927 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
5928 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5929 DestroyWindow(hwnd
);
5930 SetLastError(0xdeadbeef);
5931 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5932 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
5934 hmenu
= CreateMenu();
5936 SetLastError(0xdeadbeef);
5937 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
| WS_CAPTION
,
5938 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5939 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5940 expect_menu(hwnd
, hmenu
);
5941 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5942 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5943 DestroyWindow(hwnd
);
5944 SetLastError(0xdeadbeef);
5945 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5946 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
5948 hmenu
= CreateMenu();
5950 SetLastError(0xdeadbeef);
5951 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
5952 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5953 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5954 expect_menu(hwnd
, hmenu
);
5955 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
5956 expect_ex_style(hwnd
, 0);
5957 DestroyWindow(hwnd
);
5958 SetLastError(0xdeadbeef);
5959 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5960 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
5962 hmenu
= CreateMenu();
5964 SetLastError(0xdeadbeef);
5965 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
| WS_CAPTION
,
5966 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5967 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5968 expect_menu(hwnd
, hmenu
);
5969 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5970 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5971 DestroyWindow(hwnd
);
5972 SetLastError(0xdeadbeef);
5973 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5974 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
5976 /* WS_CHILD | WS_POPUP */
5977 SetLastError(0xdeadbeef);
5978 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5979 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5980 ok(!hwnd
, "CreateWindowEx should fail\n");
5981 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
5983 DestroyWindow(hwnd
);
5985 hmenu
= CreateMenu();
5987 SetLastError(0xdeadbeef);
5988 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5989 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5990 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5991 expect_menu(hwnd
, hmenu
);
5992 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
5993 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5994 DestroyWindow(hwnd
);
5995 SetLastError(0xdeadbeef);
5996 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5997 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
5999 SetLastError(0xdeadbeef);
6000 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
6001 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
6002 ok(!hwnd
, "CreateWindowEx should fail\n");
6003 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
6005 DestroyWindow(hwnd
);
6007 hmenu
= CreateMenu();
6009 SetLastError(0xdeadbeef);
6010 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
6011 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
6012 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
6013 expect_menu(hwnd
, hmenu
);
6014 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
6015 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
6016 DestroyWindow(hwnd
);
6017 SetLastError(0xdeadbeef);
6018 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
6019 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
6021 SetLastError(0xdeadbeef);
6022 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
6023 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
6024 ok(!hwnd
, "CreateWindowEx should fail\n");
6025 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
6027 DestroyWindow(hwnd
);
6029 hmenu
= CreateMenu();
6031 SetLastError(0xdeadbeef);
6032 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
6033 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
6034 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
6035 expect_menu(hwnd
, hmenu
);
6036 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
6037 expect_ex_style(hwnd
, 0);
6038 DestroyWindow(hwnd
);
6039 SetLastError(0xdeadbeef);
6040 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
6041 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
6043 SetLastError(0xdeadbeef);
6044 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
6045 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
6046 ok(!hwnd
, "CreateWindowEx should fail\n");
6047 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
6049 DestroyWindow(hwnd
);
6051 hmenu
= CreateMenu();
6053 SetLastError(0xdeadbeef);
6054 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
6055 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
6056 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
6057 expect_menu(hwnd
, hmenu
);
6058 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
6059 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
6060 DestroyWindow(hwnd
);
6061 SetLastError(0xdeadbeef);
6062 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
6063 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
, "IsMenu set error %d\n", GetLastError());
6065 /* test child window sizing */
6067 cls
.lpfnWndProc
= minmax_wnd_proc
;
6070 cls
.hInstance
= GetModuleHandleA(NULL
);
6072 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6073 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6074 cls
.lpszMenuName
= NULL
;
6075 cls
.lpszClassName
= "MinMax_WndClass";
6076 RegisterClassA(&cls
);
6078 SetLastError(0xdeadbeef);
6079 parent
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
6080 0, 0, 100, 100, 0, 0, 0, NULL
);
6081 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
6082 expect_menu(parent
, 0);
6083 expect_style(parent
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
| WS_CLIPSIBLINGS
);
6084 expect_ex_style(parent
, WS_EX_WINDOWEDGE
);
6086 memset(&minmax
, 0, sizeof(minmax
));
6087 SendMessageA(parent
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
6088 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxSize
.x
, minmax
.ptMaxSize
.y
);
6089 ok(IsRectEmpty(&rc_minmax
), "ptMaxSize is not empty\n");
6090 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
6091 ok(IsRectEmpty(&rc_minmax
), "ptMaxTrackSize is not empty\n");
6093 GetWindowRect(parent
, &rc
);
6094 ok(!IsRectEmpty(&rc
), "parent window rect is empty\n");
6095 GetClientRect(parent
, &rc
);
6096 ok(!IsRectEmpty(&rc
), "parent client rect is empty\n");
6098 InflateRect(&rc
, 200, 200);
6100 SetLastError(0xdeadbeef);
6101 hwnd
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
6102 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
6103 parent
, (HMENU
)1, 0, NULL
);
6104 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
6105 expect_menu(hwnd
, 1);
6106 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
);
6107 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
6109 memset(&minmax
, 0, sizeof(minmax
));
6110 SendMessageA(hwnd
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
6111 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
6113 GetWindowRect(hwnd
, &rc
);
6114 OffsetRect(&rc
, -rc
.left
, -rc
.top
);
6115 ok(EqualRect(&rc
, &rc_minmax
), "rects don't match: %s and %s\n", wine_dbgstr_rect(&rc
),
6116 wine_dbgstr_rect(&rc_minmax
));
6117 DestroyWindow(hwnd
);
6119 cls
.lpfnWndProc
= winsizes_wnd_proc
;
6120 cls
.lpszClassName
= "Sizes_WndClass";
6121 RegisterClassA(&cls
);
6123 expected_cx
= expected_cy
= 200000;
6124 SetRect( &expected_rect
, 0, 0, 200000, 200000 );
6125 broken_rect
= expected_rect
;
6126 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 300000, 300000, 200000, 200000, parent
, 0, 0, NULL
);
6127 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6128 GetClientRect( hwnd
, &rc
);
6129 ok( rc
.right
== 200000 || rc
.right
== 65535 || broken(rc
.right
== (short)200000),
6130 "invalid rect right %u\n", rc
.right
);
6131 ok( rc
.bottom
== 200000 || rc
.bottom
== 65535 || broken(rc
.bottom
== (short)200000),
6132 "invalid rect bottom %u\n", rc
.bottom
);
6133 DestroyWindow(hwnd
);
6135 expected_cx
= expected_cy
= -10;
6136 SetRectEmpty(&expected_rect
);
6137 SetRect( &broken_rect
, 0, 0, -10, -10 );
6138 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -20, -20, -10, -10, parent
, 0, 0, NULL
);
6139 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6140 GetClientRect( hwnd
, &rc
);
6141 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
6142 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
6143 DestroyWindow(hwnd
);
6145 expected_cx
= expected_cy
= -200000;
6146 SetRectEmpty(&expected_rect
);
6147 SetRect( &broken_rect
, 0, 0, -200000, -200000 );
6148 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -300000, -300000, -200000, -200000, parent
, 0, 0, NULL
);
6149 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6150 GetClientRect( hwnd
, &rc
);
6151 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
6152 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
6153 DestroyWindow(hwnd
);
6155 /* we need a parent at 0,0 so that child coordinates match */
6156 DestroyWindow(parent
);
6157 parent
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_POPUP
, 0, 0, 100, 100, 0, 0, 0, NULL
);
6158 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
6161 expected_cy
= 0x7fffffff;
6162 SetRect( &expected_rect
, 10, 10, 110, 0x7fffffff );
6163 SetRect( &broken_rect
, 10, 10, 110, 0x7fffffffU
+ 10 );
6164 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 10, 10, 100, 0x7fffffff, parent
, 0, 0, NULL
);
6165 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6166 GetClientRect( hwnd
, &rc
);
6167 ok( rc
.right
== 100, "invalid rect right %u\n", rc
.right
);
6168 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.bottom
==65535 || broken(rc
.bottom
== 0),
6169 "invalid rect bottom %u\n", rc
.bottom
);
6170 DestroyWindow(hwnd
);
6172 expected_cx
= 0x7fffffff;
6173 expected_cy
= 0x7fffffff;
6174 SetRect( &expected_rect
, 20, 10, 0x7fffffff, 0x7fffffff );
6175 SetRect( &broken_rect
, 20, 10, 0x7fffffffU
+ 20, 0x7fffffffU
+ 10 );
6176 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 20, 10, 0x7fffffff, 0x7fffffff, parent
, 0, 0, NULL
);
6177 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6178 GetClientRect( hwnd
, &rc
);
6179 ok( rc
.right
== 0x7fffffff - 20 || rc
.right
== 65535 || broken(rc
.right
== 0),
6180 "invalid rect right %u\n", rc
.right
);
6181 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.right
== 65535 || broken(rc
.bottom
== 0),
6182 "invalid rect bottom %u\n", rc
.bottom
);
6183 DestroyWindow(hwnd
);
6185 /* top level window */
6186 expected_cx
= expected_cy
= 200000;
6187 SetRect( &expected_rect
, 0, 0, GetSystemMetrics(SM_CXMAXTRACK
), GetSystemMetrics(SM_CYMAXTRACK
) );
6188 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_OVERLAPPEDWINDOW
, 300000, 300000, 200000, 200000, 0, 0, 0, NULL
);
6189 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6190 GetClientRect( hwnd
, &rc
);
6191 ok( rc
.right
<= expected_cx
, "invalid rect right %u\n", rc
.right
);
6192 ok( rc
.bottom
<= expected_cy
, "invalid rect bottom %u\n", rc
.bottom
);
6193 DestroyWindow(hwnd
);
6196 SetLastError(0xdeadbeef);
6197 hwnd
= CreateWindowExA(0, "INVALID_CLASS", NULL
, WS_CHILD
, 10, 10, 100, 100, parent
, 0, 0, NULL
);
6198 ok(hwnd
== 0, "CreateWindowEx succeeded\n");
6199 ok(GetLastError() == ERROR_CLASS_DOES_NOT_EXIST
|| GetLastError() == ERROR_CANNOT_FIND_WND_CLASS
,
6200 "invalid error %u\n", GetLastError());
6201 DestroyWindow(hwnd
);
6203 if (pGetLayout
&& pSetLayout
)
6205 HDC hdc
= GetDC( parent
);
6206 pSetLayout( hdc
, LAYOUT_RTL
);
6207 if (pGetLayout( hdc
))
6209 ReleaseDC( parent
, hdc
);
6210 DestroyWindow( parent
);
6211 SetLastError( 0xdeadbeef );
6212 parent
= CreateWindowExA(WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
,
6213 0, 0, 100, 100, 0, 0, 0, NULL
);
6214 ok( parent
!= 0, "creation failed err %u\n", GetLastError());
6215 expect_ex_style( parent
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
6216 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
6217 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6218 expect_ex_style( hwnd
, WS_EX_LAYOUTRTL
);
6219 DestroyWindow( hwnd
);
6220 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
6221 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6222 expect_ex_style( hwnd
, 0 );
6223 DestroyWindow( hwnd
);
6224 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
| WS_EX_NOINHERITLAYOUT
);
6225 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
6226 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6227 expect_ex_style( hwnd
, 0 );
6228 DestroyWindow( hwnd
);
6230 if (pGetProcessDefaultLayout
&& pSetProcessDefaultLayout
)
6234 SetLastError( 0xdeadbeef );
6235 ok( !pGetProcessDefaultLayout( NULL
), "GetProcessDefaultLayout succeeded\n" );
6236 ok( GetLastError() == ERROR_NOACCESS
, "wrong error %u\n", GetLastError() );
6237 SetLastError( 0xdeadbeef );
6238 res
= pGetProcessDefaultLayout( &layout
);
6239 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
6240 ok( layout
== 0, "GetProcessDefaultLayout wrong layout %x\n", layout
);
6241 SetLastError( 0xdeadbeef );
6242 res
= pSetProcessDefaultLayout( 7 );
6243 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
6244 res
= pGetProcessDefaultLayout( &layout
);
6245 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
6246 ok( layout
== 7, "GetProcessDefaultLayout wrong layout %x\n", layout
);
6247 SetLastError( 0xdeadbeef );
6248 res
= pSetProcessDefaultLayout( LAYOUT_RTL
);
6249 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
6250 res
= pGetProcessDefaultLayout( &layout
);
6251 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
6252 ok( layout
== LAYOUT_RTL
, "GetProcessDefaultLayout wrong layout %x\n", layout
);
6253 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
6254 0, 0, 100, 100, 0, 0, 0, NULL
);
6255 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6256 expect_ex_style( hwnd
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
6257 DestroyWindow( hwnd
);
6258 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
6259 0, 0, 100, 100, parent
, 0, 0, NULL
);
6260 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
6261 expect_ex_style( hwnd
, WS_EX_APPWINDOW
);
6262 DestroyWindow( hwnd
);
6263 pSetProcessDefaultLayout( 0 );
6265 else win_skip( "SetProcessDefaultLayout not supported\n" );
6267 else win_skip( "SetLayout not supported\n" );
6269 else win_skip( "SetLayout not available\n" );
6271 DestroyWindow(parent
);
6273 UnregisterClassA("MinMax_WndClass", GetModuleHandleA(NULL
));
6274 UnregisterClassA("Sizes_WndClass", GetModuleHandleA(NULL
));
6278 #undef expect_ex_style
6281 /* function that remembers whether the system the test is running on sets the
6282 * last error for user32 functions to make the tests stricter */
6283 static int check_error(DWORD actual
, DWORD expected
)
6285 static int sets_last_error
= -1;
6286 if (sets_last_error
== -1)
6287 sets_last_error
= (actual
!= 0xdeadbeef);
6288 return (!sets_last_error
&& (actual
== 0xdeadbeef)) || (actual
== expected
);
6291 static void test_SetWindowLong(void)
6294 WNDPROC old_window_procW
;
6296 SetLastError(0xdeadbeef);
6297 retval
= SetWindowLongPtrA(NULL
, GWLP_WNDPROC
, 0);
6298 ok(!retval
, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval
);
6299 ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE
),
6300 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instead of %d\n", GetLastError());
6302 SetLastError(0xdeadbeef);
6303 retval
= SetWindowLongPtrA(hwndMain
, 0xdeadbeef, 0);
6304 ok(!retval
, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval
);
6305 ok(check_error(GetLastError(), ERROR_INVALID_INDEX
),
6306 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instead of %d\n", GetLastError());
6308 SetLastError(0xdeadbeef);
6309 retval
= SetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
, 0);
6310 ok((WNDPROC
)retval
== main_window_procA
,
6311 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval
);
6312 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
6313 retval
= GetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
);
6314 ok((WNDPROC
)retval
== main_window_procA
,
6315 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
6316 ok(!IsWindowUnicode(hwndMain
), "hwndMain shouldn't be Unicode\n");
6318 old_window_procW
= (WNDPROC
)GetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
);
6319 SetLastError(0xdeadbeef);
6320 retval
= SetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
, 0);
6321 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED
)
6323 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
6324 ok(retval
!= 0, "SetWindowLongPtr error %d\n", GetLastError());
6325 ok((WNDPROC
)retval
== old_window_procW
,
6326 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
6327 ok(IsWindowUnicode(hwndMain
), "hwndMain should now be Unicode\n");
6329 /* set it back to ANSI */
6330 SetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
, 0);
6334 static LRESULT WINAPI
check_style_wnd_proc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
6336 const STYLESTRUCT
*expected
= (STYLESTRUCT
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
6337 const STYLESTRUCT
*got
= (STYLESTRUCT
*)lParam
;
6339 if (message
== WM_STYLECHANGING
&& wParam
== GWL_STYLE
)
6341 ok(got
->styleOld
== expected
[0].styleOld
, "expected old style %#x, got %#x\n",
6342 expected
[0].styleOld
, got
->styleOld
);
6343 ok(got
->styleNew
== expected
[0].styleNew
, "expected new style %#x, got %#x\n",
6344 expected
[0].styleNew
, got
->styleNew
);
6346 else if (message
== WM_STYLECHANGED
&& wParam
== GWL_STYLE
)
6348 ok(got
->styleOld
== expected
[1].styleOld
, "expected old style %#x, got %#x\n",
6349 expected
[1].styleOld
, got
->styleOld
);
6350 ok(got
->styleNew
== expected
[1].styleNew
, "expected new style %#x, got %#x\n",
6351 expected
[1].styleNew
, got
->styleNew
);
6354 return DefWindowProcA(hwnd
, message
, wParam
, lParam
);
6357 static void test_set_window_style(void)
6359 LONG expected_style
, new_style
, old_style
;
6360 STYLESTRUCT expected_stylestruct
[2];
6367 LONG creation_style
;
6372 { WS_MINIMIZE
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
,
6373 WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
},
6374 { WS_MINIMIZE
| WS_CLIPSIBLINGS
| WS_CAPTION
,
6375 WS_CLIPSIBLINGS
| WS_CAPTION
},
6376 { WS_MAXIMIZE
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
,
6377 WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
},
6378 { WS_MAXIMIZE
| WS_CLIPSIBLINGS
| WS_CAPTION
,
6379 WS_CLIPSIBLINGS
| WS_CAPTION
},
6380 { WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
,
6381 WS_MINIMIZE
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
},
6382 { WS_CLIPSIBLINGS
| WS_CAPTION
,
6383 WS_MINIMIZE
| WS_CLIPSIBLINGS
| WS_CAPTION
},
6384 { WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
,
6385 WS_MAXIMIZE
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
},
6386 { WS_CLIPSIBLINGS
| WS_CAPTION
,
6387 WS_MAXIMIZE
| WS_CLIPSIBLINGS
| WS_CAPTION
},
6390 memset(&cls
, 0, sizeof(cls
));
6391 cls
.lpfnWndProc
= check_style_wnd_proc
;
6392 cls
.hInstance
= GetModuleHandleA(0);
6393 cls
.lpszClassName
= "TestSetWindowStylesClass";
6394 ok(RegisterClassA(&cls
), "RegisterClass failed\n");
6396 for (i
= 0; i
< sizeof(tests
) / sizeof(*tests
); i
++)
6398 expected_style
= tests
[i
].style
;
6399 if (tests
[i
].creation_style
& WS_MINIMIZE
)
6400 expected_style
|= WS_MINIMIZE
;
6402 expected_stylestruct
[0].styleOld
= tests
[i
].creation_style
;
6403 expected_stylestruct
[0].styleNew
= tests
[i
].style
;
6404 expected_stylestruct
[1].styleOld
= tests
[i
].creation_style
;
6405 expected_stylestruct
[1].styleNew
= expected_style
;
6407 hwnd
= CreateWindowA(cls
.lpszClassName
, "Test set styles",
6408 tests
[i
].creation_style
, 100, 100, 200, 200, 0, 0, 0, NULL
);
6409 ok(hwnd
!= 0, "CreateWindow failed\n");
6410 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, (LONG_PTR
)&expected_stylestruct
);
6412 old_style
= SetWindowLongA(hwnd
, GWL_STYLE
, tests
[i
].style
);
6413 ok(old_style
== tests
[i
].creation_style
, "expected old style %#x, got %#x\n",
6414 tests
[i
].creation_style
, old_style
);
6415 new_style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6416 ok(new_style
== expected_style
, "expected new style %#x, got %#x\n",
6417 expected_style
, new_style
);
6419 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0);
6420 DestroyWindow(hwnd
);
6423 UnregisterClassA(cls
.lpszClassName
, cls
.hInstance
);
6426 static void test_ShowWindow(void)
6430 RECT rcMain
, rc
, rcMinimized
, rcClient
, rcEmpty
, rcMaximized
, rcResized
;
6432 MONITORINFO mon_info
;
6434 SetRect(&rcClient
, 0, 0, 90, 90);
6436 OffsetRect(&rcMain
, 120, 120);
6437 AdjustWindowRect(&rcMain
, WS_CAPTION
, 0);
6438 SetRect(&rcMinimized
, -32000, -32000, -32000 + GetSystemMetrics(SM_CXMINIMIZED
),
6439 -32000 + GetSystemMetrics(SM_CYMINIMIZED
));
6440 SetRectEmpty(&rcEmpty
);
6442 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
6443 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
6444 WS_MAXIMIZEBOX
| WS_POPUP
,
6445 rcMain
.left
, rcMain
.top
,
6446 rcMain
.right
- rcMain
.left
, rcMain
.bottom
- rcMain
.top
,
6450 mon_info
.cbSize
= sizeof(mon_info
);
6451 GetMonitorInfoW(MonitorFromWindow(hwnd
, MONITOR_DEFAULTTOPRIMARY
), &mon_info
);
6452 rcMaximized
= mon_info
.rcWork
;
6453 AdjustWindowRectEx(&rcMaximized
, GetWindowLongA(hwnd
, GWL_STYLE
) & ~WS_BORDER
,
6454 0, GetWindowLongA(hwnd
, GWL_EXSTYLE
));
6456 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6457 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
6458 ok(!(style
& WS_VISIBLE
), "window should not be visible\n");
6459 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
6460 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6461 GetWindowRect(hwnd
, &rc
);
6462 ok(EqualRect(&rcMain
, &rc
), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain
),
6463 wine_dbgstr_rect(&rc
));
6464 GetClientRect(hwnd
, &rc
);
6465 ok(EqualRect(&rcClient
, &rc
), "expected %s, got %s\n",
6466 wine_dbgstr_rect(&rcClient
), wine_dbgstr_rect(&rc
));
6468 ret
= ShowWindow(hwnd
, SW_SHOW
);
6469 ok(!ret
, "not expected ret: %lu\n", ret
);
6470 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6471 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
6472 ok(style
& WS_VISIBLE
, "window should be visible\n");
6473 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
6474 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6475 GetWindowRect(hwnd
, &rc
);
6476 ok(EqualRect(&rcMain
, &rc
), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain
),
6477 wine_dbgstr_rect(&rc
));
6478 GetClientRect(hwnd
, &rc
);
6479 ok(EqualRect(&rcClient
, &rc
), "expected %s, got %s\n",
6480 wine_dbgstr_rect(&rcClient
), wine_dbgstr_rect(&rc
));
6482 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
6483 ok(ret
, "not expected ret: %lu\n", ret
);
6484 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6485 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
6486 ok(style
& WS_VISIBLE
, "window should be visible\n");
6487 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
6488 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6489 GetWindowRect(hwnd
, &rc
);
6491 ok(EqualRect(&rcMinimized
, &rc
), "expected %s, got %s\n",
6492 wine_dbgstr_rect(&rcMinimized
), wine_dbgstr_rect(&rc
));
6493 GetClientRect(hwnd
, &rc
);
6495 ok(EqualRect(&rcEmpty
, &rc
), "expected %s, got %s\n",
6496 wine_dbgstr_rect(&rcEmpty
), wine_dbgstr_rect(&rc
));
6497 /* shouldn't be able to resize minimized windows */
6498 ret
= SetWindowPos(hwnd
, 0, 0, 0,
6499 (rcMinimized
.right
- rcMinimized
.left
) * 2,
6500 (rcMinimized
.bottom
- rcMinimized
.top
) * 2,
6501 SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
6502 ok(ret
, "not expected ret: %lu\n", ret
);
6503 GetWindowRect(hwnd
, &rc
);
6505 ok(EqualRect(&rcMinimized
, &rc
), "expected %s, got %s\n",
6506 wine_dbgstr_rect(&rcMinimized
), wine_dbgstr_rect(&rc
));
6507 GetClientRect(hwnd
, &rc
);
6509 ok(EqualRect(&rcEmpty
, &rc
), "expected %s, got %s\n",
6510 wine_dbgstr_rect(&rcEmpty
), wine_dbgstr_rect(&rc
));
6512 ShowWindow(hwnd
, SW_RESTORE
);
6513 ok(ret
, "not expected ret: %lu\n", ret
);
6514 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6515 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
6516 ok(style
& WS_VISIBLE
, "window should be visible\n");
6517 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
6518 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6519 GetWindowRect(hwnd
, &rc
);
6520 ok(EqualRect(&rcMain
, &rc
), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain
),
6521 wine_dbgstr_rect(&rc
));
6522 GetClientRect(hwnd
, &rc
);
6523 ok(EqualRect(&rcClient
, &rc
), "expected %s, got %s\n",
6524 wine_dbgstr_rect(&rcClient
), wine_dbgstr_rect(&rc
));
6526 ShowWindow(hwnd
, SW_MAXIMIZE
);
6527 ok(ret
, "not expected ret: %lu\n", ret
);
6528 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6529 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
6530 ok(style
& WS_VISIBLE
, "window should be visible\n");
6531 ok(!(style
& WS_MINIMIZE
), "window should be minimized\n");
6532 ok(style
& WS_MAXIMIZE
, "window should not be maximized\n");
6533 GetWindowRect(hwnd
, &rc
);
6534 ok(EqualRect(&rcMaximized
, &rc
), "expected %s, got %s\n",
6535 wine_dbgstr_rect(&rcMaximized
), wine_dbgstr_rect(&rc
));
6536 /* maximized windows can be resized */
6537 ret
= SetWindowPos(hwnd
, 0, 300, 300, 200, 200, SWP_NOACTIVATE
| SWP_NOZORDER
);
6538 ok(ret
, "not expected ret: %lu\n", ret
);
6539 SetRect(&rcResized
, 300, 300, 500, 500);
6540 GetWindowRect(hwnd
, &rc
);
6541 ok(EqualRect(&rcResized
, &rc
), "expected %s, got %s\n",
6542 wine_dbgstr_rect(&rcResized
), wine_dbgstr_rect(&rc
));
6544 ShowWindow(hwnd
, SW_RESTORE
);
6545 ok(ret
, "not expected ret: %lu\n", ret
);
6546 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6547 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
6548 ok(style
& WS_VISIBLE
, "window should be visible\n");
6549 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
6550 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6551 GetWindowRect(hwnd
, &rc
);
6552 ok(EqualRect(&rcMain
, &rc
), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain
),
6553 wine_dbgstr_rect(&rc
));
6555 ret
= EnableWindow(hwnd
, FALSE
);
6556 ok(!ret
, "not expected ret: %lu\n", ret
);
6557 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6558 ok(style
& WS_DISABLED
, "window should be disabled\n");
6560 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
6561 ok(!ret
, "not expected ret: %lu\n", ret
);
6562 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6563 ok(style
& WS_DISABLED
, "window should be disabled\n");
6564 ok(style
& WS_VISIBLE
, "window should be visible\n");
6565 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
6566 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6567 GetWindowRect(hwnd
, &rc
);
6568 ok(EqualRect(&rcMain
, &rc
), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain
),
6569 wine_dbgstr_rect(&rc
));
6570 GetClientRect(hwnd
, &rc
);
6571 ok(EqualRect(&rcClient
, &rc
), "expected %s, got %s\n",
6572 wine_dbgstr_rect(&rcClient
), wine_dbgstr_rect(&rc
));
6574 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_MAXIMIZE
, 0);
6575 ok(!ret
, "not expected ret: %lu\n", ret
);
6576 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6577 ok(style
& WS_DISABLED
, "window should be disabled\n");
6578 ok(style
& WS_VISIBLE
, "window should be visible\n");
6579 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
6580 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6581 GetWindowRect(hwnd
, &rc
);
6582 ok(EqualRect(&rcMain
, &rc
), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain
),
6583 wine_dbgstr_rect(&rc
));
6584 GetClientRect(hwnd
, &rc
);
6585 ok(EqualRect(&rcClient
, &rc
), "expected %s, got %s\n",
6586 wine_dbgstr_rect(&rcClient
), wine_dbgstr_rect(&rc
));
6588 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
6589 ok(ret
, "not expected ret: %lu\n", ret
);
6590 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6591 ok(style
& WS_DISABLED
, "window should be disabled\n");
6592 ok(style
& WS_VISIBLE
, "window should be visible\n");
6593 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
6594 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6595 GetWindowRect(hwnd
, &rc
);
6597 ok(EqualRect(&rcMinimized
, &rc
), "expected %s, got %s\n",
6598 wine_dbgstr_rect(&rcMinimized
), wine_dbgstr_rect(&rc
));
6599 GetClientRect(hwnd
, &rc
);
6601 ok(EqualRect(&rcEmpty
, &rc
), "expected %s, got %s\n",
6602 wine_dbgstr_rect(&rcEmpty
), wine_dbgstr_rect(&rc
));
6604 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0);
6605 ok(!ret
, "not expected ret: %lu\n", ret
);
6606 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6607 ok(style
& WS_DISABLED
, "window should be disabled\n");
6608 ok(style
& WS_VISIBLE
, "window should be visible\n");
6609 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
6610 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6611 GetWindowRect(hwnd
, &rc
);
6613 ok(EqualRect(&rcMinimized
, &rc
), "expected %s, got %s\n",
6614 wine_dbgstr_rect(&rcMinimized
), wine_dbgstr_rect(&rc
));
6615 GetClientRect(hwnd
, &rc
);
6617 ok(EqualRect(&rcEmpty
, &rc
), "expected %s, got %s\n",
6618 wine_dbgstr_rect(&rcEmpty
), wine_dbgstr_rect(&rc
));
6620 ret
= ShowWindow(hwnd
, SW_RESTORE
);
6621 ok(ret
, "not expected ret: %lu\n", ret
);
6622 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6623 ok(style
& WS_DISABLED
, "window should be disabled\n");
6624 ok(style
& WS_VISIBLE
, "window should be visible\n");
6625 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
6626 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
6627 GetWindowRect(hwnd
, &rc
);
6628 ok(EqualRect(&rcMain
, &rc
), "expected %s, got %s\n", wine_dbgstr_rect(&rcMain
),
6629 wine_dbgstr_rect(&rc
));
6630 GetClientRect(hwnd
, &rc
);
6631 ok(EqualRect(&rcClient
, &rc
), "expected %s, got %s\n",
6632 wine_dbgstr_rect(&rcClient
), wine_dbgstr_rect(&rc
));
6634 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
6635 ok(!ret
, "not expected ret: %lu\n", ret
);
6636 ok(IsWindow(hwnd
), "window should exist\n");
6638 ret
= EnableWindow(hwnd
, TRUE
);
6639 ok(ret
, "not expected ret: %lu\n", ret
);
6641 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
6642 ok(!ret
, "not expected ret: %lu\n", ret
);
6643 ok(!IsWindow(hwnd
), "window should not exist\n");
6645 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
6646 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
6647 WS_MAXIMIZEBOX
| WS_POPUP
| WS_MINIMIZE
,
6648 rcMain
.left
, rcMain
.top
,
6649 rcMain
.right
- rcMain
.left
, rcMain
.bottom
- rcMain
.top
,
6651 ok(hwnd
!= NULL
, "failed to create window with error %u\n", GetLastError());
6652 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6653 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
6654 GetWindowRect(hwnd
, &rc
);
6656 ok(EqualRect(&rcMinimized
, &rc
), "expected %s, got %s\n",
6657 wine_dbgstr_rect(&rcMinimized
), wine_dbgstr_rect(&rc
));
6658 GetClientRect(hwnd
, &rc
);
6660 ok(EqualRect(&rcEmpty
, &rc
), "expected %s, got %s\n",
6661 wine_dbgstr_rect(&rcEmpty
), wine_dbgstr_rect(&rc
));
6662 DestroyWindow(hwnd
);
6664 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
6665 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
6666 WS_MAXIMIZEBOX
| WS_POPUP
| WS_MINIMIZE
| WS_VISIBLE
,
6667 rcMain
.left
, rcMain
.top
,
6668 rcMain
.right
- rcMain
.left
, rcMain
.bottom
- rcMain
.top
,
6670 ok(hwnd
!= NULL
, "failed to create window with error %u\n", GetLastError());
6671 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
6672 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
6673 GetWindowRect(hwnd
, &rc
);
6675 ok(EqualRect(&rcMinimized
, &rc
), "expected %s, got %s\n",
6676 wine_dbgstr_rect(&rcMinimized
), wine_dbgstr_rect(&rc
));
6677 GetClientRect(hwnd
, &rc
);
6679 ok(EqualRect(&rcEmpty
, &rc
), "expected %s, got %s\n",
6680 wine_dbgstr_rect(&rcEmpty
), wine_dbgstr_rect(&rc
));
6681 DestroyWindow(hwnd
);
6686 static DWORD CALLBACK
enablewindow_thread(LPVOID arg
)
6689 EnableWindow(hwnd
, FALSE
);
6693 static LRESULT CALLBACK
enable_window_procA(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
6695 if (msg
== WM_CANCELMODE
)
6697 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
6700 static void test_EnableWindow(void)
6708 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
6709 0, 0, 100, 100, 0, 0, 0, NULL
);
6711 ok(IsWindowEnabled(hwnd
), "window should be enabled\n");
6715 EnableWindow(hwnd
, FALSE
);
6716 check_wnd_state(hwnd
, hwnd
, 0, 0);
6717 ok(!IsWindowEnabled(hwnd
), "window should not be enabled\n");
6721 check_wnd_state(hwnd
, hwnd
, 0, hwnd
);
6723 EnableWindow(hwnd
, TRUE
);
6725 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
6726 ok(IsWindowEnabled(hwnd
), "window should be enabled\n");
6728 /* test disabling from thread */
6729 hthread
= CreateThread(NULL
, 0, enablewindow_thread
, hwnd
, 0, &tid
);
6731 while (MsgWaitForMultipleObjects(1, &hthread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
6733 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
))
6734 DispatchMessageA(&msg
);
6737 ok(!IsWindowEnabled(hwnd
), "window should not be enabled\n");
6738 check_active_state(hwnd
, hwnd
, hwnd
);
6739 ok(0 == GetCapture(), "GetCapture() = %p\n", GetCapture());
6741 CloseHandle(hthread
);
6742 DestroyWindow(hwnd
);
6744 /* test preventing release of capture */
6745 memset(&cls
, 0, sizeof(cls
));
6746 cls
.lpfnWndProc
= enable_window_procA
;
6747 cls
.hInstance
= GetModuleHandleA(0);
6748 cls
.lpszClassName
= "EnableWindowClass";
6749 ok(RegisterClassA(&cls
), "RegisterClass failed\n");
6751 hwnd
= CreateWindowExA(0, "EnableWindowClass", NULL
, WS_OVERLAPPEDWINDOW
,
6752 0, 0, 100, 100, 0, 0, 0, NULL
);
6757 EnableWindow(hwnd
, FALSE
);
6758 check_wnd_state(hwnd
, hwnd
, 0, hwnd
);
6760 DestroyWindow(hwnd
);
6763 static DWORD CALLBACK
gettext_msg_thread( LPVOID arg
)
6769 /* test GetWindowTextA */
6770 num_gettext_msgs
= 0;
6771 memset( buf
, 0, sizeof(buf
) );
6772 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
6773 ok( buf_len
!= 0, "expected a nonempty window text\n" );
6774 ok( !strcmp(buf
, "another_caption"), "got wrong window text '%s'\n", buf
);
6775 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6780 static DWORD CALLBACK
settext_msg_thread( LPVOID arg
)
6785 /* test SetWindowTextA */
6786 num_settext_msgs
= 0;
6787 success
= SetWindowTextA( hwnd
, "thread_caption" );
6788 ok( success
, "SetWindowTextA failed\n" );
6789 ok( num_settext_msgs
== 1, "got %u WM_SETTEXT messages\n", num_settext_msgs
);
6794 static void test_gettext(void)
6796 static const WCHAR textW
[] = {'t','e','x','t'};
6797 DWORD tid
, num_msgs
;
6807 hwnd
= CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP
, 0, 0, 0, 0, 0, 0, 0, NULL
);
6808 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6810 /* test GetWindowTextA */
6811 num_gettext_msgs
= 0;
6812 memset( buf
, 0, sizeof(buf
) );
6813 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
6814 ok( buf_len
!= 0, "expected a nonempty window text\n" );
6815 ok( !strcmp(buf
, "caption"), "got wrong window text '%s'\n", buf
);
6816 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6818 /* other process window */
6820 buf_len
= GetWindowTextA( GetDesktopWindow(), buf
, sizeof(buf
) );
6821 ok( buf_len
== 0, "expected a nonempty window text\n" );
6822 ok( *buf
== 0, "got wrong window text '%s'\n", buf
);
6824 strcpy( buf
, "blah" );
6825 buf_len
= GetWindowTextA( GetDesktopWindow(), buf
, 0 );
6826 ok( buf_len
== 0, "expected a nonempty window text\n" );
6827 ok( !strcmp(buf
, "blah"), "got wrong window text '%s'\n", buf
);
6830 buf_len
= GetWindowTextW( GetDesktopWindow(), bufW
, 0 );
6831 ok( buf_len
== 0, "expected a nonempty window text\n" );
6832 ok( bufW
[0] == 0xcc, "got %x\n", bufW
[0] );
6834 g_wm_gettext_override
.enabled
= TRUE
;
6836 num_gettext_msgs
= 0;
6837 memset( buf
, 0xcc, sizeof(buf
) );
6838 g_wm_gettext_override
.buff
= buf
;
6839 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
6840 ok( buf_len
== 0, "got %d\n", buf_len
);
6841 ok( *buf
== 0, "got %x\n", *buf
);
6842 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6844 num_gettext_msgs
= 0;
6845 strcpy( buf
, "blah" );
6846 g_wm_gettext_override
.buff
= buf
;
6847 buf_len
= GetWindowTextA( hwnd
, buf
, 0 );
6848 ok( buf_len
== 0, "got %d\n", buf_len
);
6849 ok( !strcmp(buf
, "blah"), "got %s\n", buf
);
6850 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6852 g_wm_gettext_override
.enabled
= FALSE
;
6854 /* same for W window */
6855 hwnd2
= CreateWindowExW( 0, mainclassW
, NULL
, WS_POPUP
, 0, 0, 0, 0, 0, 0, 0, NULL
);
6856 ok( hwnd2
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6858 g_wm_gettext_override
.enabled
= TRUE
;
6860 num_gettext_msgs
= 0;
6861 memset( bufW
, 0xcc, sizeof(bufW
) );
6862 g_wm_gettext_override
.buffW
= bufW
;
6863 buf_len
= GetWindowTextW( hwnd2
, bufW
, sizeof(bufW
)/sizeof(WCHAR
) );
6864 ok( buf_len
== 0, "got %d\n", buf_len
);
6865 ok( *bufW
== 0, "got %x\n", *bufW
);
6866 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6868 num_gettext_msgs
= 0;
6869 memset( bufW
, 0xcc, sizeof(bufW
) );
6870 g_wm_gettext_override
.buffW
= bufW
;
6871 buf_len
= GetWindowTextW( hwnd2
, bufW
, 0 );
6872 ok( buf_len
== 0, "got %d\n", buf_len
);
6873 ok( *bufW
== 0xcccc, "got %x\n", *bufW
);
6874 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6876 g_wm_gettext_override
.enabled
= FALSE
;
6878 DestroyWindow( hwnd2
);
6880 /* test WM_GETTEXT */
6881 num_gettext_msgs
= 0;
6882 memset( buf
, 0, sizeof(buf
) );
6883 r
= SendMessageA( hwnd
, WM_GETTEXT
, sizeof(buf
), (LONG_PTR
)buf
);
6884 ok( r
!= 0, "expected a nonempty window text\n" );
6885 ok( !strcmp(buf
, "caption"), "got wrong window text '%s'\n", buf
);
6886 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6888 /* test SetWindowTextA */
6889 num_settext_msgs
= 0;
6890 success
= SetWindowTextA( hwnd
, "new_caption" );
6891 ok( success
, "SetWindowTextA failed\n" );
6892 ok( num_settext_msgs
== 1, "got %u WM_SETTEXT messages\n", num_settext_msgs
);
6894 num_gettext_msgs
= 0;
6895 memset( buf
, 0, sizeof(buf
) );
6896 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
6897 ok( buf_len
!= 0, "expected a nonempty window text\n" );
6898 ok( !strcmp(buf
, "new_caption"), "got wrong window text '%s'\n", buf
);
6899 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6901 /* test WM_SETTEXT */
6902 num_settext_msgs
= 0;
6903 r
= SendMessageA( hwnd
, WM_SETTEXT
, 0, (ULONG_PTR
)"another_caption" );
6904 ok( r
!= 0, "WM_SETTEXT failed\n" );
6905 ok( num_settext_msgs
== 1, "got %u WM_SETTEXT messages\n", num_settext_msgs
);
6907 num_gettext_msgs
= 0;
6908 memset( buf
, 0, sizeof(buf
) );
6909 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
6910 ok( buf_len
!= 0, "expected a nonempty window text\n" );
6911 ok( !strcmp(buf
, "another_caption"), "got wrong window text '%s'\n", buf
);
6912 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6914 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
))
6915 DispatchMessageA( &msg
);
6917 /* test interthread GetWindowTextA */
6919 thread
= CreateThread( NULL
, 0, gettext_msg_thread
, hwnd
, 0, &tid
);
6920 ok(thread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6921 while (MsgWaitForMultipleObjects( 1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
6923 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
))
6924 DispatchMessageA( &msg
);
6927 CloseHandle( thread
);
6928 ok( num_msgs
>= 1, "got %u wakeups from MsgWaitForMultipleObjects\n", num_msgs
);
6930 /* test interthread SetWindowText */
6932 thread
= CreateThread( NULL
, 0, settext_msg_thread
, hwnd
, 0, &tid
);
6933 ok(thread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
6934 while (MsgWaitForMultipleObjects( 1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
6936 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
))
6937 DispatchMessageA( &msg
);
6940 CloseHandle( thread
);
6941 ok( num_msgs
>= 1, "got %u wakeups from MsgWaitForMultipleObjects\n", num_msgs
);
6943 num_gettext_msgs
= 0;
6944 memset( buf
, 0, sizeof(buf
) );
6945 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
6946 ok( buf_len
!= 0, "expected a nonempty window text\n" );
6947 ok( !strcmp(buf
, "thread_caption"), "got wrong window text '%s'\n", buf
);
6948 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
6950 /* WM_GETTEXT does not terminate returned string */
6951 memset( buf
, 0x1c, sizeof(buf
) );
6952 g_wm_gettext_override
.dont_terminate
= TRUE
;
6953 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
6954 ok( buf_len
== 4, "Unexpected text length, %d\n", buf_len
);
6955 ok( !memcmp(buf
, "text", 4), "Unexpected window text, '%s'\n", buf
);
6956 ok( buf
[4] == 0x1c, "Unexpected buffer contents\n" );
6957 g_wm_gettext_override
.dont_terminate
= FALSE
;
6959 memset( bufW
, 0x1c, sizeof(bufW
) );
6960 g_wm_gettext_override
.dont_terminate
= TRUE
;
6961 buf_len
= GetWindowTextW( hwnd
, bufW
, sizeof(bufW
)/sizeof(bufW
[0]) );
6962 ok( buf_len
== 4, "Unexpected text length, %d\n", buf_len
);
6963 ok( !memcmp(bufW
, textW
, 4 * sizeof(WCHAR
)), "Unexpected window text, %s\n", wine_dbgstr_w(bufW
) );
6964 ok( bufW
[4] == 0, "Unexpected buffer contents, %#x\n", bufW
[4] );
6965 g_wm_gettext_override
.dont_terminate
= FALSE
;
6967 hwnd2
= CreateWindowExW( 0, mainclassW
, NULL
, WS_POPUP
, 0, 0, 0, 0, 0, 0, 0, NULL
);
6968 ok( hwnd2
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6970 memset( buf
, 0x1c, sizeof(buf
) );
6971 g_wm_gettext_override
.dont_terminate
= TRUE
;
6972 buf_len
= GetWindowTextA( hwnd2
, buf
, sizeof(buf
) );
6973 ok( buf_len
== 4, "Unexpected text length, %d\n", buf_len
);
6974 ok( !memcmp(buf
, "text", 4), "Unexpected window text, '%s'\n", buf
);
6975 ok( buf
[4] == 0, "Unexpected buffer contents, %#x\n", buf
[4] );
6976 g_wm_gettext_override
.dont_terminate
= FALSE
;
6978 memset( bufW
, 0x1c, sizeof(bufW
) );
6979 g_wm_gettext_override
.dont_terminate
= TRUE
;
6980 buf_len
= GetWindowTextW( hwnd2
, bufW
, sizeof(bufW
)/sizeof(bufW
[0]) );
6981 ok( buf_len
== 4, "Unexpected text length, %d\n", buf_len
);
6982 ok( !memcmp(bufW
, textW
, 4 * sizeof(WCHAR
)), "Unexpected window text, %s\n", wine_dbgstr_w(bufW
) );
6983 ok( bufW
[4] == 0x1c1c, "Unexpected buffer contents, %#x\n", bufW
[4] );
6984 g_wm_gettext_override
.dont_terminate
= FALSE
;
6986 DestroyWindow(hwnd2
);
6988 /* seems to crash on every modern Windows version */
6991 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x10, 0x1000);
6992 ok( r
== 0, "settext should return zero\n");
6994 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x10000, 0);
6995 ok( r
== 0, "settext should return zero (%ld)\n", r
);
6997 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0xff000000, 0x1000);
6998 ok( r
== 0, "settext should return zero (%ld)\n", r
);
7000 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x1000, 0xff000000);
7001 ok( r
== 0, "settext should return zero (%ld)\n", r
);
7004 DestroyWindow(hwnd
);
7008 static void test_GetUpdateRect(void)
7011 BOOL ret
, parent_wm_paint
, grandparent_wm_paint
;
7013 HWND hgrandparent
, hparent
, hchild
;
7015 static const char classNameA
[] = "GetUpdateRectClass";
7017 hgrandparent
= CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW
,
7018 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
7020 hparent
= CreateWindowA("static", "parent", WS_CHILD
|WS_VISIBLE
,
7021 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
7023 hchild
= CreateWindowA("static", "child", WS_CHILD
|WS_VISIBLE
,
7024 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
7026 ShowWindow(hgrandparent
, SW_SHOW
);
7027 UpdateWindow(hgrandparent
);
7028 flush_events( TRUE
);
7030 ShowWindow(hchild
, SW_HIDE
);
7032 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
7033 ok(!ret
, "GetUpdateRect returned not empty region\n");
7034 ok(EqualRect(&rc1
, &rc2
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1
),
7035 wine_dbgstr_rect(&rc2
));
7037 SetRect(&rc2
, 10, 10, 40, 40);
7038 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
7039 ok(ret
, "GetUpdateRect returned empty region\n");
7040 ok(EqualRect(&rc1
, &rc2
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1
),
7041 wine_dbgstr_rect(&rc2
));
7043 parent_wm_paint
= FALSE
;
7044 grandparent_wm_paint
= FALSE
;
7045 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
7047 if (msg
.message
== WM_PAINT
)
7049 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
7050 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
7052 DispatchMessageA(&msg
);
7054 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
7055 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
7057 DestroyWindow(hgrandparent
);
7060 cls
.lpfnWndProc
= DefWindowProcA
;
7063 cls
.hInstance
= GetModuleHandleA(0);
7065 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
7066 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7067 cls
.lpszMenuName
= NULL
;
7068 cls
.lpszClassName
= classNameA
;
7069 ret
= RegisterClassA(&cls
);
7070 ok(ret
, "Failed to register a test class.\n");
7072 hgrandparent
= CreateWindowA(classNameA
, "grandparent", WS_OVERLAPPEDWINDOW
,
7073 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
7075 hparent
= CreateWindowA(classNameA
, "parent", WS_CHILD
|WS_VISIBLE
,
7076 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
7078 hchild
= CreateWindowA(classNameA
, "child", WS_CHILD
|WS_VISIBLE
,
7079 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
7081 ShowWindow(hgrandparent
, SW_SHOW
);
7082 UpdateWindow(hgrandparent
);
7083 flush_events( TRUE
);
7085 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
7086 ok(!ret
, "GetUpdateRect returned not empty region\n");
7088 ShowWindow(hchild
, SW_HIDE
);
7091 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
7092 ok(!ret
, "GetUpdateRect returned not empty region\n");
7093 ok(EqualRect(&rc1
, &rc2
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1
),
7094 wine_dbgstr_rect(&rc2
));
7096 SetRect(&rc2
, 10, 10, 40, 40);
7097 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
7098 ok(ret
, "GetUpdateRect returned empty region\n");
7099 ok(EqualRect(&rc1
, &rc2
), "rects do not match %s / %s\n", wine_dbgstr_rect(&rc1
),
7100 wine_dbgstr_rect(&rc2
));
7102 parent_wm_paint
= FALSE
;
7103 grandparent_wm_paint
= FALSE
;
7104 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
7106 if (msg
.message
== WM_PAINT
)
7108 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
7109 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
7111 DispatchMessageA(&msg
);
7113 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
7114 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
7116 DestroyWindow(hgrandparent
);
7120 static LRESULT CALLBACK
TestExposedRegion_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7128 const int waitTime
= 2000;
7130 BeginPaint(hwnd
, &ps
);
7132 /* create and destroy window to create an exposed region on this window */
7133 win
= CreateWindowA("static", "win", WS_VISIBLE
,
7134 10,10,50,50, NULL
, NULL
, 0, NULL
);
7137 waitResult
= MsgWaitForMultipleObjects( 0, NULL
, FALSE
, waitTime
, QS_PAINT
);
7139 ValidateRect(hwnd
, NULL
);
7140 EndPaint(hwnd
, &ps
);
7142 if(waitResult
!= WAIT_TIMEOUT
)
7144 GetUpdateRect(hwnd
, &updateRect
, FALSE
);
7145 ok(IsRectEmpty(&updateRect
), "Exposed rect should be empty\n");
7150 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
7153 static void test_Expose(void)
7158 memset(&cls
, 0, sizeof(WNDCLASSA
));
7159 cls
.lpfnWndProc
= TestExposedRegion_WndProc
;
7160 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7161 cls
.lpszClassName
= "TestExposeClass";
7162 RegisterClassA(&cls
);
7164 mw
= CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
7165 0, 0, 200, 100, NULL
, NULL
, 0, NULL
);
7171 static LRESULT CALLBACK
TestNCRedraw_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
7173 static UINT ncredrawflags
;
7179 ncredrawflags
= *(UINT
*) (((CREATESTRUCTA
*)lParam
)->lpCreateParams
);
7182 RedrawWindow(hwnd
, NULL
, NULL
, ncredrawflags
);
7185 BeginPaint(hwnd
, &ps
);
7186 EndPaint(hwnd
, &ps
);
7189 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
7192 static void run_NCRedrawLoop(UINT flags
)
7199 hwnd
= CreateWindowA("TestNCRedrawClass", "MainWindow",
7200 WS_OVERLAPPEDWINDOW
, 0, 0, 200, 100,
7201 NULL
, NULL
, 0, &flags
);
7202 ShowWindow(hwnd
, SW_SHOW
);
7204 flush_events( FALSE
);
7205 while (PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
))
7207 if (msg
.message
== WM_PAINT
) loopcount
++;
7208 if (loopcount
>= 100) break;
7209 TranslateMessage(&msg
);
7210 DispatchMessageA(&msg
);
7211 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, QS_ALLINPUT
);
7213 todo_wine_if (flags
== (RDW_INVALIDATE
| RDW_FRAME
))
7214 ok(loopcount
< 100, "Detected infinite WM_PAINT loop (%x).\n", flags
);
7215 DestroyWindow(hwnd
);
7218 static void test_NCRedraw(void)
7222 wndclass
.lpszClassName
= "TestNCRedrawClass";
7223 wndclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
7224 wndclass
.lpfnWndProc
= TestNCRedraw_WndProc
;
7225 wndclass
.cbClsExtra
= 0;
7226 wndclass
.cbWndExtra
= 0;
7227 wndclass
.hInstance
= 0;
7228 wndclass
.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
7229 wndclass
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
7230 wndclass
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7231 wndclass
.lpszMenuName
= NULL
;
7233 RegisterClassA(&wndclass
);
7235 run_NCRedrawLoop(RDW_INVALIDATE
| RDW_FRAME
);
7236 run_NCRedrawLoop(RDW_INVALIDATE
);
7239 static void test_GetWindowModuleFileName(void)
7244 char buf1
[MAX_PATH
], buf2
[MAX_PATH
];
7246 if (!pGetWindowModuleFileNameA
)
7248 win_skip("GetWindowModuleFileNameA is not available\n");
7252 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
7255 hinst
= (HINSTANCE
)GetWindowLongPtrA(hwnd
, GWLP_HINSTANCE
);
7256 ok(hinst
== 0, "expected 0, got %p\n", hinst
);
7259 SetLastError(0xdeadbeef);
7260 ret1
= GetModuleFileNameA(hinst
, buf1
, sizeof(buf1
));
7261 ok(ret1
, "GetModuleFileName error %u\n", GetLastError());
7264 SetLastError(0xdeadbeef);
7265 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
7266 ok(ret2
, "GetWindowModuleFileNameA error %u\n", GetLastError());
7270 ok(ret1
== ret2
, "%u != %u\n", ret1
, ret2
);
7271 ok(!strcmp(buf1
, buf2
), "%s != %s\n", buf1
, buf2
);
7273 hinst
= GetModuleHandleA(NULL
);
7275 SetLastError(0xdeadbeef);
7276 ret2
= GetModuleFileNameA(hinst
, buf2
, ret1
- 2);
7277 ok(ret2
== ret1
- 2, "expected %u, got %u\n", ret1
- 2, ret2
);
7278 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7279 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
7280 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7282 SetLastError(0xdeadbeef);
7283 ret2
= GetModuleFileNameA(hinst
, buf2
, 0);
7284 ok(!ret2
, "GetModuleFileName should return 0\n");
7285 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7286 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
7287 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7289 SetLastError(0xdeadbeef);
7290 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, ret1
- 2);
7291 ok(ret2
== ret1
- 2, "expected %u, got %u\n", ret1
- 2, ret2
);
7292 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7293 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
7294 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7296 SetLastError(0xdeadbeef);
7297 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, 0);
7298 ok(!ret2
, "expected 0, got %u\n", ret2
);
7299 ok(GetLastError() == 0xdeadbeef /* XP */ ||
7300 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
7301 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
7303 DestroyWindow(hwnd
);
7306 hwnd
= (HWND
)0xdeadbeef;
7307 SetLastError(0xdeadbeef);
7308 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
7309 ok(!ret1
, "expected 0, got %u\n", ret1
);
7310 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
,
7311 "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
7313 hwnd
= FindWindowA("Shell_TrayWnd", NULL
);
7314 ok(IsWindow(hwnd
) || broken(!hwnd
), "got invalid tray window %p\n", hwnd
);
7315 SetLastError(0xdeadbeef);
7316 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
7317 ok(!ret1
, "expected 0, got %u\n", ret1
);
7318 ret1
= GetModuleFileNameA(0, buf1
, sizeof(buf1
));
7319 hwnd
= GetDesktopWindow();
7320 ok(IsWindow(hwnd
), "got invalid desktop window %p\n", hwnd
);
7321 SetLastError(0xdeadbeef);
7322 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
7324 ret1
== ret2
, /* vista */
7325 "expected 0 or %u, got %u %s\n", ret1
, ret2
, buf2
);
7328 static void test_hwnd_message(void)
7330 static const WCHAR mainwindowclassW
[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
7331 static const WCHAR message_windowW
[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
7333 HWND parent
= 0, hwnd
, found
;
7343 { GWLP_USERDATA
, 0, 0 },
7344 { GWL_STYLE
, WS_POPUP
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
, 0 },
7345 { GWL_EXSTYLE
, 0, 0 },
7347 /* GWLP_HWNDPARENT - returns random values */
7348 /* GWLP_HINSTANCE - not useful and not consistent between Windows versions */
7349 { GWLP_WNDPROC
, 0, ERROR_ACCESS_DENIED
},
7350 { DWLP_MSGRESULT
, 0, ERROR_INVALID_INDEX
}
7355 hwnd
= CreateWindowExW(0, mainwindowclassW
, message_windowW
, WS_CAPTION
| WS_VISIBLE
,
7356 100, 100, 200, 200, HWND_MESSAGE
, 0, 0, NULL
);
7357 ok( hwnd
!= 0, "CreateWindowExW with parent HWND_MESSAGE failed\n" );
7358 ok( !GetParent(hwnd
), "GetParent should return 0 for message only windows\n" );
7362 HWND root
, desktop
= GetDesktopWindow();
7364 parent
= pGetAncestor(hwnd
, GA_PARENT
);
7365 ok(parent
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
7366 ok(parent
!= desktop
, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
7367 root
= pGetAncestor(hwnd
, GA_ROOT
);
7368 ok(root
== hwnd
, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
7369 ok( !pGetAncestor(parent
, GA_PARENT
),
7370 "parent shouldn't have parent %p\n", pGetAncestor(parent
, GA_PARENT
) );
7371 if (!GetClassNameA( parent
, buffer
, sizeof(buffer
) )) buffer
[0] = 0;
7372 ok( !lstrcmpiA( buffer
, "Message" ), "wrong parent class '%s'\n", buffer
);
7373 GetWindowRect( parent
, &rect
);
7374 ok( rect
.left
== 0 && rect
.right
== 100 && rect
.top
== 0 && rect
.bottom
== 100,
7375 "wrong parent rect %s\n", wine_dbgstr_rect( &rect
));
7377 GetWindowRect( hwnd
, &rect
);
7378 ok( rect
.left
== 100 && rect
.right
== 300 && rect
.top
== 100 && rect
.bottom
== 300,
7379 "wrong window rect %s\n", wine_dbgstr_rect( &rect
));
7381 /* test FindWindow behavior */
7383 found
= FindWindowExA( 0, 0, 0, "message window" );
7384 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
7385 SetLastError(0xdeadbeef);
7386 found
= FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
7387 ok( found
== 0, "found message window %p/%p\n", found
, hwnd
);
7388 ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %d\n", GetLastError() );
7391 found
= FindWindowExA( parent
, 0, 0, "message window" );
7392 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
7395 /* test IsChild behavior */
7397 if (parent
) ok( !IsChild( parent
, hwnd
), "HWND_MESSAGE is child of top window\n" );
7399 /* test IsWindowVisible behavior */
7401 ok( !IsWindowVisible( hwnd
), "HWND_MESSAGE window is visible\n" );
7402 if (parent
) ok( !IsWindowVisible( parent
), "HWND_MESSAGE parent is visible\n" );
7405 for (i
= 0; i
< sizeof(tests
) / sizeof(tests
[0]); i
++)
7407 SetLastError( 0xdeadbeef );
7408 result
= GetWindowLongPtrW( parent
, tests
[i
].offset
);
7409 ok( result
== tests
[i
].expect
, "offset %d, got %08lx expect %08lx\n",
7410 tests
[i
].offset
, result
, tests
[i
].expect
);
7412 ok( GetLastError() == tests
[i
].error
, "offset %d: error %d expect %d\n",
7413 tests
[i
].offset
, GetLastError(), tests
[i
].error
);
7415 ok( GetLastError() == 0xdeadbeef, "offset %d: error %d expect unchanged\n",
7416 tests
[i
].offset
, GetLastError() );
7419 DestroyWindow(hwnd
);
7422 static void test_layered_window(void)
7428 POINT pt
= { 0, 0 };
7429 SIZE sz
= { 200, 200 };
7435 if (!pGetLayeredWindowAttributes
|| !pSetLayeredWindowAttributes
|| !pUpdateLayeredWindow
)
7437 win_skip( "layered windows not supported\n" );
7441 hdc
= CreateCompatibleDC( 0 );
7442 hbm
= CreateCompatibleBitmap( hdc
, 200, 200 );
7443 SelectObject( hdc
, hbm
);
7445 hwnd
= CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION
,
7446 100, 100, 200, 200, 0, 0, 0, NULL
);
7448 SetLastError( 0xdeadbeef );
7449 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
7450 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
7451 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
7452 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7453 ok( !ret
, "GetLayeredWindowAttributes should fail on non-layered window\n" );
7454 ret
= pSetLayeredWindowAttributes( hwnd
, 0, 0, LWA_ALPHA
);
7455 ok( !ret
, "SetLayeredWindowAttributes should fail on non-layered window\n" );
7456 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
7457 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7458 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
7459 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
7460 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
7461 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7462 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
7463 ret
= pSetLayeredWindowAttributes( hwnd
, 0x123456, 44, LWA_ALPHA
);
7464 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
7465 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7466 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
7467 ok( key
== 0x123456 || key
== 0, "wrong color key %x\n", key
);
7468 ok( alpha
== 44, "wrong alpha %u\n", alpha
);
7469 ok( flags
== LWA_ALPHA
, "wrong flags %x\n", flags
);
7470 SetLastError( 0xdeadbeef );
7471 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
7472 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
7473 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
7475 /* clearing WS_EX_LAYERED resets attributes */
7476 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
7477 SetLastError( 0xdeadbeef );
7478 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
7479 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
7480 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7481 ok( !ret
, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
7482 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
7483 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7484 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
7485 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
7486 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
7487 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
| ULW_EX_NORESIZE
);
7488 ok( !ret
, "UpdateLayeredWindow should fail with ex flag\n" );
7489 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
7490 if (pUpdateLayeredWindowIndirect
)
7492 UPDATELAYEREDWINDOWINFO info
;
7493 info
.cbSize
= sizeof(info
);
7501 info
.dwFlags
= ULW_OPAQUE
| ULW_EX_NORESIZE
;
7502 info
.prcDirty
= NULL
;
7503 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
7504 ok( ret
, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
7507 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
7508 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
7509 /* particular error code differs from version to version, could be ERROR_INCORRECT_SIZE,
7510 ERROR_MR_MID_NOT_FOUND or ERROR_GEN_FAILURE (Win8/Win10) */
7511 ok( GetLastError() != 0, "wrong error %u\n", GetLastError() );
7512 info
.dwFlags
= ULW_OPAQUE
;
7513 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
7514 ok( ret
, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
7516 info
.dwFlags
= ULW_OPAQUE
| 0xf00;
7517 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
7518 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
7519 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
7521 info
.dwFlags
= ULW_OPAQUE
;
7522 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
7523 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
7524 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
7525 ret
= pUpdateLayeredWindowIndirect( hwnd
, NULL
);
7526 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
7527 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
7530 ret
= pSetLayeredWindowAttributes( hwnd
, 0x654321, 22, LWA_COLORKEY
| LWA_ALPHA
);
7531 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
7532 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7533 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
7534 ok( key
== 0x654321, "wrong color key %x\n", key
);
7535 ok( alpha
== 22, "wrong alpha %u\n", alpha
);
7536 ok( flags
== (LWA_COLORKEY
| LWA_ALPHA
), "wrong flags %x\n", flags
);
7537 SetLastError( 0xdeadbeef );
7538 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
7539 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
7540 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
7542 ret
= pSetLayeredWindowAttributes( hwnd
, 0x888888, 33, LWA_COLORKEY
);
7543 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
7545 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7546 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
7547 ok( key
== 0x888888, "wrong color key %x\n", key
);
7548 /* alpha not changed on vista if LWA_ALPHA is not set */
7549 ok( alpha
== 22 || alpha
== 33, "wrong alpha %u\n", alpha
);
7550 ok( flags
== LWA_COLORKEY
, "wrong flags %x\n", flags
);
7552 /* color key may or may not be changed without LWA_COLORKEY */
7553 ret
= pSetLayeredWindowAttributes( hwnd
, 0x999999, 44, 0 );
7554 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
7556 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7557 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
7558 ok( key
== 0x888888 || key
== 0x999999, "wrong color key %x\n", key
);
7559 ok( alpha
== 22 || alpha
== 44, "wrong alpha %u\n", alpha
);
7560 ok( flags
== 0, "wrong flags %x\n", flags
);
7562 /* default alpha and color key is 0 */
7563 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
7564 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
7565 ret
= pSetLayeredWindowAttributes( hwnd
, 0x222222, 55, 0 );
7566 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
7567 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
7568 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
7569 ok( key
== 0 || key
== 0x222222, "wrong color key %x\n", key
);
7570 ok( alpha
== 0 || alpha
== 55, "wrong alpha %u\n", alpha
);
7571 ok( flags
== 0, "wrong flags %x\n", flags
);
7573 /* test layered window with WS_CLIPCHILDREN flag */
7574 SetWindowLongA( hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) | WS_CLIPCHILDREN
);
7575 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
7576 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
7577 child
= CreateWindowExA( 0, "button", "button", WS_VISIBLE
| WS_CHILD
,
7578 0, 0, 50, 50, hwnd
, 0, 0, NULL
);
7579 ok( child
!= NULL
, "CreateWindowEx error %u\n", GetLastError() );
7580 ShowWindow( hwnd
, SW_SHOW
);
7582 ret
= pSetLayeredWindowAttributes( hwnd
, 0, 255, LWA_ALPHA
);
7583 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
7584 while (GetMessageA(&msg
, 0, 0, 0))
7586 DispatchMessageA(&msg
);
7588 if (msg
.message
== WM_PAINT
&& msg
.hwnd
== child
)
7592 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
7593 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
7594 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
7595 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
7597 ret
= pSetLayeredWindowAttributes( hwnd
, 0, 255, LWA_ALPHA
);
7598 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
7599 while (GetMessageA(&msg
, 0, 0, 0))
7601 DispatchMessageA(&msg
);
7603 if (msg
.message
== WM_PAINT
&& msg
.hwnd
== child
)
7607 DestroyWindow( hwnd
);
7609 DeleteObject( hbm
);
7612 static MONITORINFO mi
;
7614 static LRESULT CALLBACK
fullscreen_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7620 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
7621 ok(cs
->x
== mi
.rcMonitor
.left
&& cs
->y
== mi
.rcMonitor
.top
&&
7622 cs
->cx
== mi
.rcMonitor
.right
&& cs
->cy
== mi
.rcMonitor
.bottom
,
7623 "expected %s, got (%d,%d)-(%d,%d)\n", wine_dbgstr_rect(&mi
.rcMonitor
),
7624 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
7627 case WM_GETMINMAXINFO
:
7629 MINMAXINFO
*minmax
= (MINMAXINFO
*)lp
;
7630 ok(minmax
->ptMaxPosition
.x
<= mi
.rcMonitor
.left
, "%d <= %d\n", minmax
->ptMaxPosition
.x
, mi
.rcMonitor
.left
);
7631 ok(minmax
->ptMaxPosition
.y
<= mi
.rcMonitor
.top
, "%d <= %d\n", minmax
->ptMaxPosition
.y
, mi
.rcMonitor
.top
);
7632 ok(minmax
->ptMaxSize
.x
>= mi
.rcMonitor
.right
, "%d >= %d\n", minmax
->ptMaxSize
.x
, mi
.rcMonitor
.right
);
7633 ok(minmax
->ptMaxSize
.y
>= mi
.rcMonitor
.bottom
, "%d >= %d\n", minmax
->ptMaxSize
.y
, mi
.rcMonitor
.bottom
);
7637 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
7640 static void test_fullscreen(void)
7642 static const DWORD t_style
[] = {
7643 WS_OVERLAPPED
, WS_POPUP
, WS_CHILD
, WS_THICKFRAME
, WS_DLGFRAME
7645 static const DWORD t_ex_style
[] = {
7646 0, WS_EX_APPWINDOW
, WS_EX_TOOLWINDOW
7656 if (!pGetMonitorInfoA
|| !pMonitorFromPoint
)
7658 win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
7663 SetLastError(0xdeadbeef);
7664 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
7665 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
7667 mi
.cbSize
= sizeof(mi
);
7668 SetLastError(0xdeadbeef);
7669 ret
= pGetMonitorInfoA(hmon
, &mi
);
7670 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
7671 trace("monitor %s, work %s\n", wine_dbgstr_rect(&mi
.rcMonitor
), wine_dbgstr_rect(&mi
.rcWork
));
7674 cls
.lpfnWndProc
= fullscreen_wnd_proc
;
7677 cls
.hInstance
= GetModuleHandleA(NULL
);
7679 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
7680 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7681 cls
.lpszMenuName
= NULL
;
7682 cls
.lpszClassName
= "fullscreen_class";
7683 RegisterClassA(&cls
);
7685 for (i
= 0; i
< sizeof(t_style
)/sizeof(t_style
[0]); i
++)
7687 DWORD style
, ex_style
;
7689 /* avoid a WM interaction */
7690 assert(!(t_style
[i
] & WS_VISIBLE
));
7692 for (j
= 0; j
< sizeof(t_ex_style
)/sizeof(t_ex_style
[0]); j
++)
7697 ex_style
= t_ex_style
[j
];
7699 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
7700 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
7701 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
7702 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
7703 GetWindowRect(hwnd
, &rc
);
7704 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
7705 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
7706 "%#x/%#x: window rect %s\n", ex_style
, style
, wine_dbgstr_rect(&rc
));
7707 DestroyWindow(hwnd
);
7709 style
= t_style
[i
] | WS_MAXIMIZE
;
7710 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
7711 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
7712 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
7713 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
7714 GetWindowRect(hwnd
, &rc
);
7715 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
7716 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
7717 "%#x/%#x: window rect %s\n", ex_style
, style
, wine_dbgstr_rect(&rc
));
7718 DestroyWindow(hwnd
);
7720 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
;
7721 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
7722 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
7723 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
7724 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
7725 GetWindowRect(hwnd
, &rc
);
7726 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
7727 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
7728 "%#x/%#x: window rect %s\n", ex_style
, style
, wine_dbgstr_rect(&rc
));
7729 DestroyWindow(hwnd
);
7731 style
= t_style
[i
] | WS_CAPTION
| WS_MAXIMIZEBOX
;
7732 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
7733 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
7734 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
7735 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
7736 GetWindowRect(hwnd
, &rc
);
7737 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
7738 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
7739 "%#x/%#x: window rect %s\n", ex_style
, style
, wine_dbgstr_rect(&rc
));
7740 DestroyWindow(hwnd
);
7742 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
| WS_MAXIMIZEBOX
;
7743 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
7744 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
7745 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
7746 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
7747 GetWindowRect(hwnd
, &rc
);
7748 /* Windows makes a maximized window slightly larger (to hide the borders?) */
7749 fixup
= min(abs(rc
.left
), abs(rc
.top
));
7750 InflateRect(&rc
, -fixup
, -fixup
);
7751 ok(rc
.left
>= mi
.rcMonitor
.left
&& rc
.top
>= mi
.rcMonitor
.top
&&
7752 rc
.right
<= mi
.rcMonitor
.right
&& rc
.bottom
<= mi
.rcMonitor
.bottom
,
7753 "%#x/%#x: window rect %s must be in %s\n", ex_style
, style
, wine_dbgstr_rect(&rc
),
7754 wine_dbgstr_rect(&mi
.rcMonitor
));
7755 DestroyWindow(hwnd
);
7757 style
= t_style
[i
] | WS_MAXIMIZE
| WS_MAXIMIZEBOX
;
7758 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
7759 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
7760 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
7761 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
7762 GetWindowRect(hwnd
, &rc
);
7763 /* Windows makes a maximized window slightly larger (to hide the borders?) */
7764 fixup
= min(abs(rc
.left
), abs(rc
.top
));
7765 InflateRect(&rc
, -fixup
, -fixup
);
7766 if (style
& (WS_CHILD
| WS_POPUP
))
7767 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
7768 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
7769 "%#x/%#x: window rect %s\n", ex_style
, style
, wine_dbgstr_rect(&rc
));
7771 ok(rc
.left
>= mi
.rcMonitor
.left
&& rc
.top
>= mi
.rcMonitor
.top
&&
7772 rc
.right
<= mi
.rcMonitor
.right
&& rc
.bottom
<= mi
.rcMonitor
.bottom
,
7773 "%#x/%#x: window rect %s\n", ex_style
, style
, wine_dbgstr_rect(&rc
));
7774 DestroyWindow(hwnd
);
7778 UnregisterClassA("fullscreen_class", GetModuleHandleA(NULL
));
7781 static BOOL test_thick_child_got_minmax
;
7782 static const char * test_thick_child_name
;
7783 static LONG test_thick_child_style
;
7784 static LONG test_thick_child_exStyle
;
7786 static LRESULT WINAPI
test_thick_child_size_winproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
7789 int expectedMinTrackX
;
7790 int expectedMinTrackY
;
7791 int actualMinTrackX
;
7792 int actualMinTrackY
;
7793 int expectedMaxTrackX
;
7794 int expectedMaxTrackY
;
7795 int actualMaxTrackX
;
7796 int actualMaxTrackY
;
7797 int expectedMaxSizeX
;
7798 int expectedMaxSizeY
;
7809 case WM_GETMINMAXINFO
:
7811 minmax
= (MINMAXINFO
*)lparam
;
7812 if (winetest_debug
> 1)
7814 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
7815 dump_minmax_info( minmax
);
7817 test_thick_child_got_minmax
= TRUE
;
7820 adjustedStyle
= test_thick_child_style
;
7821 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
7822 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
7823 GetClientRect(GetParent(hwnd
), &rect
);
7824 AdjustWindowRectEx(&rect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
7826 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
7828 expectedMinTrackX
= GetSystemMetrics(SM_CXMINTRACK
);
7829 expectedMinTrackY
= GetSystemMetrics(SM_CYMINTRACK
);
7833 expectedMinTrackX
= -2 * rect
.left
;
7834 expectedMinTrackY
= -2 * rect
.top
;
7836 actualMinTrackX
= minmax
->ptMinTrackSize
.x
;
7837 actualMinTrackY
= minmax
->ptMinTrackSize
.y
;
7839 ok(actualMinTrackX
== expectedMinTrackX
&& actualMinTrackY
== expectedMinTrackY
,
7840 "expected minTrack %dx%d, actual minTrack %dx%d for %s\n",
7841 expectedMinTrackX
, expectedMinTrackY
, actualMinTrackX
, actualMinTrackY
,
7842 test_thick_child_name
);
7844 actualMaxTrackX
= minmax
->ptMaxTrackSize
.x
;
7845 actualMaxTrackY
= minmax
->ptMaxTrackSize
.y
;
7846 expectedMaxTrackX
= GetSystemMetrics(SM_CXMAXTRACK
);
7847 expectedMaxTrackY
= GetSystemMetrics(SM_CYMAXTRACK
);
7848 ok(actualMaxTrackX
== expectedMaxTrackX
&& actualMaxTrackY
== expectedMaxTrackY
,
7849 "expected maxTrack %dx%d, actual maxTrack %dx%d for %s\n",
7850 expectedMaxTrackX
, expectedMaxTrackY
, actualMaxTrackX
, actualMaxTrackY
,
7851 test_thick_child_name
);
7853 expectedMaxSizeX
= rect
.right
- rect
.left
;
7854 expectedMaxSizeY
= rect
.bottom
- rect
.top
;
7855 actualMaxSizeX
= minmax
->ptMaxSize
.x
;
7856 actualMaxSizeY
= minmax
->ptMaxSize
.y
;
7858 ok(actualMaxSizeX
== expectedMaxSizeX
&& actualMaxSizeY
== expectedMaxSizeY
,
7859 "expected maxSize %dx%d, actual maxSize %dx%d for %s\n",
7860 expectedMaxSizeX
, expectedMaxSizeY
, actualMaxSizeX
, actualMaxSizeY
,
7861 test_thick_child_name
);
7864 expectedPosX
= rect
.left
;
7865 expectedPosY
= rect
.top
;
7866 actualPosX
= minmax
->ptMaxPosition
.x
;
7867 actualPosY
= minmax
->ptMaxPosition
.y
;
7868 ok(actualPosX
== expectedPosX
&& actualPosY
== expectedPosY
,
7869 "expected maxPosition (%d/%d), actual maxPosition (%d/%d) for %s\n",
7870 expectedPosX
, expectedPosY
, actualPosX
, actualPosY
, test_thick_child_name
);
7876 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
7879 #define NUMBER_OF_THICK_CHILD_TESTS 16
7880 static void test_thick_child_size(HWND parentWindow
)
7884 RECT adjustedParentRect
;
7889 LONG expectedHeight
;
7891 static const char className
[] = "THICK_CHILD_CLASS";
7894 static const LONG styles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
7895 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
7896 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
7897 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
7898 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
7899 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
7900 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
7901 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
7902 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
7903 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
7904 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
7905 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
7906 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
7907 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
7908 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
7909 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
7910 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
7913 static const LONG exStyles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
7918 WS_EX_DLGMODALFRAME
,
7919 WS_EX_DLGMODALFRAME
,
7920 WS_EX_DLGMODALFRAME
,
7921 WS_EX_DLGMODALFRAME
,
7926 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
7927 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
7928 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
7929 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
7931 static const char *styleName
[NUMBER_OF_THICK_CHILD_TESTS
] = {
7932 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME",
7933 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME",
7934 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER",
7935 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER",
7936 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_DLGMODALFRAME",
7937 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_DLGMODALFRAME",
7938 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
7939 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
7940 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME exstyle= WS_EX_STATICEDGE",
7941 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE",
7942 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
7943 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
7944 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7945 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7946 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7947 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
7951 cls
.lpfnWndProc
= test_thick_child_size_winproc
;
7954 cls
.hInstance
= GetModuleHandleA(0);
7956 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
7957 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
7958 cls
.lpszMenuName
= NULL
;
7959 cls
.lpszClassName
= className
;
7960 SetLastError(0xdeadbeef);
7961 success
= RegisterClassA(&cls
);
7962 ok(success
,"RegisterClassA failed, error: %u\n", GetLastError());
7964 for(i
= 0; i
< NUMBER_OF_THICK_CHILD_TESTS
; i
++)
7966 test_thick_child_name
= styleName
[i
];
7967 test_thick_child_style
= styles
[i
];
7968 test_thick_child_exStyle
= exStyles
[i
];
7969 test_thick_child_got_minmax
= FALSE
;
7971 SetLastError(0xdeadbeef);
7972 childWindow
= CreateWindowExA( exStyles
[i
], className
, "", styles
[i
], 0, 0, 0, 0, parentWindow
, 0, GetModuleHandleA(0), NULL
);
7973 ok(childWindow
!= NULL
, "Failed to create child window, error: %u\n", GetLastError());
7975 ok(test_thick_child_got_minmax
, "Got no WM_GETMINMAXINFO\n");
7977 SetLastError(0xdeadbeef);
7978 success
= GetWindowRect(childWindow
, &childRect
);
7979 ok(success
,"GetWindowRect call failed, error: %u\n", GetLastError());
7980 childWidth
= childRect
.right
- childRect
.left
;
7981 childHeight
= childRect
.bottom
- childRect
.top
;
7983 adjustedStyle
= styles
[i
];
7984 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
7985 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
7986 GetClientRect(GetParent(childWindow
), &adjustedParentRect
);
7987 AdjustWindowRectEx(&adjustedParentRect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
7990 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
7992 expectedWidth
= GetSystemMetrics(SM_CXMINTRACK
);
7993 expectedHeight
= GetSystemMetrics(SM_CYMINTRACK
);
7997 expectedWidth
= -2 * adjustedParentRect
.left
;
7998 expectedHeight
= -2 * adjustedParentRect
.top
;
8001 ok((childWidth
== expectedWidth
) && (childHeight
== expectedHeight
),
8002 "size of window (%s) is wrong: expected size %dx%d != actual size %dx%d\n",
8003 test_thick_child_name
, expectedWidth
, expectedHeight
, childWidth
, childHeight
);
8005 SetLastError(0xdeadbeef);
8006 success
= DestroyWindow(childWindow
);
8007 ok(success
,"DestroyWindow call failed, error: %u\n", GetLastError());
8009 ok(UnregisterClassA(className
, GetModuleHandleA(NULL
)),"UnregisterClass call failed\n");
8012 static void test_handles( HWND full_hwnd
)
8014 HWND hwnd
= full_hwnd
;
8018 SetLastError( 0xdeadbeef );
8019 ret
= GetWindowRect( hwnd
, &rect
);
8020 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
8023 if ((ULONG_PTR
)full_hwnd
>> 32)
8024 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
& ~0u);
8026 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
| ((ULONG_PTR
)~0u << 32));
8027 SetLastError( 0xdeadbeef );
8028 ret
= GetWindowRect( hwnd
, &rect
);
8029 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
8031 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& ~0u) | ((ULONG_PTR
)0x1234 << 32));
8032 SetLastError( 0xdeadbeef );
8033 ret
= GetWindowRect( hwnd
, &rect
);
8034 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
8036 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x9876 << 16));
8037 SetLastError( 0xdeadbeef );
8038 ret
= GetWindowRect( hwnd
, &rect
);
8039 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
8040 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
8042 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x12345678 << 16));
8043 SetLastError( 0xdeadbeef );
8044 ret
= GetWindowRect( hwnd
, &rect
);
8045 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
8046 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
8050 static void test_winregion(void)
8057 if (!pGetWindowRgnBox
)
8059 win_skip("GetWindowRgnBox not supported\n");
8063 hwnd
= CreateWindowExA(0, "static", NULL
, WS_VISIBLE
, 10, 10, 10, 10, NULL
, 0, 0, NULL
);
8065 SetLastError(0xdeadbeef);
8066 ret
= pGetWindowRgnBox(hwnd
, NULL
);
8067 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
8068 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
8070 hrgn
= CreateRectRgn(2, 3, 10, 15);
8071 ok( hrgn
!= NULL
, "Region creation failed\n");
8074 SetWindowRgn(hwnd
, hrgn
, FALSE
);
8076 SetLastError(0xdeadbeef);
8077 ret
= pGetWindowRgnBox(hwnd
, NULL
);
8078 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
8079 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
8082 ret
= pGetWindowRgnBox(hwnd
, &r
);
8083 ok( ret
== SIMPLEREGION
, "Expected SIMPLEREGION, got %d\n", ret
);
8084 ok( r
.left
== 2 && r
.top
== 3 && r
.right
== 10 && r
.bottom
== 15,
8085 "Expected (2,3)-(10,15), got %s\n", wine_dbgstr_rect( &r
));
8088 hrgn
= CreateRectRgn(2, 3, 10, 15);
8089 ret
= pMirrorRgn( hwnd
, hrgn
);
8090 ok( ret
== TRUE
, "MirrorRgn failed %u\n", ret
);
8092 GetWindowRect( hwnd
, &r
);
8093 width
= r
.right
- r
.left
;
8095 ret
= GetRgnBox( hrgn
, &r
);
8096 ok( ret
== SIMPLEREGION
, "GetRgnBox failed %u\n", ret
);
8097 ok( r
.left
== width
- 10 && r
.top
== 3 && r
.right
== width
- 2 && r
.bottom
== 15,
8098 "Wrong rectangle %s for width %d\n", wine_dbgstr_rect( &r
), width
);
8100 else win_skip( "MirrorRgn not supported\n" );
8102 DestroyWindow(hwnd
);
8105 static void test_rtl_layout(void)
8111 if (!pSetProcessDefaultLayout
)
8113 win_skip( "SetProcessDefaultLayout not supported\n" );
8117 parent
= CreateWindowExA(WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
, 100, 100, 300, 300, NULL
, 0, 0, NULL
);
8118 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 10, 10, 20, 20, parent
, 0, 0, NULL
);
8120 GetWindowRect( parent
, &r
);
8121 ok( r
.left
== 100 && r
.right
== 400, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8122 GetClientRect( parent
, &r
);
8123 ok( r
.left
== 0 && r
.right
== 300, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8124 GetClientRect( child
, &r
);
8125 ok( r
.left
== 0 && r
.right
== 20, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8126 MapWindowPoints( child
, parent
, (POINT
*)&r
, 2 );
8127 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8128 GetWindowRect( child
, &r
);
8129 ok( r
.left
== 370 && r
.right
== 390, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8130 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
8131 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8132 GetWindowRect( child
, &r
);
8133 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 1 );
8134 MapWindowPoints( NULL
, parent
, (POINT
*)&r
+ 1, 1 );
8135 ok( r
.left
== 30 && r
.right
== 10, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8137 MapWindowPoints( child
, parent
, &pt
, 1 );
8138 ok( pt
.x
== 22 && pt
.y
== 22, "wrong point %d,%d\n", pt
.x
, pt
.y
);
8139 SetWindowPos( parent
, 0, 0, 0, 250, 250, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
8140 GetWindowRect( parent
, &r
);
8141 ok( r
.left
== 100 && r
.right
== 350, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8142 GetWindowRect( child
, &r
);
8143 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8144 SetWindowLongW( parent
, GWL_EXSTYLE
, 0 );
8145 GetWindowRect( child
, &r
);
8146 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8147 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
8148 ok( r
.left
== 220 && r
.right
== 240, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8149 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_LAYOUTRTL
);
8150 GetWindowRect( child
, &r
);
8151 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8152 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
8153 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8154 SetWindowPos( child
, 0, 0, 0, 30, 30, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
8155 GetWindowRect( child
, &r
);
8156 ok( r
.left
== 310 && r
.right
== 340, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8157 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
8158 ok( r
.left
== 10 && r
.right
== 40, "wrong rect %s\n", wine_dbgstr_rect( &r
));
8159 DestroyWindow( child
);
8160 DestroyWindow( parent
);
8163 static void test_FlashWindow(void)
8169 win_skip( "FlashWindow not supported\n" );
8173 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP
,
8174 0, 0, 0, 0, 0, 0, 0, NULL
);
8175 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
8177 SetLastError( 0xdeadbeef );
8178 ret
= pFlashWindow( NULL
, TRUE
);
8179 ok( !ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
||
8180 GetLastError() == ERROR_INVALID_WINDOW_HANDLE
),
8181 "FlashWindow returned with %d\n", GetLastError() );
8183 DestroyWindow( hwnd
);
8185 SetLastError( 0xdeadbeef );
8186 ret
= pFlashWindow( hwnd
, TRUE
);
8187 ok( !ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
||
8188 GetLastError() == ERROR_INVALID_WINDOW_HANDLE
),
8189 "FlashWindow returned with %d\n", GetLastError() );
8192 static void test_FlashWindowEx(void)
8198 if (!pFlashWindowEx
)
8200 win_skip( "FlashWindowEx not supported\n" );
8204 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP
,
8205 0, 0, 0, 0, 0, 0, 0, NULL
);
8206 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
8208 finfo
.cbSize
= sizeof(FLASHWINFO
);
8209 finfo
.dwFlags
= FLASHW_TIMER
;
8211 finfo
.dwTimeout
= 200;
8213 SetLastError(0xdeadbeef);
8214 ret
= pFlashWindowEx(&finfo
);
8215 ok(!ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
||
8216 GetLastError() == ERROR_INVALID_WINDOW_HANDLE
),
8217 "FlashWindowEx returned with %d\n", GetLastError());
8220 SetLastError(0xdeadbeef);
8221 ret
= pFlashWindowEx(NULL
);
8222 ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
8223 "FlashWindowEx returned with %d\n", GetLastError());
8225 SetLastError(0xdeadbeef);
8226 ret
= pFlashWindowEx(&finfo
);
8227 todo_wine
ok(!ret
, "previous window state should not be active\n");
8229 finfo
.cbSize
= sizeof(FLASHWINFO
) - 1;
8230 SetLastError(0xdeadbeef);
8231 ret
= pFlashWindowEx(&finfo
);
8232 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
8233 "FlashWindowEx succeeded\n");
8235 finfo
.cbSize
= sizeof(FLASHWINFO
) + 1;
8236 SetLastError(0xdeadbeef);
8237 ret
= pFlashWindowEx(&finfo
);
8238 ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
8239 "FlashWindowEx succeeded\n");
8240 finfo
.cbSize
= sizeof(FLASHWINFO
);
8242 DestroyWindow( hwnd
);
8244 SetLastError(0xdeadbeef);
8245 ret
= pFlashWindowEx(&finfo
);
8246 ok(!ret
&& (GetLastError() == ERROR_INVALID_PARAMETER
||
8247 GetLastError() == ERROR_INVALID_WINDOW_HANDLE
),
8248 "FlashWindowEx returned with %d\n", GetLastError());
8250 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
8251 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
8252 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
8253 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
8254 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
8256 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_VISIBLE
| WS_POPUPWINDOW
,
8257 0, 0, 0, 0, 0, 0, 0, NULL
);
8258 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
8261 SetLastError(0xdeadbeef);
8262 ret
= pFlashWindowEx(NULL
);
8263 ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
8264 "FlashWindowEx returned with %d\n", GetLastError());
8266 SetLastError(0xdeadbeef);
8267 prev
= pFlashWindowEx(&finfo
);
8269 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
8270 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
8271 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
8272 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
8273 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
8275 finfo
.dwFlags
= FLASHW_STOP
;
8276 SetLastError(0xdeadbeef);
8277 ret
= pFlashWindowEx(&finfo
);
8278 ok(prev
!= ret
, "previous window state should be different\n");
8280 DestroyWindow( hwnd
);
8283 static void test_FindWindowEx(void)
8287 hwnd
= CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
8288 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
8290 num_gettext_msgs
= 0;
8291 found
= FindWindowExA( 0, 0, "ClassThatDoesntExist", "" );
8292 ok( found
== NULL
, "expected a NULL hwnd\n" );
8293 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8295 num_gettext_msgs
= 0;
8296 found
= FindWindowExA( 0, 0, "ClassThatDoesntExist", NULL
);
8297 ok( found
== NULL
, "expected a NULL hwnd\n" );
8298 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8300 num_gettext_msgs
= 0;
8301 found
= FindWindowExA( 0, 0, "MainWindowClass", "" );
8302 ok( found
== NULL
, "expected a NULL hwnd\n" );
8303 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8305 num_gettext_msgs
= 0;
8306 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
8307 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8308 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8310 num_gettext_msgs
= 0;
8311 found
= FindWindowExA( 0, 0, "MainWindowClass", "caption" );
8312 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8313 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8315 DestroyWindow( hwnd
);
8317 hwnd
= CreateWindowExA( 0, "MainWindowClass", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
8318 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
8320 num_gettext_msgs
= 0;
8321 found
= FindWindowExA( 0, 0, "MainWindowClass", "" );
8322 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8323 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8325 num_gettext_msgs
= 0;
8326 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
8327 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8328 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8330 DestroyWindow( hwnd
);
8332 /* test behaviour with a window title that is an empty character */
8333 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", "" );
8334 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
8335 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", NULL
);
8336 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
8339 static void test_FindWindow(void)
8343 hwnd
= CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
8344 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
8346 num_gettext_msgs
= 0;
8347 found
= FindWindowA( "ClassThatDoesntExist", "" );
8348 ok( found
== NULL
, "expected a NULL hwnd\n" );
8349 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8351 num_gettext_msgs
= 0;
8352 found
= FindWindowA( "ClassThatDoesntExist", NULL
);
8353 ok( found
== NULL
, "expected a NULL hwnd\n" );
8354 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8356 num_gettext_msgs
= 0;
8357 found
= FindWindowA( "MainWindowClass", "" );
8358 ok( found
== NULL
, "expected a NULL hwnd\n" );
8359 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8361 num_gettext_msgs
= 0;
8362 found
= FindWindowA( "MainWindowClass", NULL
);
8363 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8364 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8366 num_gettext_msgs
= 0;
8367 found
= FindWindowA( "MainWindowClass", "caption" );
8368 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8369 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8371 DestroyWindow( hwnd
);
8373 hwnd
= CreateWindowExA( 0, "MainWindowClass", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
8374 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
8376 num_gettext_msgs
= 0;
8377 found
= FindWindowA( "MainWindowClass", "" );
8378 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8379 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8381 num_gettext_msgs
= 0;
8382 found
= FindWindowA( "MainWindowClass", NULL
);
8383 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
8384 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
8386 DestroyWindow( hwnd
);
8388 /* test behaviour with a window title that is an empty character */
8389 found
= FindWindowA( "Shell_TrayWnd", "" );
8390 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
8391 found
= FindWindowA( "Shell_TrayWnd", NULL
);
8392 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
8395 static void test_GetLastActivePopup(void)
8397 HWND hwndOwner
, hwndPopup1
, hwndPopup2
;
8399 hwndOwner
= CreateWindowExA(0, "MainWindowClass", NULL
,
8400 WS_VISIBLE
| WS_POPUPWINDOW
,
8402 NULL
, 0, GetModuleHandleA(NULL
), NULL
);
8403 hwndPopup1
= CreateWindowExA(0, "MainWindowClass", NULL
,
8404 WS_VISIBLE
| WS_POPUPWINDOW
,
8406 hwndOwner
, 0, GetModuleHandleA(NULL
), NULL
);
8407 hwndPopup2
= CreateWindowExA(0, "MainWindowClass", NULL
,
8408 WS_VISIBLE
| WS_POPUPWINDOW
,
8410 hwndPopup1
, 0, GetModuleHandleA(NULL
), NULL
);
8411 ok( GetLastActivePopup(hwndOwner
) == hwndPopup2
, "wrong last active popup\n" );
8412 DestroyWindow( hwndPopup2
);
8413 DestroyWindow( hwndPopup1
);
8414 DestroyWindow( hwndOwner
);
8417 static LRESULT WINAPI
my_httrasparent_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
8419 if (msg
== WM_NCHITTEST
) return HTTRANSPARENT
;
8420 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
8423 static LRESULT WINAPI
my_window_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
8425 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
8428 static void create_window_tree(HWND parent
, HWND
*window
, int size
)
8430 static const DWORD style
[] = { 0, WS_VISIBLE
, WS_DISABLED
, WS_VISIBLE
| WS_DISABLED
};
8433 memset(window
, 0, size
* sizeof(window
[0]));
8436 for (i
= 0; i
< sizeof(style
)/sizeof(style
[0]); i
++)
8439 window
[pos
] = CreateWindowExA(0, "my_window", NULL
, style
[i
] | WS_CHILD
,
8440 0, 0, 100, 100, parent
, 0, 0, NULL
);
8441 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8444 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_window", NULL
, style
[i
] | WS_CHILD
,
8445 0, 0, 100, 100, parent
, 0, 0, NULL
);
8446 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8450 window
[pos
] = CreateWindowExA(0, "my_httrasparent", NULL
, style
[i
] | WS_CHILD
,
8451 0, 0, 100, 100, parent
, 0, 0, NULL
);
8452 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8455 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_httrasparent", NULL
, style
[i
] | WS_CHILD
,
8456 0, 0, 100, 100, parent
, 0, 0, NULL
);
8457 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8461 window
[pos
] = CreateWindowExA(0, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
8462 0, 0, 100, 100, parent
, 0, 0, NULL
);
8463 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8466 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
8467 0, 0, 100, 100, parent
, 0, 0, NULL
);
8468 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8471 window
[pos
] = CreateWindowExA(0, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
8472 0, 0, 100, 100, parent
, 0, 0, NULL
);
8473 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8476 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
8477 0, 0, 100, 100, parent
, 0, 0, NULL
);
8478 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8482 window
[pos
] = CreateWindowExA(0, "Button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
8483 0, 0, 100, 100, parent
, 0, 0, NULL
);
8484 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8487 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
8488 0, 0, 100, 100, parent
, 0, 0, NULL
);
8489 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8492 window
[pos
] = CreateWindowExA(0, "Button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
8493 0, 0, 100, 100, parent
, 0, 0, NULL
);
8494 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8497 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
8498 0, 0, 100, 100, parent
, 0, 0, NULL
);
8499 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8503 window
[pos
] = CreateWindowExA(0, "Static", NULL
, style
[i
] | WS_CHILD
,
8504 0, 0, 100, 100, parent
, 0, 0, NULL
);
8505 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8508 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Static", NULL
, style
[i
] | WS_CHILD
,
8509 0, 0, 100, 100, parent
, 0, 0, NULL
);
8510 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
8515 struct window_attributes
8517 char class_name
[128];
8518 BOOL is_visible
, is_enabled
, is_groupbox
, is_httransparent
, is_extransparent
;
8521 static void get_window_attributes(HWND hwnd
, struct window_attributes
*attrs
)
8523 DWORD style
, ex_style
, hittest
;
8525 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
8526 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
8527 attrs
->class_name
[0] = 0;
8528 GetClassNameA(hwnd
, attrs
->class_name
, sizeof(attrs
->class_name
));
8529 hittest
= SendMessageA(hwnd
, WM_NCHITTEST
, 0, 0);
8531 attrs
->is_visible
= (style
& WS_VISIBLE
) != 0;
8532 attrs
->is_enabled
= (style
& WS_DISABLED
) == 0;
8533 attrs
->is_groupbox
= !lstrcmpiA(attrs
->class_name
, "Button") && (style
& BS_TYPEMASK
) == BS_GROUPBOX
;
8534 attrs
->is_httransparent
= hittest
== HTTRANSPARENT
;
8535 attrs
->is_extransparent
= (ex_style
& WS_EX_TRANSPARENT
) != 0;
8538 static int window_to_index(HWND hwnd
, HWND
*window
, int size
)
8542 for (i
= 0; i
< size
; i
++)
8544 if (!window
[i
]) break;
8545 if (window
[i
] == hwnd
) return i
;
8550 static void test_child_window_from_point(void)
8552 static const int real_child_pos
[] = { 14,15,16,17,18,19,20,21,24,25,26,27,42,43,
8553 44,45,46,47,48,49,52,53,54,55,51,50,23,22,-1 };
8555 HWND hwnd
, parent
, window
[100];
8557 int found_invisible
, found_disabled
, found_groupbox
, found_httransparent
, found_extransparent
;
8560 ret
= GetClassInfoA(0, "Button", &cls
);
8561 ok(ret
, "GetClassInfo(Button) failed\n");
8562 cls
.lpszClassName
= "my_button";
8563 ret
= RegisterClassA(&cls
);
8564 ok(ret
, "RegisterClass(my_button) failed\n");
8566 cls
.lpszClassName
= "my_httrasparent";
8567 cls
.lpfnWndProc
= my_httrasparent_proc
;
8568 ret
= RegisterClassA(&cls
);
8569 ok(ret
, "RegisterClass(my_httrasparent) failed\n");
8571 cls
.lpszClassName
= "my_window";
8572 cls
.lpfnWndProc
= my_window_proc
;
8573 ret
= RegisterClassA(&cls
);
8574 ok(ret
, "RegisterClass(my_window) failed\n");
8576 parent
= CreateWindowExA(0, "MainWindowClass", NULL
,
8577 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
,
8579 0, 0, GetModuleHandleA(NULL
), NULL
);
8580 ok(parent
!= 0, "CreateWindowEx failed\n");
8581 trace("parent %p\n", parent
);
8583 create_window_tree(parent
, window
, sizeof(window
)/sizeof(window
[0]));
8585 found_invisible
= 0;
8588 found_httransparent
= 0;
8589 found_extransparent
= 0;
8591 /* FIXME: also test WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx */
8592 for (i
= 0; i
< sizeof(real_child_pos
)/sizeof(real_child_pos
[0]); i
++)
8594 struct window_attributes attrs
;
8597 hwnd
= RealChildWindowFromPoint(parent
, pt
);
8598 ok(hwnd
!= 0, "RealChildWindowFromPoint failed\n");
8599 ret
= window_to_index(hwnd
, window
, sizeof(window
)/sizeof(window
[0]));
8600 /* FIXME: remove once Wine is fixed */
8601 todo_wine_if (ret
!= real_child_pos
[i
])
8602 ok(ret
== real_child_pos
[i
], "expected %d, got %d\n", real_child_pos
[i
], ret
);
8604 get_window_attributes(hwnd
, &attrs
);
8605 if (!attrs
.is_visible
) found_invisible
++;
8606 if (!attrs
.is_enabled
) found_disabled
++;
8607 if (attrs
.is_groupbox
) found_groupbox
++;
8608 if (attrs
.is_httransparent
) found_httransparent
++;
8609 if (attrs
.is_extransparent
) found_extransparent
++;
8611 if (ret
!= real_child_pos
[i
] && ret
!= -1)
8613 trace("found hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
8614 hwnd
, attrs
.class_name
, attrs
.is_visible
, attrs
.is_enabled
, attrs
.is_groupbox
, attrs
.is_httransparent
, attrs
.is_extransparent
);
8615 get_window_attributes(window
[real_child_pos
[i
]], &attrs
);
8616 trace("expected hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
8617 window
[real_child_pos
[i
]], attrs
.class_name
, attrs
.is_visible
, attrs
.is_enabled
, attrs
.is_groupbox
, attrs
.is_httransparent
, attrs
.is_extransparent
);
8621 ok(hwnd
== parent
, "expected %p, got %p\n", parent
, hwnd
);
8624 DestroyWindow(hwnd
);
8627 DestroyWindow(parent
);
8629 ok(!found_invisible
, "found %d invisible windows\n", found_invisible
);
8630 ok(found_disabled
, "found %d disabled windows\n", found_disabled
);
8632 ok(found_groupbox
== 4, "found %d groupbox windows\n", found_groupbox
);
8633 ok(found_httransparent
, "found %d httransparent windows\n", found_httransparent
);
8635 ok(found_extransparent
, "found %d extransparent windows\n", found_extransparent
);
8637 ret
= UnregisterClassA("my_button", cls
.hInstance
);
8638 ok(ret
, "UnregisterClass(my_button) failed\n");
8639 ret
= UnregisterClassA("my_httrasparent", cls
.hInstance
);
8640 ok(ret
, "UnregisterClass(my_httrasparent) failed\n");
8641 ret
= UnregisterClassA("my_window", cls
.hInstance
);
8642 ok(ret
, "UnregisterClass(my_window) failed\n");
8645 static void simulate_click(int x
, int y
)
8651 memset(input
, 0, sizeof(input
));
8652 input
[0].type
= INPUT_MOUSE
;
8653 U(input
[0]).mi
.dx
= x
;
8654 U(input
[0]).mi
.dy
= y
;
8655 U(input
[0]).mi
.dwFlags
= MOUSEEVENTF_LEFTDOWN
;
8656 input
[1].type
= INPUT_MOUSE
;
8657 U(input
[1]).mi
.dx
= x
;
8658 U(input
[1]).mi
.dy
= y
;
8659 U(input
[1]).mi
.dwFlags
= MOUSEEVENTF_LEFTUP
;
8660 events_no
= SendInput(2, input
, sizeof(input
[0]));
8661 ok(events_no
== 2, "SendInput returned %d\n", events_no
);
8664 static WNDPROC def_static_proc
;
8665 static BOOL got_hittest
;
8666 static LRESULT WINAPI
static_hook_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
8668 if(msg
== WM_NCHITTEST
)
8670 if(msg
== WM_LBUTTONDOWN
)
8671 ok(0, "unexpected call\n");
8673 return def_static_proc(hwnd
, msg
, wp
, lp
);
8676 static void window_from_point_proc(HWND parent
)
8678 HANDLE start_event
, end_event
;
8679 HANDLE win
, child_static
, child_button
;
8685 start_event
= OpenEventA(EVENT_ALL_ACCESS
, FALSE
, "test_wfp_start");
8686 ok(start_event
!= 0, "OpenEvent failed\n");
8687 end_event
= OpenEventA(EVENT_ALL_ACCESS
, FALSE
, "test_wfp_end");
8688 ok(end_event
!= 0, "OpenEvent failed\n");
8690 child_static
= CreateWindowExA(0, "static", "static", WS_CHILD
| WS_VISIBLE
,
8691 0, 0, 100, 100, parent
, 0, NULL
, NULL
);
8692 ok(child_static
!= 0, "CreateWindowEx failed\n");
8694 win
= WindowFromPoint(pt
);
8695 ok(win
== parent
, "WindowFromPoint returned %p, expected %p\n", win
, parent
);
8697 child_button
= CreateWindowExA(0, "button", "button", WS_CHILD
| WS_VISIBLE
,
8698 100, 0, 100, 100, parent
, 0, NULL
, NULL
);
8699 ok(child_button
!= 0, "CreateWindowEx failed\n");
8701 win
= WindowFromPoint(pt
);
8702 ok(win
== child_button
, "WindowFromPoint returned %p, expected %p\n", win
, child_button
);
8704 /* without this window simulate click test keeps sending WM_NCHITTEST
8705 * message to child_static in an infinite loop */
8706 win
= CreateWindowExA(0, "button", "button", WS_CHILD
| WS_VISIBLE
,
8707 0, 0, 100, 100, parent
, 0, NULL
, NULL
);
8708 ok(win
!= 0, "CreateWindowEx failed\n");
8709 def_static_proc
= (void*)SetWindowLongPtrA(child_static
,
8710 GWLP_WNDPROC
, (LONG_PTR
)static_hook_proc
);
8712 SetEvent(start_event
);
8714 got_hittest
= FALSE
;
8716 while(!got_click
&& wait_for_message(&msg
)) {
8717 if(msg
.message
== WM_LBUTTONUP
) {
8718 ok(msg
.hwnd
== win
, "msg.hwnd = %p, expected %p\n", msg
.hwnd
, win
);
8721 DispatchMessageA(&msg
);
8723 ok(got_hittest
, "transparent window didn't get WM_NCHITTEST message\n");
8724 ok(got_click
, "button under static window didn't get WM_LBUTTONUP\n");
8726 ret
= WaitForSingleObject(end_event
, 5000);
8727 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject returned %x\n", ret
);
8729 CloseHandle(start_event
);
8730 CloseHandle(end_event
);
8733 static void test_window_from_point(const char *argv0
)
8735 HWND hwnd
, child
, win
;
8737 PROCESS_INFORMATION info
;
8738 STARTUPINFOA startup
;
8740 HANDLE start_event
, end_event
;
8742 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
| WS_VISIBLE
,
8743 100, 100, 200, 100, 0, 0, NULL
, NULL
);
8744 ok(hwnd
!= 0, "CreateWindowEx failed\n");
8747 win
= WindowFromPoint(pt
);
8750 win
= WindowFromPoint(pt
);
8752 skip("there's another window covering test window\n");
8753 DestroyWindow(hwnd
);
8757 child
= CreateWindowExA(0, "static", "static", WS_CHILD
| WS_VISIBLE
,
8758 0, 0, 100, 100, hwnd
, 0, NULL
, NULL
);
8759 ok(child
!= 0, "CreateWindowEx failed\n");
8761 win
= WindowFromPoint(pt
);
8762 ok(win
== hwnd
, "WindowFromPoint returned %p, expected %p\n", win
, hwnd
);
8763 DestroyWindow(child
);
8765 child
= CreateWindowExA(0, "button", "button", WS_CHILD
| WS_VISIBLE
,
8766 0, 0, 100, 100, hwnd
, 0, NULL
, NULL
);
8767 ok(child
!= 0, "CreateWindowEx failed\n");
8768 win
= WindowFromPoint(pt
);
8769 ok(win
== child
, "WindowFromPoint returned %p, expected %p\n", win
, child
);
8770 DestroyWindow(child
);
8772 start_event
= CreateEventA(NULL
, FALSE
, FALSE
, "test_wfp_start");
8773 ok(start_event
!= 0, "CreateEvent failed\n");
8774 end_event
= CreateEventA(NULL
, FALSE
, FALSE
, "test_wfp_end");
8775 ok(start_event
!= 0, "CreateEvent failed\n");
8777 sprintf(cmd
, "%s win create_children %p\n", argv0
, hwnd
);
8778 memset(&startup
, 0, sizeof(startup
));
8779 startup
.cb
= sizeof(startup
);
8780 ok(CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
,
8781 &startup
, &info
), "CreateProcess failed.\n");
8782 ok(wait_for_event(start_event
, 1000), "didn't get start_event\n");
8784 child
= GetWindow(hwnd
, GW_CHILD
);
8785 win
= WindowFromPoint(pt
);
8786 ok(win
== child
, "WindowFromPoint returned %p, expected %p\n", win
, child
);
8788 simulate_click(150, 150);
8791 child
= GetWindow(child
, GW_HWNDNEXT
);
8793 win
= WindowFromPoint(pt
);
8794 ok(win
== child
, "WindowFromPoint returned %p, expected %p\n", win
, child
);
8796 SetEvent(end_event
);
8797 winetest_wait_child_process(info
.hProcess
);
8798 CloseHandle(start_event
);
8799 CloseHandle(end_event
);
8800 CloseHandle(info
.hProcess
);
8801 CloseHandle(info
.hThread
);
8803 DestroyWindow(hwnd
);
8806 static void test_map_points(void)
8810 HWND wnd
, wnd0
, dwnd
;
8813 POINT pos
= { 100, 200 };
8819 /* Create test windows */
8820 wnd
= CreateWindowA("static", "test1", WS_POPUP
, pos
.x
, pos
.y
, width
, height
, NULL
, NULL
, NULL
, NULL
);
8821 ok(wnd
!= NULL
, "Failed %p\n", wnd
);
8822 wnd0
= CreateWindowA("static", "test2", WS_POPUP
, 0, 0, width
, height
, NULL
, NULL
, NULL
, NULL
);
8823 ok(wnd0
!= NULL
, "Failed %p\n", wnd
);
8824 dwnd
= CreateWindowA("static", "test3", 0, 200, 300, 150, 150, NULL
, NULL
, NULL
, NULL
);
8825 DestroyWindow(dwnd
);
8826 ok(dwnd
!= NULL
, "Failed %p\n", dwnd
);
8828 /* Verify window rect and client rect (they should have the same width and height) */
8829 GetWindowRect(wnd
, &window_rect
);
8830 ok(window_rect
.left
== pos
.x
, "left is %d instead of %d\n", window_rect
.left
, pos
.x
);
8831 ok(window_rect
.top
== pos
.y
, "top is %d instead of %d\n", window_rect
.top
, pos
.y
);
8832 ok(window_rect
.right
== pos
.x
+ width
, "right is %d instead of %d\n", window_rect
.right
, pos
.x
+ width
);
8833 ok(window_rect
.bottom
== pos
.y
+ height
, "bottom is %d instead of %d\n", window_rect
.bottom
, pos
.y
+ height
);
8834 GetClientRect(wnd
, &client_rect
);
8835 ok(client_rect
.left
== 0, "left is %d instead of 0\n", client_rect
.left
);
8836 ok(client_rect
.top
== 0, "top is %d instead of 0\n", client_rect
.top
);
8837 ok(client_rect
.right
== width
, "right is %d instead of %d\n", client_rect
.right
, width
);
8838 ok(client_rect
.bottom
== height
, "bottom is %d instead of %d\n", client_rect
.bottom
, height
);
8840 /* Test MapWindowPoints */
8842 /* MapWindowPoints(NULL or wnd, NULL or wnd, NULL, 1); crashes on Windows */
8844 SetLastError(0xdeadbeef);
8845 n
= MapWindowPoints(NULL
, NULL
, NULL
, 0);
8846 err
= GetLastError();
8847 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8848 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
8850 SetLastError(0xdeadbeef);
8851 n
= MapWindowPoints(wnd
, wnd
, NULL
, 0);
8852 err
= GetLastError();
8853 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8854 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
8856 n
= MapWindowPoints(wnd
, NULL
, NULL
, 0);
8857 ok(n
== MAKELONG(window_rect
.left
, window_rect
.top
), "Got %x, expected %x\n",
8858 n
, MAKELONG(window_rect
.left
, window_rect
.top
));
8860 n
= MapWindowPoints(NULL
, wnd
, NULL
, 0);
8861 ok(n
== MAKELONG(-window_rect
.left
, -window_rect
.top
), "Got %x, expected %x\n",
8862 n
, MAKELONG(-window_rect
.left
, -window_rect
.top
));
8864 SetLastError(0xdeadbeef);
8866 n
= MapWindowPoints(dwnd
, NULL
, &p
, 1);
8867 err
= GetLastError();
8868 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8869 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8870 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8872 SetLastError(0xdeadbeef);
8874 n
= MapWindowPoints(dwnd
, wnd
, &p
, 1);
8875 err
= GetLastError();
8876 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8877 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8878 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8880 SetLastError(0xdeadbeef);
8882 n
= MapWindowPoints(NULL
, dwnd
, &p
, 1);
8883 err
= GetLastError();
8884 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8885 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8886 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8888 SetLastError(0xdeadbeef);
8890 n
= MapWindowPoints(wnd
, dwnd
, &p
, 1);
8891 err
= GetLastError();
8892 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8893 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8894 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8896 SetLastError(0xdeadbeef);
8898 n
= MapWindowPoints(dwnd
, dwnd
, &p
, 1);
8899 err
= GetLastError();
8900 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8901 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8902 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8904 SetLastError(0xdeadbeef);
8906 n
= MapWindowPoints(NULL
, NULL
, &p
, 1);
8907 err
= GetLastError();
8908 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8909 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8910 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
8912 SetLastError(0xdeadbeef);
8914 n
= MapWindowPoints(wnd
, wnd
, &p
, 1);
8915 err
= GetLastError();
8916 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
8917 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8918 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
8921 n
= MapWindowPoints(wnd
, NULL
, &p
, 1);
8922 ok(n
== MAKELONG(window_rect
.left
, window_rect
.top
), "Got %x, expected %x\n",
8923 n
, MAKELONG(window_rect
.left
, window_rect
.top
));
8924 ok((p
.x
== (window_rect
.left
+ 100)) && (p
.y
== (window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
8925 p
.x
, p
.y
, window_rect
.left
+ 100, window_rect
.top
+ 100);
8928 n
= MapWindowPoints(NULL
, wnd
, &p
, 1);
8929 ok(n
== MAKELONG(-window_rect
.left
, -window_rect
.top
), "Got %x, expected %x\n",
8930 n
, MAKELONG(-window_rect
.left
, -window_rect
.top
));
8931 ok((p
.x
== (-window_rect
.left
+ 100)) && (p
.y
== (-window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
8932 p
.x
, p
.y
, -window_rect
.left
+ 100, -window_rect
.top
+ 100);
8934 SetLastError(0xdeadbeef);
8936 n
= MapWindowPoints(wnd0
, NULL
, &p
, 1);
8937 err
= GetLastError();
8938 ok(n
== 0, "Got %x, expected 0\n", n
);
8939 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
8940 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
8942 SetLastError(0xdeadbeef);
8944 n
= MapWindowPoints(NULL
, wnd0
, &p
, 1);
8945 err
= GetLastError();
8946 ok(n
== 0, "Got %x, expected 0\n", n
);
8947 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
8948 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
8950 /* Test ClientToScreen */
8952 /* ClientToScreen(wnd, NULL); crashes on Windows */
8954 SetLastError(0xdeadbeef);
8955 ret
= ClientToScreen(NULL
, NULL
);
8956 err
= GetLastError();
8957 ok(!ret
, "Should fail\n");
8958 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8960 SetLastError(0xdeadbeef);
8962 ret
= ClientToScreen(NULL
, &p
);
8963 err
= GetLastError();
8964 ok(!ret
, "Should fail\n");
8965 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8966 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8968 SetLastError(0xdeadbeef);
8970 ret
= ClientToScreen(dwnd
, &p
);
8971 err
= GetLastError();
8972 ok(!ret
, "Should fail\n");
8973 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
8974 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8977 ret
= ClientToScreen(wnd
, &p
);
8978 ok(ret
, "Failed with error %u\n", GetLastError());
8979 ok((p
.x
== (window_rect
.left
+ 100)) && (p
.y
== (window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
8980 p
.x
, p
.y
, window_rect
.left
+ 100, window_rect
.top
+ 100);
8983 ret
= ClientToScreen(wnd0
, &p
);
8984 ok(ret
, "Failed with error %u\n", GetLastError());
8985 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
8987 /* Test ScreenToClient */
8989 /* ScreenToClient(wnd, NULL); crashes on Windows */
8991 SetLastError(0xdeadbeef);
8992 ret
= ScreenToClient(NULL
, NULL
);
8993 err
= GetLastError();
8994 ok(!ret
, "Should fail\n");
8995 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
8997 SetLastError(0xdeadbeef);
8999 ret
= ScreenToClient(NULL
, &p
);
9000 err
= GetLastError();
9001 ok(!ret
, "Should fail\n");
9002 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
9003 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
9005 SetLastError(0xdeadbeef);
9007 ret
= ScreenToClient(dwnd
, &p
);
9008 err
= GetLastError();
9009 ok(!ret
, "Should fail\n");
9010 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
9011 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
9014 ret
= ScreenToClient(wnd
, &p
);
9015 ok(ret
, "Failed with error %u\n", GetLastError());
9016 ok((p
.x
== (-window_rect
.left
+ 100)) && (p
.y
== (-window_rect
.top
+ 100)), "Failed got(%d, %d), expected (%d, %d)\n",
9017 p
.x
, p
.y
, -window_rect
.left
+ 100, -window_rect
.top
+ 100);
9020 ret
= ScreenToClient(wnd0
, &p
);
9021 ok(ret
, "Failed with error %u\n", GetLastError());
9022 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
9025 DestroyWindow(wnd0
);
9028 static void test_update_region(void)
9030 HWND hwnd
, parent
, child
;
9032 const RECT rc
= {15, 15, 40, 40};
9033 const POINT wnd_orig
= {30, 20};
9034 const POINT child_orig
= {10, 5};
9036 parent
= CreateWindowExA(0, "MainWindowClass", NULL
,
9037 WS_VISIBLE
| WS_CLIPCHILDREN
,
9038 0, 0, 300, 150, NULL
, NULL
, GetModuleHandleA(0), 0);
9039 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
9040 WS_VISIBLE
| WS_CLIPCHILDREN
| WS_CHILD
,
9041 0, 0, 200, 100, parent
, NULL
, GetModuleHandleA(0), 0);
9042 child
= CreateWindowExA(0, "MainWindowClass", NULL
,
9043 WS_VISIBLE
| WS_CHILD
,
9044 child_orig
.x
, child_orig
.y
, 100, 50,
9045 hwnd
, NULL
, GetModuleHandleA(0), 0);
9046 assert(parent
&& hwnd
&& child
);
9048 ValidateRgn(parent
, NULL
);
9049 ValidateRgn(hwnd
, NULL
);
9050 InvalidateRect(hwnd
, &rc
, FALSE
);
9051 ValidateRgn(child
, NULL
);
9053 rgn1
= CreateRectRgn(0, 0, 0, 0);
9054 ok(GetUpdateRgn(parent
, rgn1
, FALSE
) == NULLREGION
,
9055 "has invalid area after ValidateRgn(NULL)\n");
9056 GetUpdateRgn(hwnd
, rgn1
, FALSE
);
9057 rgn2
= CreateRectRgnIndirect(&rc
);
9058 ok(EqualRgn(rgn1
, rgn2
), "assigned and retrieved update regions are different\n");
9059 ok(GetUpdateRgn(child
, rgn2
, FALSE
) == NULLREGION
,
9060 "has invalid area after ValidateRgn(NULL)\n");
9062 SetWindowPos(hwnd
, 0, wnd_orig
.x
, wnd_orig
.y
, 0, 0,
9063 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOSIZE
);
9065 /* parent now has non-simple update region, it consist of
9066 * two rects, that was exposed after hwnd moving ... */
9067 SetRectRgn(rgn1
, 0, 0, 200, wnd_orig
.y
);
9068 SetRectRgn(rgn2
, 0, 0, wnd_orig
.x
, 100);
9069 CombineRgn(rgn1
, rgn1
, rgn2
, RGN_OR
);
9070 /* ... and mapped hwnd's invalid area, that hwnd has before moving */
9071 SetRectRgn(rgn2
, rc
.left
+ wnd_orig
.x
, rc
.top
+ wnd_orig
.y
,
9072 rc
.right
+ wnd_orig
.x
, rc
.bottom
+ wnd_orig
.y
);
9073 CombineRgn(rgn1
, rgn1
, rgn2
, RGN_OR
);
9074 GetUpdateRgn(parent
, rgn2
, FALSE
);
9076 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
9078 /* hwnd has the same invalid region as before moving */
9079 SetRectRgn(rgn1
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
9080 GetUpdateRgn(hwnd
, rgn2
, FALSE
);
9081 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
9083 /* hwnd's invalid area maps to child during moving */
9084 SetRectRgn(rgn1
, rc
.left
- child_orig
.x
, rc
.top
- child_orig
.y
,
9085 rc
.right
- child_orig
.x
, rc
.bottom
- child_orig
.y
);
9086 GetUpdateRgn(child
, rgn2
, FALSE
);
9088 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
9092 DestroyWindow(parent
);
9095 static void test_window_without_child_style(void)
9099 hwnd
= CreateWindowExA(0, "edit", NULL
, WS_VISIBLE
|WS_CHILD
,
9100 0, 0, 50, 50, hwndMain
, NULL
, 0, NULL
);
9101 ok(hwnd
!= NULL
, "CreateWindow failed\n");
9103 ok(SetWindowLongA(hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) & (~WS_CHILD
)),
9104 "can't remove WS_CHILD style\n");
9106 SetActiveWindow(hwndMain
);
9107 PostMessageW(hwnd
, WM_LBUTTONUP
, 0, 0);
9108 SendMessageW(hwnd
, WM_NCLBUTTONDOWN
, HTCAPTION
, 0);
9109 check_active_state(hwnd
, hwnd
, hwnd
);
9112 DestroyWindow(hwnd
);
9116 struct smresult_thread_data
9120 HANDLE thread_started
;
9121 HANDLE thread_got_wm_app
;
9122 HANDLE main_in_wm_app_1
;
9123 HANDLE thread_replied
;
9127 static LRESULT WINAPI
smresult_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
9133 struct smresult_thread_data
*data
= (struct smresult_thread_data
*)lparam
;
9135 ok(hwnd
== data
->thread_hwnd
, "unexpected hwnd %p\n", hwnd
);
9137 SendNotifyMessageA(data
->main_hwnd
, WM_APP
+1, 0, lparam
);
9139 /* Don't return until the main thread is processing our sent message. */
9140 ok(WaitForSingleObject(data
->main_in_wm_app_1
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9142 /* Break the PeekMessage loop so we can notify the main thread after we return. */
9143 SetEvent(data
->thread_got_wm_app
);
9149 struct smresult_thread_data
*data
= (struct smresult_thread_data
*)lparam
;
9152 ok(hwnd
== data
->main_hwnd
, "unexpected hwnd %p\n", hwnd
);
9154 /* Ask the thread to reply to our WM_APP message. */
9155 SetEvent(data
->main_in_wm_app_1
);
9157 /* Wait until the thread has sent a reply. */
9158 ok(WaitForSingleObject(data
->thread_replied
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9160 /* Send another message while we have a reply queued for the current one. */
9161 res
= SendMessageA(data
->thread_hwnd
, WM_APP
+2, 0, lparam
);
9162 ok(res
== 0x449b0190, "unexpected result %lx\n", res
);
9168 struct smresult_thread_data
*data
= (struct smresult_thread_data
*)lparam
;
9170 ok(hwnd
== data
->thread_hwnd
, "unexpected hwnd %p\n", hwnd
);
9172 /* Don't return until we know the main thread is processing sent messages. */
9173 SendMessageA(data
->main_hwnd
, WM_NULL
, 0, 0);
9181 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
9184 static DWORD WINAPI
smresult_thread_proc(void *param
)
9187 struct smresult_thread_data
*data
= param
;
9189 data
->thread_hwnd
= CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW
,
9190 100, 100, 200, 200, 0, 0, 0, NULL
);
9191 ok(data
->thread_hwnd
!= 0, "Failed to create overlapped window\n");
9193 SetEvent(data
->thread_started
);
9195 /* Loop until we've processed WM_APP. */
9196 while (WaitForSingleObject(data
->thread_got_wm_app
, 0) != WAIT_OBJECT_0
)
9198 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
9200 TranslateMessage(&msg
);
9201 DispatchMessageA(&msg
);
9205 MsgWaitForMultipleObjects(1, &data
->thread_got_wm_app
, FALSE
, INFINITE
, QS_SENDMESSAGE
);
9209 /* Notify the main thread that we replied to its WM_APP message. */
9210 SetEvent(data
->thread_replied
);
9212 while (GetMessageA(&msg
, 0, 0, 0))
9214 TranslateMessage(&msg
);
9215 DispatchMessageA(&msg
);
9221 static void test_smresult(void)
9226 struct smresult_thread_data data
;
9230 cls
.style
= CS_DBLCLKS
;
9231 cls
.lpfnWndProc
= smresult_wndproc
;
9234 cls
.hInstance
= GetModuleHandleA(0);
9236 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
9237 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
9238 cls
.lpszMenuName
= NULL
;
9239 cls
.lpszClassName
= "SmresultClass";
9241 ret
= RegisterClassA(&cls
);
9242 ok(ret
, "RegisterClassA failed\n");
9244 data
.thread_started
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
9245 ok(data
.thread_started
!= NULL
, "CreateEventA failed\n");
9247 data
.thread_got_wm_app
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
9248 ok(data
.thread_got_wm_app
!= NULL
, "CreateEventA failed\n");
9250 data
.main_in_wm_app_1
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
9251 ok(data
.main_in_wm_app_1
!= NULL
, "CreateEventA failed\n");
9253 data
.thread_replied
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
9254 ok(data
.thread_replied
!= NULL
, "CreateEventA failed\n");
9256 data
.main_hwnd
= CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW
,
9257 100, 100, 200, 200, 0, 0, 0, NULL
);
9259 hThread
= CreateThread(NULL
, 0, smresult_thread_proc
, &data
, 0, &tid
);
9260 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
9262 ok(WaitForSingleObject(data
.thread_started
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9264 res
= SendMessageA(data
.thread_hwnd
, WM_APP
, 0, (LPARAM
)&data
);
9265 ok(res
== 0x240408ea, "unexpected result %lx\n", res
);
9267 SendMessageA(data
.thread_hwnd
, WM_CLOSE
, 0, 0);
9269 DestroyWindow(data
.main_hwnd
);
9271 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
9273 CloseHandle(data
.thread_started
);
9274 CloseHandle(data
.thread_got_wm_app
);
9275 CloseHandle(data
.main_in_wm_app_1
);
9276 CloseHandle(data
.thread_replied
);
9277 CloseHandle(hThread
);
9280 static void test_GetMessagePos(void)
9286 button
= CreateWindowExA(0, "button", "button", WS_VISIBLE
,
9287 100, 100, 100, 100, 0, 0, 0, NULL
);
9288 ok(button
!= 0, "CreateWindowExA failed\n");
9290 SetCursorPos(120, 140);
9292 pos
= GetMessagePos();
9293 ok(pos
== MAKELONG(120, 140), "pos = %08x\n", pos
);
9295 SetCursorPos(340, 320);
9296 pos
= GetMessagePos();
9297 ok(pos
== MAKELONG(120, 140), "pos = %08x\n", pos
);
9299 SendMessageW(button
, WM_APP
, 0, 0);
9300 pos
= GetMessagePos();
9301 ok(pos
== MAKELONG(120, 140), "pos = %08x\n", pos
);
9303 PostMessageA(button
, WM_APP
, 0, 0);
9304 GetMessageA(&msg
, button
, 0, 0);
9305 ok(msg
.message
== WM_APP
, "msg.message = %x\n", msg
.message
);
9306 pos
= GetMessagePos();
9307 ok(pos
== MAKELONG(340, 320), "pos = %08x\n", pos
);
9309 PostMessageA(button
, WM_APP
, 0, 0);
9310 SetCursorPos(350, 330);
9311 GetMessageA(&msg
, button
, 0, 0);
9312 ok(msg
.message
== WM_APP
, "msg.message = %x\n", msg
.message
);
9313 pos
= GetMessagePos();
9314 ok(pos
== MAKELONG(340, 320), "pos = %08x\n", pos
);
9316 PostMessageA(button
, WM_APP
, 0, 0);
9317 SetCursorPos(320, 340);
9318 PostMessageA(button
, WM_APP
+1, 0, 0);
9319 pos
= GetMessagePos();
9320 ok(pos
== MAKELONG(340, 320), "pos = %08x\n", pos
);
9321 GetMessageA(&msg
, button
, 0, 0);
9322 ok(msg
.message
== WM_APP
, "msg.message = %x\n", msg
.message
);
9323 pos
= GetMessagePos();
9324 ok(pos
== MAKELONG(350, 330), "pos = %08x\n", pos
);
9325 GetMessageA(&msg
, button
, 0, 0);
9326 ok(msg
.message
== WM_APP
+1, "msg.message = %x\n", msg
.message
);
9327 pos
= GetMessagePos();
9328 ok(pos
== MAKELONG(320, 340), "pos = %08x\n", pos
);
9330 SetTimer(button
, 1, 250, NULL
);
9331 SetCursorPos(330, 350);
9332 GetMessageA(&msg
, button
, 0, 0);
9333 while (msg
.message
== WM_PAINT
)
9335 UpdateWindow( button
);
9336 GetMessageA(&msg
, button
, 0, 0);
9338 ok(msg
.message
== WM_TIMER
, "msg.message = %x\n", msg
.message
);
9339 pos
= GetMessagePos();
9340 ok(pos
== MAKELONG(330, 350), "pos = %08x\n", pos
);
9341 KillTimer(button
, 1);
9343 DestroyWindow(button
);
9346 #define SET_FOREGROUND_STEAL_1 0x01
9347 #define SET_FOREGROUND_SET_1 0x02
9348 #define SET_FOREGROUND_STEAL_2 0x04
9349 #define SET_FOREGROUND_SET_2 0x08
9350 #define SET_FOREGROUND_INJECT 0x10
9352 struct set_foreground_thread_params
9354 UINT msg_quit
, msg_command
;
9355 HWND window1
, window2
, thread_window
;
9356 HANDLE command_executed
;
9359 static DWORD WINAPI
set_foreground_thread(void *params
)
9361 struct set_foreground_thread_params
*p
= params
;
9364 p
->thread_window
= CreateWindowExA(0, "static", "thread window", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9365 0, 0, 10, 10, 0, 0, 0, NULL
);
9366 SetEvent(p
->command_executed
);
9368 while(GetMessageA(&msg
, 0, 0, 0))
9370 if (msg
.message
== p
->msg_quit
)
9373 if (msg
.message
== p
->msg_command
)
9375 if (msg
.wParam
& SET_FOREGROUND_STEAL_1
)
9377 SetForegroundWindow(p
->thread_window
);
9378 check_wnd_state(p
->thread_window
, p
->thread_window
, p
->thread_window
, 0);
9380 if (msg
.wParam
& SET_FOREGROUND_INJECT
)
9382 SendNotifyMessageA(p
->window1
, WM_ACTIVATEAPP
, 0, 0);
9384 if (msg
.wParam
& SET_FOREGROUND_SET_1
)
9386 SetForegroundWindow(p
->window1
);
9387 check_wnd_state(0, p
->window1
, 0, 0);
9389 if (msg
.wParam
& SET_FOREGROUND_STEAL_2
)
9391 SetForegroundWindow(p
->thread_window
);
9392 check_wnd_state(p
->thread_window
, p
->thread_window
, p
->thread_window
, 0);
9394 if (msg
.wParam
& SET_FOREGROUND_SET_2
)
9396 SetForegroundWindow(p
->window2
);
9397 check_wnd_state(0, p
->window2
, 0, 0);
9400 SetEvent(p
->command_executed
);
9404 TranslateMessage(&msg
);
9405 DispatchMessageA(&msg
);
9408 DestroyWindow(p
->thread_window
);
9412 static void test_activateapp(HWND window1
)
9414 HWND window2
, test_window
;
9416 struct set_foreground_thread_params thread_params
;
9420 window2
= CreateWindowExA(0, "static", "window 2", WS_OVERLAPPEDWINDOW
| WS_VISIBLE
,
9421 300, 0, 10, 10, 0, 0, 0, NULL
);
9422 thread_params
.msg_quit
= WM_USER
;
9423 thread_params
.msg_command
= WM_USER
+ 1;
9424 thread_params
.window1
= window1
;
9425 thread_params
.window2
= window2
;
9426 thread_params
.command_executed
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
9428 thread
= CreateThread(NULL
, 0, set_foreground_thread
, &thread_params
, 0, &tid
);
9429 WaitForSingleObject(thread_params
.command_executed
, INFINITE
);
9431 SetForegroundWindow(window1
);
9432 check_wnd_state(window1
, window1
, window1
, 0);
9433 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9435 /* Steal foreground: WM_ACTIVATEAPP(0) is delivered. */
9436 app_activated
= app_deactivated
= FALSE
;
9437 PostThreadMessageA(tid
, thread_params
.msg_command
, SET_FOREGROUND_STEAL_1
, 0);
9438 WaitForSingleObject(thread_params
.command_executed
, INFINITE
);
9439 test_window
= GetForegroundWindow();
9440 ok(test_window
== thread_params
.thread_window
, "Expected foreground window %p, got %p\n",
9441 thread_params
.thread_window
, test_window
);
9442 /* Active and Focus window are sometimes 0 on KDE. Ignore them.
9443 * check_wnd_state(window1, thread_params.thread_window, window1, 0); */
9444 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9445 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9446 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9447 check_wnd_state(0, thread_params
.thread_window
, 0, 0);
9448 test_window
= GetForegroundWindow();
9449 ok(test_window
== thread_params
.thread_window
, "Expected foreground window %p, got %p\n",
9450 thread_params
.thread_window
, test_window
);
9451 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9452 /* This message is reliable on Windows and inside a virtual desktop.
9453 * It is unreliable on KDE (50/50) and never arrives on FVWM.
9454 * ok(app_deactivated, "Expected WM_ACTIVATEAPP(0), did not receive it.\n"); */
9456 /* Set foreground: WM_ACTIVATEAPP (1) is delivered. */
9457 app_activated
= app_deactivated
= FALSE
;
9458 PostThreadMessageA(tid
, thread_params
.msg_command
, SET_FOREGROUND_SET_1
, 0);
9459 WaitForSingleObject(thread_params
.command_executed
, INFINITE
);
9460 check_wnd_state(0, 0, 0, 0);
9461 test_window
= GetForegroundWindow();
9462 ok(!test_window
, "Expected foreground window 0, got %p\n", test_window
);
9463 ok(!app_activated
, "Received WM_ACTIVATEAPP(!= 0), did not expect it.\n");
9464 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9465 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9466 check_wnd_state(window1
, window1
, window1
, 0);
9467 test_window
= GetForegroundWindow();
9468 ok(test_window
== window1
, "Expected foreground window %p, got %p\n",
9469 window1
, test_window
);
9470 ok(app_activated
, "Expected WM_ACTIVATEAPP(1), did not receive it.\n");
9471 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9473 /* Steal foreground then set it back: No messages are delivered. */
9474 app_activated
= app_deactivated
= FALSE
;
9475 PostThreadMessageA(tid
, thread_params
.msg_command
, SET_FOREGROUND_STEAL_1
| SET_FOREGROUND_SET_1
, 0);
9476 WaitForSingleObject(thread_params
.command_executed
, INFINITE
);
9477 test_window
= GetForegroundWindow();
9478 ok(test_window
== window1
, "Expected foreground window %p, got %p\n",
9479 window1
, test_window
);
9480 check_wnd_state(window1
, window1
, window1
, 0);
9481 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9482 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9483 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9484 test_window
= GetForegroundWindow();
9485 ok(test_window
== window1
, "Expected foreground window %p, got %p\n",
9486 window1
, test_window
);
9487 check_wnd_state(window1
, window1
, window1
, 0);
9488 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9489 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9491 /* This is not implemented with a plain WM_ACTIVATEAPP filter. */
9492 app_activated
= app_deactivated
= FALSE
;
9493 PostThreadMessageA(tid
, thread_params
.msg_command
, SET_FOREGROUND_STEAL_1
9494 | SET_FOREGROUND_INJECT
| SET_FOREGROUND_SET_1
, 0);
9495 WaitForSingleObject(thread_params
.command_executed
, INFINITE
);
9496 test_window
= GetForegroundWindow();
9497 ok(test_window
== window1
, "Expected foreground window %p, got %p\n",
9498 window1
, test_window
);
9499 check_wnd_state(window1
, window1
, window1
, 0);
9500 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9501 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9502 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9503 test_window
= GetForegroundWindow();
9504 ok(test_window
== window1
, "Expected foreground window %p, got %p\n",
9505 window1
, test_window
);
9506 check_wnd_state(window1
, window1
, window1
, 0);
9507 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9508 ok(app_deactivated
, "Expected WM_ACTIVATEAPP(0), did not receive it.\n");
9510 SetForegroundWindow(thread_params
.thread_window
);
9512 /* Set foreground then remove: Both messages are delivered. */
9513 app_activated
= app_deactivated
= FALSE
;
9514 PostThreadMessageA(tid
, thread_params
.msg_command
, SET_FOREGROUND_SET_1
| SET_FOREGROUND_STEAL_2
, 0);
9515 WaitForSingleObject(thread_params
.command_executed
, INFINITE
);
9516 test_window
= GetForegroundWindow();
9517 ok(test_window
== thread_params
.thread_window
, "Expected foreground window %p, got %p\n",
9518 thread_params
.thread_window
, test_window
);
9519 check_wnd_state(0, thread_params
.thread_window
, 0, 0);
9520 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9521 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9522 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9523 test_window
= GetForegroundWindow();
9524 ok(test_window
== thread_params
.thread_window
, "Expected foreground window %p, got %p\n",
9525 thread_params
.thread_window
, test_window
);
9526 /* Active and focus are window1 on wine because the internal WM_WINE_SETACTIVEWINDOW(0)
9527 * message is never generated. GetCapture() returns 0 though, so we'd get a test success
9528 * in todo_wine in the line below.
9529 * todo_wine check_wnd_state(0, thread_params.thread_window, 0, 0); */
9530 ok(app_activated
, "Expected WM_ACTIVATEAPP(1), did not receive it.\n");
9531 todo_wine
ok(app_deactivated
, "Expected WM_ACTIVATEAPP(0), did not receive it.\n");
9533 SetForegroundWindow(window1
);
9534 test_window
= GetForegroundWindow();
9535 ok(test_window
== window1
, "Expected foreground window %p, got %p\n",
9536 window1
, test_window
);
9537 check_wnd_state(window1
, window1
, window1
, 0);
9539 /* Switch to a different window from the same thread? No messages. */
9540 app_activated
= app_deactivated
= FALSE
;
9541 PostThreadMessageA(tid
, thread_params
.msg_command
, SET_FOREGROUND_STEAL_1
| SET_FOREGROUND_SET_2
, 0);
9542 WaitForSingleObject(thread_params
.command_executed
, INFINITE
);
9543 test_window
= GetForegroundWindow();
9544 ok(test_window
== window1
, "Expected foreground window %p, got %p\n",
9545 window1
, test_window
);
9546 check_wnd_state(window1
, window1
, window1
, 0);
9547 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9548 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9549 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
9550 test_window
= GetForegroundWindow();
9551 ok(test_window
== window2
, "Expected foreground window %p, got %p\n",
9552 window2
, test_window
);
9553 check_wnd_state(window2
, window2
, window2
, 0);
9554 ok(!app_activated
, "Received WM_ACTIVATEAPP(1), did not expect it.\n");
9555 ok(!app_deactivated
, "Received WM_ACTIVATEAPP(0), did not expect it.\n");
9557 PostThreadMessageA(tid
, thread_params
.msg_quit
, 0, 0);
9558 WaitForSingleObject(thread
, INFINITE
);
9560 CloseHandle(thread_params
.command_executed
);
9561 DestroyWindow(window2
);
9564 static LRESULT WINAPI
winproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
9567 int *count
= (int*)lparam
;
9573 static LRESULT WINAPI
winproc_convA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
9575 if(msg
== WM_SETTEXT
)
9577 const char *text
= (const char*)lparam
;
9579 ok(!wparam
, "wparam = %08lx\n", wparam
);
9580 ok(!strcmp(text
, "text"), "WM_SETTEXT lparam = %s\n", text
);
9586 static const WCHAR textW
[] = {'t','e','x','t',0};
9587 static LRESULT WINAPI
winproc_convW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
9589 if(msg
== WM_SETTEXT
)
9591 const WCHAR
*text
= (const WCHAR
*)lparam
;
9593 ok(!wparam
, "wparam = %08lx\n", wparam
);
9594 ok(!lstrcmpW(text
, textW
), "WM_SETTEXT lparam = %s\n", wine_dbgstr_w(text
));
9600 static void test_winproc_handles(const char *argv0
)
9602 static const WCHAR winproc_testW
[] = {'w','i','n','p','r','o','c','_','t','e','s','t',0};
9604 HINSTANCE hinst
= GetModuleHandleA(NULL
);
9605 WNDCLASSA wnd_classA
;
9606 WNDCLASSW wnd_classW
;
9608 PROCESS_INFORMATION info
;
9609 STARTUPINFOA startup
;
9612 memset(&wnd_classA
, 0, sizeof(wnd_classA
));
9613 wnd_classA
.lpszClassName
= "winproc_test";
9614 wnd_classA
.lpfnWndProc
= winproc
;
9615 ret
= RegisterClassA(&wnd_classA
);
9616 ok(ret
, "RegisterClass failed with error %d\n", GetLastError());
9618 ret
= GetClassInfoW(hinst
, winproc_testW
, &wnd_classW
);
9619 ok(ret
, "GetClassInfoW failed with error %d\n", GetLastError());
9620 ok(wnd_classA
.lpfnWndProc
!= wnd_classW
.lpfnWndProc
,
9621 "winproc pointers should not be identical\n");
9624 CallWindowProcA(wnd_classW
.lpfnWndProc
, 0, 0, 0, (LPARAM
)&count
);
9625 ok(count
== 1, "winproc should be called once (%d)\n", count
);
9627 CallWindowProcW(wnd_classW
.lpfnWndProc
, 0, 0, 0, (LPARAM
)&count
);
9628 ok(count
== 1, "winproc should be called once (%d)\n", count
);
9630 ret
= UnregisterClassW(winproc_testW
, hinst
);
9631 ok(ret
, "UnregisterClass failed with error %d\n", GetLastError());
9633 /* crashes on 64-bit windows because lpfnWndProc handle is already freed */
9634 if (sizeof(void*) == 4)
9637 CallWindowProcA(wnd_classW
.lpfnWndProc
, 0, 0, 0, (LPARAM
)&count
);
9638 todo_wine
ok(!count
, "winproc should not be called (%d)\n", count
);
9639 CallWindowProcW(wnd_classW
.lpfnWndProc
, 0, 0, 0, (LPARAM
)&count
);
9640 todo_wine
ok(!count
, "winproc should not be called (%d)\n", count
);
9643 sprintf(cmd
, "%s win winproc_limit", argv0
);
9644 memset(&startup
, 0, sizeof(startup
));
9645 startup
.cb
= sizeof(startup
);
9646 ok(CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
,
9647 &startup
, &info
), "CreateProcess failed.\n");
9648 winetest_wait_child_process(info
.hProcess
);
9649 CloseHandle(info
.hProcess
);
9650 CloseHandle(info
.hThread
);
9653 static void test_winproc_limit(void)
9655 WNDPROC winproc_handle
;
9660 hwnd
= CreateWindowExA(0, "static", "test", WS_POPUP
, 0, 0, 0, 0, 0, 0, 0, 0);
9661 ok(hwnd
!= 0, "CreateWindowEx failed\n");
9663 ok(SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)winproc
),
9664 "SetWindowLongPtr failed\n");
9665 winproc_handle
= (WNDPROC
)GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
);
9666 ok(winproc_handle
!= winproc
, "winproc pointers should not be identical\n");
9668 /* run out of winproc slots */
9669 for(i
= 2; i
<0xffff; i
++)
9671 ok(SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, i
), "SetWindowLongPtr failed (%d)\n", i
);
9672 if(GetWindowLongPtrW(hwnd
, GWLP_WNDPROC
) == i
)
9675 ok(i
!= 0xffff, "unable to run out of winproc slots\n");
9677 ret
= SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)winproc_convA
);
9678 ok(ret
, "SetWindowLongPtr failed with error %d\n", GetLastError());
9679 ok(SendMessageA(hwnd
, WM_SETTEXT
, 0, (LPARAM
)"text"), "WM_SETTEXT failed\n");
9680 ok(SendMessageW(hwnd
, WM_SETTEXT
, 0, (LPARAM
)textW
), "WM_SETTEXT with conversion failed\n");
9682 ret
= SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)winproc_convW
);
9683 ok(ret
, "SetWindowLongPtr failed with error %d\n", GetLastError());
9684 ok(SendMessageA(hwnd
, WM_SETTEXT
, 0, (LPARAM
)"text"), "WM_SETTEXT failed\n");
9685 ok(SendMessageW(hwnd
, WM_SETTEXT
, 0, (LPARAM
)textW
), "WM_SETTEXT with conversion failed\n");
9687 /* Show that there's no message conversion when CallWindowProc is used */
9688 ok(CallWindowProcA(winproc_convW
, hwnd
, WM_SETTEXT
, 0, (LPARAM
)textW
) == 1,
9689 "winproc_convW returned error\n");
9690 ok(CallWindowProcW(winproc_convW
, hwnd
, WM_SETTEXT
, 0, (LPARAM
)textW
) == 1,
9691 "winproc_convW returned error\n");
9694 CallWindowProcA(winproc_handle
, 0, 0, 0, (LPARAM
)&i
);
9695 ok(i
== 1, "winproc should be called once (%d)\n", i
);
9697 CallWindowProcW(winproc_handle
, 0, 0, 0, (LPARAM
)&i
);
9698 ok(i
== 1, "winproc should be called once (%d)\n", i
);
9700 DestroyWindow(hwnd
);
9703 CallWindowProcA(winproc_handle
, 0, 0, 0, (LPARAM
)&i
);
9704 ok(i
== 1, "winproc should be called once (%d)\n", i
);
9706 CallWindowProcW(winproc_handle
, 0, 0, 0, (LPARAM
)&i
);
9707 ok(i
== 1, "winproc should be called once (%d)\n", i
);
9710 static void test_deferwindowpos(void)
9716 hdwp
= BeginDeferWindowPos(0);
9717 ok(hdwp
!= NULL
, "got %p\n", hdwp
);
9719 ret
= EndDeferWindowPos(NULL
);
9720 ok(!ret
, "got %d\n", ret
);
9722 hdwp2
= DeferWindowPos(NULL
, NULL
, NULL
, 0, 0, 10, 10, 0);
9724 ok(hdwp2
== NULL
&& ((GetLastError() == ERROR_INVALID_DWP_HANDLE
) ||
9725 broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
) /* before win8 */), "got %p, error %d\n", hdwp2
, GetLastError());
9727 hdwp2
= DeferWindowPos((HDWP
)0xdead, GetDesktopWindow(), NULL
, 0, 0, 10, 10, 0);
9729 ok(hdwp2
== NULL
&& ((GetLastError() == ERROR_INVALID_DWP_HANDLE
) ||
9730 broken(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
) /* before win8 */), "got %p, error %d\n", hdwp2
, GetLastError());
9732 hdwp2
= DeferWindowPos(hdwp
, NULL
, NULL
, 0, 0, 10, 10, 0);
9733 ok(hdwp2
== NULL
&& GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "got %p, error %d\n", hdwp2
, GetLastError());
9735 hdwp2
= DeferWindowPos(hdwp
, GetDesktopWindow(), NULL
, 0, 0, 10, 10, 0);
9736 ok(hdwp2
== NULL
&& GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "got %p, error %d\n", hdwp2
, GetLastError());
9738 hdwp2
= DeferWindowPos(hdwp
, (HWND
)0xdead, NULL
, 0, 0, 10, 10, 0);
9739 ok(hdwp2
== NULL
&& GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "got %p, error %d\n", hdwp2
, GetLastError());
9741 ret
= EndDeferWindowPos(hdwp
);
9742 ok(ret
, "got %d\n", ret
);
9743 hdwp
= BeginDeferWindowPos(0);
9744 ok(hdwp
!= NULL
, "got %p\n", hdwp
);
9746 hwnd
= create_tool_window(WS_POPUP
, 0);
9747 hdwp2
= DeferWindowPos(hdwp
, hwnd
, NULL
, 0, 0, 10, 10, 0);
9748 ok(hdwp2
!= NULL
, "got %p, error %d\n", hdwp2
, GetLastError());
9749 DestroyWindow(hwnd
);
9751 ret
= EndDeferWindowPos(hdwp
);
9752 ok(ret
, "got %d\n", ret
);
9755 static void test_LockWindowUpdate(HWND parent
)
9759 HWND hwnd_lock
, hwnd_draw
;
9765 HWND child
= CreateWindowA("static", 0, WS_CHILD
| WS_VISIBLE
, 0, 0, 20, 20, parent
, 0, 0, 0);
9768 {child
, child
, 0, 0},
9769 {child
, child
, 1, 1},
9770 {child
, parent
, 0, 1},
9771 {child
, parent
, 1, 1},
9772 {parent
, child
, 0, 0},
9773 {parent
, child
, 1, 1},
9774 {parent
, parent
, 0, 0},
9775 {parent
, parent
, 1, 1}
9780 skip("CreateWindow failed, skipping LockWindowUpdate tests\n");
9784 ShowWindow(parent
, SW_SHOW
);
9785 UpdateWindow(parent
);
9788 for (i
= 0; i
< sizeof(tests
) / sizeof(tests
[0]); ++i
)
9793 const DWORD dc_flags
= DCX_USESTYLE
| (tests
[i
].allow_drawing
? DCX_LOCKWINDOWUPDATE
: 0);
9794 const COLORREF c1
= 0x111100, c2
= 0x222200;
9796 hdc
= GetDCEx(tests
[i
].hwnd_draw
, 0, dc_flags
);
9798 #define TEST_PIXEL(c_valid, c_invalid) \
9800 COLORREF c = GetPixel(hdc, p.x, p.y); \
9801 COLORREF e = tests[i].expect_valid ? (c_valid) : (c_invalid); \
9802 todo_wine_if(!tests[i].expect_valid) \
9803 ok(c == e, "%u: GetPixel: got %08x, expected %08x\n", i, c, e); \
9806 SetPixel(hdc
, p
.x
, p
.y
, c1
);
9807 ret
= LockWindowUpdate(tests
[i
].hwnd_lock
);
9808 ok(ret
, "%u: LockWindowUpdate failed\n", i
);
9809 TEST_PIXEL(c1
, CLR_INVALID
);
9810 SetPixel(hdc
, p
.x
, p
.y
, c2
);
9811 TEST_PIXEL(c2
, CLR_INVALID
);
9812 LockWindowUpdate(0);
9814 ReleaseDC(tests
[i
].hwnd_draw
, hdc
);
9817 DestroyWindow(child
);
9820 static void test_hide_window(void)
9822 HWND hwnd
, hwnd2
, hwnd3
;
9824 hwnd
= CreateWindowExA(0, "MainWindowClass", "Main window", WS_POPUP
| WS_VISIBLE
,
9825 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9826 hwnd2
= CreateWindowExA(0, "MainWindowClass", "Main window 2", WS_POPUP
| WS_VISIBLE
,
9827 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9828 if (winetest_debug
> 1) trace("hwnd = %p, hwnd2 = %p\n", hwnd
, hwnd2
);
9829 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9830 ok(GetWindow(hwnd2
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd2
, GW_HWNDNEXT
));
9832 /* test hiding two normal windows */
9833 ShowWindow(hwnd2
, SW_HIDE
);
9834 check_active_state(hwnd
, hwnd
, hwnd
);
9836 ok(GetWindow(hwnd
, GW_HWNDNEXT
) == hwnd2
, "expected %p, got %p\n", hwnd2
, GetWindow(hwnd
, GW_HWNDNEXT
));
9838 ShowWindow(hwnd
, SW_HIDE
);
9839 check_active_state(hwndMain
, 0, hwndMain
);
9840 ok(GetWindow(hwnd
, GW_HWNDNEXT
) == hwnd2
, "expected %p, got %p\n", hwnd2
, GetWindow(hwnd
, GW_HWNDNEXT
));
9842 ShowWindow(hwnd
, SW_SHOW
);
9843 check_active_state(hwnd
, hwnd
, hwnd
);
9845 ShowWindow(hwnd2
, SW_SHOW
);
9846 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9847 ok(GetWindow(hwnd2
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd2
, GW_HWNDNEXT
));
9849 /* hide a non-active window */
9850 ShowWindow(hwnd
, SW_HIDE
);
9851 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9853 ok(GetWindow(hwnd2
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd2
, GW_HWNDNEXT
));
9855 /* hide a window in the middle */
9856 ShowWindow(hwnd
, SW_SHOW
);
9857 ShowWindow(hwnd2
, SW_SHOW
);
9858 hwnd3
= CreateWindowExA(0, "MainWindowClass", "Main window 3", WS_POPUP
| WS_VISIBLE
,
9859 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9860 SetActiveWindow(hwnd2
);
9861 ShowWindow(hwnd2
, SW_HIDE
);
9862 check_active_state(hwnd3
, hwnd3
, hwnd3
);
9864 ok(GetWindow(hwnd3
, GW_HWNDNEXT
) == hwnd2
, "expected %p, got %p\n", hwnd2
, GetWindow(hwnd3
, GW_HWNDNEXT
));
9865 ok(GetWindow(hwnd2
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd2
, GW_HWNDNEXT
));
9868 DestroyWindow(hwnd3
);
9870 /* hide a normal window when there is a topmost window */
9871 hwnd3
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", "Topmost window 3", WS_POPUP
|WS_VISIBLE
,
9872 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9873 ShowWindow(hwnd
, SW_SHOW
);
9874 ShowWindow(hwnd2
, SW_SHOW
);
9875 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9876 ShowWindow(hwnd2
, SW_HIDE
);
9878 check_active_state(hwnd3
, hwnd3
, hwnd3
);
9879 ok(GetWindow(hwnd2
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd2
, GW_HWNDNEXT
));
9881 /* hide a topmost window */
9882 ShowWindow(hwnd2
, SW_SHOW
);
9883 ShowWindow(hwnd3
, SW_SHOW
);
9884 ShowWindow(hwnd3
, SW_HIDE
);
9885 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9886 ok(GetWindow(hwnd2
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd2
, GW_HWNDNEXT
));
9888 DestroyWindow(hwnd3
);
9890 /* hiding an owned window activates its owner */
9891 ShowWindow(hwnd
, SW_SHOW
);
9892 ShowWindow(hwnd2
, SW_SHOW
);
9893 hwnd3
= CreateWindowExA(0, "MainWindowClass", "Owned window 3", WS_POPUP
|WS_VISIBLE
,
9894 100, 100, 200, 200, hwnd
, 0, GetModuleHandleA(NULL
), NULL
);
9895 ShowWindow(hwnd3
, SW_HIDE
);
9896 check_active_state(hwnd
, hwnd
, hwnd
);
9898 ok(GetWindow(hwnd3
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd3
, GW_HWNDNEXT
));
9899 ok(GetWindow(hwnd
, GW_HWNDNEXT
) == hwnd2
, "expected %p, got %p\n", hwnd2
, GetWindow(hwnd
, GW_HWNDNEXT
));
9902 /* hide an owner window */
9903 ShowWindow(hwnd
, SW_SHOW
);
9904 ShowWindow(hwnd2
, SW_SHOW
);
9905 ShowWindow(hwnd3
, SW_SHOW
);
9906 ShowWindow(hwnd
, SW_HIDE
);
9907 check_active_state(hwnd3
, hwnd3
, hwnd3
);
9908 ok(GetWindow(hwnd3
, GW_HWNDNEXT
) == hwnd
, "expected %p, got %p\n", hwnd
, GetWindow(hwnd3
, GW_HWNDNEXT
));
9909 ok(GetWindow(hwnd
, GW_HWNDNEXT
) == hwnd2
, "expected %p, got %p\n", hwnd2
, GetWindow(hwnd
, GW_HWNDNEXT
));
9911 DestroyWindow(hwnd3
);
9912 DestroyWindow(hwnd2
);
9913 DestroyWindow(hwnd
);
9916 static void test_minimize_window(HWND hwndMain
)
9918 HWND hwnd
, hwnd2
, hwnd3
;
9920 hwnd
= CreateWindowExA(0, "MainWindowClass", "Main window", WS_POPUP
| WS_VISIBLE
,
9921 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9922 hwnd2
= CreateWindowExA(0, "MainWindowClass", "Main window 2", WS_POPUP
| WS_VISIBLE
,
9923 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9924 if (winetest_debug
> 1) trace("hwnd = %p, hwnd2 = %p\n", hwnd
, hwnd2
);
9925 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9927 /* test hiding two normal windows */
9928 ShowWindow(hwnd2
, SW_MINIMIZE
);
9930 check_active_state(hwnd
, hwnd
, hwnd
);
9932 ShowWindow(hwnd
, SW_MINIMIZE
);
9934 if (GetActiveWindow() == 0)
9935 check_active_state(0, 0, 0);
9937 ShowWindow(hwnd
, SW_RESTORE
);
9938 check_active_state(hwnd
, hwnd
, hwnd
);
9940 ShowWindow(hwnd2
, SW_RESTORE
);
9941 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9943 /* try SW_SHOWMINIMIZED */
9944 ShowWindow(hwnd2
, SW_SHOWMINIMIZED
);
9945 check_active_state(hwnd2
, hwnd2
, 0);
9947 ShowWindow(hwnd2
, SW_RESTORE
);
9948 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9950 /* hide a non-active window */
9951 ShowWindow(hwnd
, SW_MINIMIZE
);
9952 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9954 /* hide a window in the middle */
9955 ShowWindow(hwnd
, SW_RESTORE
);
9956 ShowWindow(hwnd2
, SW_RESTORE
);
9957 hwnd3
= CreateWindowExA(0, "MainWindowClass", "Main window 3", WS_POPUP
| WS_VISIBLE
,
9958 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9959 SetActiveWindow(hwnd2
);
9960 ShowWindow(hwnd2
, SW_MINIMIZE
);
9962 check_active_state(hwnd3
, hwnd3
, hwnd3
);
9964 DestroyWindow(hwnd3
);
9966 /* hide a normal window when there is a topmost window */
9967 hwnd3
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", "Topmost window 3", WS_POPUP
|WS_VISIBLE
,
9968 100, 100, 200, 200, 0, 0, GetModuleHandleA(NULL
), NULL
);
9969 ShowWindow(hwnd
, SW_RESTORE
);
9970 ShowWindow(hwnd2
, SW_RESTORE
);
9971 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9972 ShowWindow(hwnd2
, SW_MINIMIZE
);
9974 check_active_state(hwnd3
, hwnd3
, hwnd3
);
9976 /* hide a topmost window */
9977 ShowWindow(hwnd2
, SW_RESTORE
);
9978 ShowWindow(hwnd3
, SW_RESTORE
);
9979 ShowWindow(hwnd3
, SW_MINIMIZE
);
9980 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9982 DestroyWindow(hwnd3
);
9984 /* hide an owned window */
9985 ShowWindow(hwnd
, SW_RESTORE
);
9986 ShowWindow(hwnd2
, SW_RESTORE
);
9987 hwnd3
= CreateWindowExA(0, "MainWindowClass", "Owned window 3", WS_POPUP
|WS_VISIBLE
,
9988 100, 100, 200, 200, hwnd
, 0, GetModuleHandleA(NULL
), NULL
);
9989 ShowWindow(hwnd3
, SW_MINIMIZE
);
9991 check_active_state(hwnd2
, hwnd2
, hwnd2
);
9993 /* with SW_SHOWMINIMIZED */
9994 ShowWindow(hwnd3
, SW_RESTORE
);
9995 ShowWindow(hwnd3
, SW_SHOWMINIMIZED
);
9996 check_active_state(hwnd3
, hwnd3
, 0);
9998 /* hide an owner window */
9999 ShowWindow(hwnd
, SW_RESTORE
);
10000 ShowWindow(hwnd2
, SW_RESTORE
);
10001 ShowWindow(hwnd3
, SW_RESTORE
);
10002 ShowWindow(hwnd
, SW_MINIMIZE
);
10004 check_active_state(hwnd2
, hwnd2
, hwnd2
);
10006 DestroyWindow(hwnd3
);
10008 /* test a child window - focus should be yielded back to the parent */
10009 ShowWindow(hwnd
, SW_RESTORE
);
10010 hwnd3
= CreateWindowExA(0, "MainWindowClass", "Child window 3", WS_CHILD
|WS_VISIBLE
,
10011 100, 100, 200, 200, hwnd
, 0, GetModuleHandleA(NULL
), NULL
);
10013 check_active_state(hwnd
, hwnd
, hwnd3
);
10014 ShowWindow(hwnd3
, SW_MINIMIZE
);
10015 check_active_state(hwnd
, hwnd
, hwnd
);
10017 /* with SW_SHOWMINIMIZED */
10018 ShowWindow(hwnd3
, SW_RESTORE
);
10020 check_active_state(hwnd
, hwnd
, hwnd3
);
10021 ShowWindow(hwnd3
, SW_SHOWMINIMIZED
);
10022 check_active_state(hwnd
, hwnd
, hwnd
);
10024 DestroyWindow(hwnd3
);
10025 DestroyWindow(hwnd2
);
10026 DestroyWindow(hwnd
);
10029 static void test_desktop( void )
10031 HWND desktop
= GetDesktopWindow();
10032 /* GetWindowLong Desktop window tests */
10033 static const struct
10041 { GWLP_USERDATA
, 0, 0 },
10042 { GWL_STYLE
, WS_POPUP
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
, 0 },
10043 { GWL_EXSTYLE
, 0, 0 },
10045 { GWLP_HWNDPARENT
, 0, 0 },
10046 /* GWLP_HINSTANCE - not useful and not consistent between Windows versions */
10047 { GWLP_WNDPROC
, 0, ERROR_ACCESS_DENIED
},
10048 { DWLP_MSGRESULT
, 0, ERROR_INVALID_INDEX
}
10053 for (i
= 0; i
< sizeof(tests
) / sizeof(tests
[0]); i
++)
10055 SetLastError( 0xdeadbeef );
10056 result
= GetWindowLongPtrW( desktop
, tests
[i
].offset
);
10057 ok( result
== tests
[i
].expect
, "offset %d, got %08lx expect %08lx\n",
10058 tests
[i
].offset
, result
, tests
[i
].expect
);
10059 if (tests
[i
].error
)
10060 ok( GetLastError() == tests
[i
].error
, "offset %d: error %d expect %d\n",
10061 tests
[i
].offset
, GetLastError(), tests
[i
].error
);
10063 ok( GetLastError() == 0xdeadbeef, "offset %d: error %d expect unchanged\n",
10064 tests
[i
].offset
, GetLastError() );
10068 static BOOL
is_topmost(HWND hwnd
)
10070 return (GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
) != 0;
10073 static void swp_after(HWND hwnd
, HWND after
)
10077 ret
= SetWindowPos(hwnd
, after
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
10078 ok(ret
, "SetWindowPos failed\n");
10079 flush_events( TRUE
);
10082 static void reset_window_state(HWND
*state
, int n
)
10086 for (i
= 0; i
< n
; i
++)
10090 swp_after(state
[i
], HWND_NOTOPMOST
);
10091 todo_wine_if(i
== 5) /* FIXME: remove once Wine is fixed */
10092 ok(!is_topmost(state
[i
]), "%d: hwnd %p is still topmost\n", i
, state
[i
]);
10093 swp_after(state
[i
], HWND_TOP
);
10098 static void test_topmost(void)
10100 HWND owner
, hwnd
, hwnd2
, hwnd_child
, hwnd_child2
, hwnd_grandchild
, state
[6] = { 0 };
10101 BOOL is_wine
= !strcmp(winetest_platform
, "wine");
10103 owner
= create_tool_window(WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
10104 WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
, 0);
10105 ok(owner
!= 0, "Failed to create owner window (%d)\n", GetLastError());
10107 /* Give current thread foreground state otherwise the tests may fail. */
10108 if (!SetForegroundWindow(owner
))
10110 DestroyWindow(owner
);
10111 skip("SetForegroundWindow not working\n");
10115 hwnd
= create_tool_window(WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
10116 WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
, owner
);
10117 ok(hwnd
!= 0, "Failed to create popup window (%d)\n", GetLastError());
10118 hwnd2
= create_tool_window(WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
10119 WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
, owner
);
10120 ok(hwnd2
!= 0, "Failed to create popup window (%d)\n", GetLastError());
10122 flush_events( TRUE
);
10124 if (winetest_debug
> 1) trace("owner %p, hwnd %p, hwnd2 %p\n", owner
, hwnd
, hwnd2
);
10129 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10130 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10131 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10132 check_z_order(hwnd
, 0, hwnd2
, owner
, FALSE
);
10134 swp_after(hwnd
, HWND_TOPMOST
);
10135 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10136 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10137 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10138 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10139 swp_after(hwnd
, HWND_TOP
);
10140 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10141 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10142 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10143 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10144 swp_after(hwnd
, HWND_NOTOPMOST
);
10145 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10146 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10147 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10148 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10149 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10151 swp_after(hwnd
, HWND_TOPMOST
);
10152 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10153 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10154 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10155 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10156 swp_after(hwnd2
, hwnd
);
10157 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10158 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10159 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10160 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10161 swp_after(hwnd
, hwnd2
);
10162 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10163 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10164 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10165 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10166 swp_after(hwnd2
, HWND_TOP
);
10167 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10168 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10169 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10170 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10171 swp_after(owner
, HWND_TOPMOST
);
10173 ok(is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10174 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10176 ok(is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10177 swp_after(hwnd
, HWND_NOTOPMOST
);
10178 ok(!is_topmost(owner
) || broken(is_topmost(owner
)) /*win7 64-bit*/, "hwnd %p topmost state is wrong\n", owner
);
10179 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10180 ok(!is_topmost(hwnd2
) || broken(is_topmost(hwnd2
)) /*win7 64-bit*/, "hwnd %p topmost state is wrong\n", hwnd2
);
10181 if (0) /*win7 64-bit is broken*/
10182 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10183 swp_after(hwnd2
, HWND_NOTOPMOST
);
10184 ok(!is_topmost(owner
) || broken(is_topmost(owner
)) /*win7 64-bit*/, "hwnd %p topmost state is wrong\n", owner
);
10185 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10186 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10187 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10188 check_z_order(hwnd
, 0, hwnd2
, owner
, FALSE
);
10189 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10191 swp_after(hwnd
, HWND_TOPMOST
);
10192 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10193 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10194 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10195 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10196 swp_after(hwnd
, HWND_BOTTOM
);
10197 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10199 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10200 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10201 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10202 check_z_order(hwnd
, 0, hwnd2
, owner
, FALSE
);
10203 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10205 swp_after(hwnd
, HWND_TOPMOST
);
10206 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10207 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10208 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10209 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10210 swp_after(hwnd
, hwnd2
);
10211 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10213 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10214 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10215 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10216 check_z_order(hwnd
, 0, hwnd2
, owner
, FALSE
);
10217 /* FIXME: compensate todo_wine above */
10218 swp_after(hwnd
, HWND_NOTOPMOST
);
10219 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10220 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10221 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10222 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10223 check_z_order(hwnd
, 0, hwnd2
, owner
, FALSE
);
10224 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10226 hwnd_child2
= create_tool_window(WS_VISIBLE
|WS_POPUP
, hwnd
);
10227 ok(hwnd_child2
!= 0, "Failed to create popup window (%d)\n", GetLastError());
10228 hwnd_child
= create_tool_window(WS_VISIBLE
|WS_POPUP
, hwnd
);
10229 ok(hwnd_child
!= 0, "Failed to create popup window (%d)\n", GetLastError());
10230 hwnd_grandchild
= create_tool_window(WS_VISIBLE
|WS_POPUP
, hwnd_child
);
10231 ok(hwnd_grandchild
!= 0, "Failed to create popup window (%d)\n", GetLastError());
10233 flush_events( TRUE
);
10235 if (winetest_debug
> 1)
10236 trace("hwnd_child %p, hwnd_child2 %p, hwnd_grandchild %p\n", hwnd_child
, hwnd_child2
, hwnd_grandchild
);
10237 state
[3] = hwnd_child2
;
10238 state
[4] = hwnd_child
;
10239 state
[5] = hwnd_grandchild
;
10241 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10242 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10243 ok(!is_topmost(hwnd2
), "hwnd %p topmost state is wrong\n", hwnd2
);
10244 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10245 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10246 ok(!is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10247 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10248 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10249 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, FALSE
);
10251 swp_after(hwnd
, HWND_TOPMOST
);
10252 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10254 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10256 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10258 ok(is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10259 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10260 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10261 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10262 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10263 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10264 swp_after(hwnd
, HWND_NOTOPMOST
);
10265 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10266 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10267 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10268 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10270 ok(!is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10271 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10272 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10273 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, FALSE
);
10274 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10276 swp_after(hwnd
, HWND_TOPMOST
);
10277 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10279 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10281 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10283 ok(is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10284 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10285 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10286 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10287 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10288 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10289 swp_after(hwnd_child
, HWND_NOTOPMOST
);
10290 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10291 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10292 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10293 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10295 ok(!is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10296 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10297 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, FALSE
);
10298 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10300 swp_after(hwnd
, HWND_TOPMOST
);
10301 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10303 ok(is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10305 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10307 ok(is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10308 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10309 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10310 check_z_order(hwnd
, hwnd2
, 0, owner
, TRUE
);
10311 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10312 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10313 swp_after(hwnd_grandchild
, HWND_NOTOPMOST
);
10314 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10315 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10316 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10317 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10319 ok(!is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10320 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10321 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, FALSE
);
10322 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10324 swp_after(hwnd_child
, HWND_TOPMOST
);
10325 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10326 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10328 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10329 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10330 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10331 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10332 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10333 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10334 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10335 swp_after(hwnd_child
, HWND_TOP
);
10336 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10337 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10339 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10340 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10341 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10342 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10343 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10344 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10345 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10346 swp_after(hwnd
, HWND_NOTOPMOST
);
10347 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10348 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10349 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10350 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10352 ok(!is_topmost(hwnd_grandchild
) || broken(is_topmost(hwnd_grandchild
))/*win2008 64-bit*/, "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10353 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10354 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10355 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, FALSE
);
10356 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10358 swp_after(hwnd_child
, HWND_TOPMOST
);
10359 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10360 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10362 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10363 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10364 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10365 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10366 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10367 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10368 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10369 swp_after(hwnd
, HWND_NOTOPMOST
);
10370 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10371 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10372 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10373 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10375 ok(!is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10376 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10377 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10378 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, FALSE
);
10379 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10381 swp_after(hwnd_grandchild
, HWND_TOPMOST
);
10382 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10383 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10384 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10385 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10386 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10387 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10388 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10389 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, FALSE
);
10390 swp_after(hwnd_child2
, HWND_NOTOPMOST
);
10391 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10392 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10393 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10394 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10395 ok(is_topmost(hwnd_grandchild
) || broken(!is_topmost(hwnd_grandchild
)) /* win8+ */, "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10396 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10397 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10398 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10399 check_z_order(hwnd_child
, 0, hwnd_child2
, hwnd
, FALSE
);
10400 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10402 swp_after(hwnd_child
, HWND_TOPMOST
);
10403 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10404 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10406 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10407 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10408 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10409 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10410 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10411 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10412 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10413 swp_after(hwnd_child
, HWND_BOTTOM
);
10414 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10415 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10416 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10417 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10419 ok(!is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10420 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10421 check_z_order(hwnd
, 0, hwnd2
, owner
, FALSE
);
10422 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10423 check_z_order(hwnd_child
, 0, hwnd_child2
, hwnd
, FALSE
);
10424 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10426 swp_after(hwnd_child
, HWND_TOPMOST
);
10427 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10428 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10430 ok(is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10431 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10432 ok(is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10433 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10434 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10435 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10436 check_z_order(hwnd_child
, hwnd_child2
, 0, hwnd
, TRUE
);
10437 swp_after(hwnd_child
, hwnd_child2
);
10438 ok(!is_topmost(owner
), "hwnd %p topmost state is wrong\n", owner
);
10439 ok(!is_topmost(hwnd
), "hwnd %p topmost state is wrong\n", hwnd
);
10440 ok(!is_topmost(hwnd_child
), "hwnd %p topmost state is wrong\n", hwnd_child
);
10441 ok(!is_topmost(hwnd_child2
), "hwnd %p topmost state is wrong\n", hwnd_child2
);
10443 ok(!is_topmost(hwnd_grandchild
), "hwnd %p topmost state is wrong\n", hwnd_grandchild
);
10444 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10445 check_z_order(hwnd
, hwnd2
, 0, owner
, FALSE
);
10446 if (!is_wine
) /* FIXME: remove once Wine is fixed */
10447 check_z_order(hwnd_child
, 0, hwnd_child2
, hwnd
, FALSE
);
10448 reset_window_state(state
, sizeof(state
)/sizeof(state
[0]));
10450 DestroyWindow(hwnd_grandchild
);
10451 DestroyWindow(hwnd_child
);
10452 DestroyWindow(hwnd_child2
);
10453 DestroyWindow(hwnd
);
10454 DestroyWindow(hwnd2
);
10455 DestroyWindow(owner
);
10458 static void test_display_affinity( HWND win
)
10464 if (!pGetWindowDisplayAffinity
|| !pSetWindowDisplayAffinity
)
10466 win_skip("GetWindowDisplayAffinity or SetWindowDisplayAffinity missing\n");
10470 ret
= pGetWindowDisplayAffinity(NULL
, NULL
);
10471 ok(!ret
, "GetWindowDisplayAffinity succeeded\n");
10472 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "Expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
10474 ret
= pGetWindowDisplayAffinity(NULL
, &affinity
);
10475 ok(!ret
, "GetWindowDisplayAffinity succeeded\n");
10476 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "Expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
10478 ret
= pGetWindowDisplayAffinity(win
, NULL
);
10479 ok(!ret
, "GetWindowDisplayAffinity succeeded\n");
10480 ok(GetLastError() == ERROR_NOACCESS
, "Expected ERROR_NOACCESS, got %u\n", GetLastError());
10482 styleex
= GetWindowLongW(win
, GWL_EXSTYLE
);
10483 SetWindowLongW(win
, GWL_EXSTYLE
, styleex
& ~WS_EX_LAYERED
);
10485 affinity
= 0xdeadbeef;
10486 ret
= pGetWindowDisplayAffinity(win
, &affinity
);
10487 ok(ret
, "GetWindowDisplayAffinity failed with %u\n", GetLastError());
10488 ok(affinity
== WDA_NONE
, "Expected WDA_NONE, got 0x%x\n", affinity
);
10490 /* Windows 7 fails with ERROR_NOT_ENOUGH_MEMORY when dwm compositing is disabled */
10491 ret
= pSetWindowDisplayAffinity(win
, WDA_MONITOR
);
10492 ok(ret
|| GetLastError() == ERROR_NOT_ENOUGH_MEMORY
,
10493 "SetWindowDisplayAffinity failed with %u\n", GetLastError());
10496 affinity
= 0xdeadbeef;
10497 ret
= pGetWindowDisplayAffinity(win
, &affinity
);
10498 ok(ret
, "GetWindowDisplayAffinity failed with %u\n", GetLastError());
10499 if (dwm
) ok(affinity
== WDA_MONITOR
, "Expected WDA_MONITOR, got 0x%x\n", affinity
);
10500 else ok(affinity
== WDA_NONE
, "Expected WDA_NONE, got 0x%x\n", affinity
);
10502 ret
= pSetWindowDisplayAffinity(win
, WDA_NONE
);
10503 ok(ret
|| GetLastError() == ERROR_NOT_ENOUGH_MEMORY
,
10504 "SetWindowDisplayAffinity failed with %u\n", GetLastError());
10506 affinity
= 0xdeadbeef;
10507 ret
= pGetWindowDisplayAffinity(win
, &affinity
);
10508 ok(ret
, "GetWindowDisplayAffinity failed with %u\n", GetLastError());
10509 ok(affinity
== WDA_NONE
, "Expected WDA_NONE, got 0x%x\n", affinity
);
10511 SetWindowLongW(win
, GWL_EXSTYLE
, styleex
| WS_EX_LAYERED
);
10513 affinity
= 0xdeadbeef;
10514 ret
= pGetWindowDisplayAffinity(win
, &affinity
);
10515 ok(ret
, "GetWindowDisplayAffinity failed with %u\n", GetLastError());
10516 ok(affinity
== WDA_NONE
, "Expected WDA_NONE, got 0x%x\n", affinity
);
10518 ret
= pSetWindowDisplayAffinity(win
, WDA_MONITOR
);
10519 ok(ret
|| GetLastError() == ERROR_NOT_ENOUGH_MEMORY
,
10520 "SetWindowDisplayAffinity failed with %u\n", GetLastError());
10522 affinity
= 0xdeadbeef;
10523 ret
= pGetWindowDisplayAffinity(win
, &affinity
);
10524 ok(ret
, "GetWindowDisplayAffinity failed with %u\n", GetLastError());
10525 if (dwm
) ok(affinity
== WDA_MONITOR
, "Expected WDA_MONITOR, got 0x%x\n", affinity
);
10526 else ok(affinity
== WDA_NONE
, "Expected WDA_NONE, got 0x%x\n", affinity
);
10528 ret
= pSetWindowDisplayAffinity(win
, WDA_NONE
);
10529 ok(ret
|| GetLastError() == ERROR_NOT_ENOUGH_MEMORY
,
10530 "SetWindowDisplayAffinity failed with %u\n", GetLastError());
10532 affinity
= 0xdeadbeef;
10533 ret
= pGetWindowDisplayAffinity(win
, &affinity
);
10534 ok(ret
, "GetWindowDisplayAffinity failed with %u\n", GetLastError());
10535 ok(affinity
== WDA_NONE
, "Expected WDA_NONE, got 0x%x\n", affinity
);
10537 SetWindowLongW(win
, GWL_EXSTYLE
, styleex
);
10540 static struct destroy_data
10547 DWORD destroy_count
;
10548 DWORD ncdestroy_count
;
10551 static LRESULT WINAPI
destroy_thread1_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
10556 ok( destroy_data
.destroy_count
> 0, "parent didn't get WM_DESTROY\n" );
10557 PostQuitMessage(0);
10560 ok( destroy_data
.ncdestroy_count
> 0, "parent didn't get WM_NCDESTROY\n" );
10563 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
10566 static LRESULT WINAPI
destroy_thread2_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
10571 ok( destroy_data
.destroy_count
> 0, "parent didn't get WM_DESTROY\n" );
10574 ok( destroy_data
.ncdestroy_count
> 0, "parent didn't get WM_NCDESTROY\n" );
10575 ok( WaitForSingleObject(destroy_data
.evt
, 10000) != WAIT_TIMEOUT
, "timeout\n" );
10576 PostQuitMessage(0);
10579 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
10582 static LRESULT WINAPI
destroy_main_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
10587 destroy_data
.destroy_count
++;
10590 destroy_data
.ncdestroy_count
++;
10593 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
10596 static DWORD CALLBACK
destroy_thread1(void *user
)
10600 destroy_data
.thread1_wnd
= CreateWindowExA(0, "destroy_test_thread1",
10601 "destroy test thread", WS_CHILD
, 100, 100, 100, 100,
10602 destroy_data
.main_wnd
, 0, GetModuleHandleA(NULL
), NULL
);
10603 ok(destroy_data
.thread1_wnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
10604 PostThreadMessageW(destroy_data
.main_tid
, WM_USER
, 0, 0);
10606 while (GetMessageA(&msg
, 0, 0, 0))
10608 TranslateMessage(&msg
);
10609 DispatchMessageA(&msg
);
10611 PostThreadMessageW(destroy_data
.main_tid
, WM_USER
+ 2, 0, 0);
10612 ok( WaitForSingleObject(destroy_data
.evt
, 10000) != WAIT_TIMEOUT
, "timeout\n" );
10613 ok( IsWindow( destroy_data
.thread1_wnd
), "window destroyed\n" );
10617 static DWORD CALLBACK
destroy_thread2(void *user
)
10621 destroy_data
.thread2_wnd
= CreateWindowExA(0, "destroy_test_thread2",
10622 "destroy test thread", WS_CHILD
, 100, 100, 100, 100,
10623 destroy_data
.main_wnd
, 0, GetModuleHandleA(NULL
), NULL
);
10624 ok(destroy_data
.thread2_wnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
10626 PostThreadMessageW(destroy_data
.main_tid
, WM_USER
+ 1, 0, 0);
10629 while (GetMessageA(&msg
, 0, 0, 0))
10631 TranslateMessage(&msg
);
10632 DispatchMessageA(&msg
);
10634 ok( !IsWindow( destroy_data
.thread2_wnd
), "window not destroyed\n" );
10638 static void test_destroy_quit(void)
10641 WNDCLASSA wnd_classA
;
10643 HANDLE thread1
, thread2
;
10645 destroy_data
.main_tid
= GetCurrentThreadId();
10646 destroy_data
.evt
= CreateEventW(NULL
, TRUE
, FALSE
, NULL
);
10647 destroy_data
.destroy_count
= 0;
10648 destroy_data
.ncdestroy_count
= 0;
10650 memset(&wnd_classA
, 0, sizeof(wnd_classA
));
10651 wnd_classA
.lpszClassName
= "destroy_test_main";
10652 wnd_classA
.lpfnWndProc
= destroy_main_wndproc
;
10653 ret
= RegisterClassA(&wnd_classA
);
10654 ok(ret
, "RegisterClass failed with error %d\n", GetLastError());
10656 wnd_classA
.lpszClassName
= "destroy_test_thread1";
10657 wnd_classA
.lpfnWndProc
= destroy_thread1_wndproc
;
10658 ret
= RegisterClassA(&wnd_classA
);
10659 ok(ret
, "RegisterClass failed with error %d\n", GetLastError());
10661 wnd_classA
.lpszClassName
= "destroy_test_thread2";
10662 wnd_classA
.lpfnWndProc
= destroy_thread2_wndproc
;
10663 ret
= RegisterClassA(&wnd_classA
);
10664 ok(ret
, "RegisterClass failed with error %d\n", GetLastError());
10666 destroy_data
.main_wnd
= CreateWindowExA(0, "destroy_test_main",
10667 "destroy test main", WS_OVERLAPPED
| WS_CAPTION
, 100, 100, 100, 100,
10668 0, 0, GetModuleHandleA(NULL
), NULL
);
10669 ok(destroy_data
.main_wnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
10670 if (!destroy_data
.main_wnd
)
10672 CloseHandle(destroy_data
.evt
);
10676 thread1
= CreateThread(NULL
, 0, destroy_thread1
, 0, 0, NULL
);
10678 while (GetMessageA(&msg
, 0, 0, 0))
10681 switch (msg
.message
)
10684 thread2
= CreateThread(NULL
, 0, destroy_thread2
, 0, 0, NULL
);
10685 CloseHandle( thread2
);
10688 DestroyWindow(destroy_data
.main_wnd
);
10691 SetEvent(destroy_data
.evt
);
10695 DispatchMessageA(&msg
);
10701 ok( WaitForSingleObject( thread1
, 10000 ) != WAIT_TIMEOUT
, "timeout" );
10702 ok( !IsWindow( destroy_data
.thread1_wnd
), "window not destroyed\n" );
10703 CloseHandle( thread1
);
10709 int argc
= winetest_get_mainargs( &argv
);
10710 HMODULE user32
= GetModuleHandleA( "user32.dll" );
10711 HMODULE gdi32
= GetModuleHandleA("gdi32.dll");
10712 pGetAncestor
= (void *)GetProcAddress( user32
, "GetAncestor" );
10713 pGetWindowInfo
= (void *)GetProcAddress( user32
, "GetWindowInfo" );
10714 pGetWindowModuleFileNameA
= (void *)GetProcAddress( user32
, "GetWindowModuleFileNameA" );
10715 pGetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "GetLayeredWindowAttributes" );
10716 pSetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "SetLayeredWindowAttributes" );
10717 pUpdateLayeredWindow
= (void *)GetProcAddress( user32
, "UpdateLayeredWindow" );
10718 pUpdateLayeredWindowIndirect
= (void *)GetProcAddress( user32
, "UpdateLayeredWindowIndirect" );
10719 pGetMonitorInfoA
= (void *)GetProcAddress( user32
, "GetMonitorInfoA" );
10720 pMonitorFromPoint
= (void *)GetProcAddress( user32
, "MonitorFromPoint" );
10721 pGetWindowRgnBox
= (void *)GetProcAddress( user32
, "GetWindowRgnBox" );
10722 pGetGUIThreadInfo
= (void *)GetProcAddress( user32
, "GetGUIThreadInfo" );
10723 pGetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "GetProcessDefaultLayout" );
10724 pSetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "SetProcessDefaultLayout" );
10725 pFlashWindow
= (void *)GetProcAddress( user32
, "FlashWindow" );
10726 pFlashWindowEx
= (void *)GetProcAddress( user32
, "FlashWindowEx" );
10727 pGetLayout
= (void *)GetProcAddress( gdi32
, "GetLayout" );
10728 pSetLayout
= (void *)GetProcAddress( gdi32
, "SetLayout" );
10729 pMirrorRgn
= (void *)GetProcAddress( gdi32
, "MirrorRgn" );
10730 pGetWindowDisplayAffinity
= (void *)GetProcAddress( user32
, "GetWindowDisplayAffinity" );
10731 pSetWindowDisplayAffinity
= (void *)GetProcAddress( user32
, "SetWindowDisplayAffinity" );
10732 pAdjustWindowRectExForDpi
= (void *)GetProcAddress( user32
, "AdjustWindowRectExForDpi" );
10733 pSystemParametersInfoForDpi
= (void *)GetProcAddress( user32
, "SystemParametersInfoForDpi" );
10735 if (argc
==4 && !strcmp(argv
[2], "create_children"))
10739 sscanf(argv
[3], "%p", &hwnd
);
10740 window_from_point_proc(hwnd
);
10744 if (argc
==3 && !strcmp(argv
[2], "winproc_limit"))
10746 test_winproc_limit();
10750 if (!RegisterWindowClasses()) assert(0);
10752 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
10753 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
10754 WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
,
10755 100, 100, 200, 200,
10756 0, 0, GetModuleHandleA(NULL
), NULL
);
10757 assert( hwndMain
);
10759 if(!SetForegroundWindow(hwndMain
)) {
10760 /* workaround for foreground lock timeout */
10761 simulate_click(101, 101);
10762 ok(SetForegroundWindow(hwndMain
), "SetForegroundWindow failed\n");
10765 SetLastError(0xdeafbeef);
10766 GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC
);
10768 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
10769 if (!hhook
) win_skip( "Cannot set CBT hook, skipping some tests\n" );
10771 /* make sure that these tests are executed first */
10772 test_FindWindowEx();
10776 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
10777 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
10778 WS_MAXIMIZEBOX
| WS_POPUP
,
10779 100, 100, 200, 200,
10780 0, 0, GetModuleHandleA(NULL
), NULL
);
10781 assert( hwndMain2
);
10783 our_pid
= GetWindowThreadProcessId(hwndMain
, NULL
);
10785 /* Add the tests below this line */
10786 test_child_window_from_point();
10787 test_window_from_point(argv
[0]);
10788 test_thick_child_size(hwndMain
);
10790 test_hwnd_message();
10791 test_nonclient_area(hwndMain
);
10793 test_GetWindowModuleFileName();
10796 test_capture_3(hwndMain
, hwndMain2
);
10799 test_FlashWindow();
10800 test_FlashWindowEx();
10802 test_CreateWindow();
10803 test_parent_owner();
10804 test_enum_thread_windows();
10808 test_SetWindowPos(hwndMain
, hwndMain2
);
10809 test_SetMenu(hwndMain
);
10810 test_SetFocus(hwndMain
);
10811 test_SetActiveWindow(hwndMain
);
10814 test_children_zorder(hwndMain
);
10815 test_popup_zorder(hwndMain2
, hwndMain
, WS_POPUP
);
10816 test_popup_zorder(hwndMain2
, hwndMain
, 0);
10817 test_GetLastActivePopup();
10818 test_keyboard_input(hwndMain
);
10819 test_mouse_input(hwndMain
);
10820 test_validatergn(hwndMain
);
10821 test_nccalcscroll( hwndMain
);
10822 test_scrollwindow( hwndMain
);
10823 test_scrollvalidate( hwndMain
);
10824 test_scrolldc( hwndMain
);
10826 test_IsWindowUnicode();
10827 test_vis_rgn(hwndMain
);
10829 test_AdjustWindowRect();
10830 test_window_styles();
10831 test_dialog_styles();
10832 test_dialog_parent();
10835 test_SetWindowLong();
10836 test_set_window_style();
10838 test_EnableWindow();
10840 test_GetUpdateRect();
10842 test_layered_window();
10844 test_SetForegroundWindow(hwndMain
);
10845 test_shell_window();
10846 test_handles( hwndMain
);
10849 test_update_region();
10850 test_window_without_child_style();
10852 test_GetMessagePos();
10853 test_activateapp(hwndMain
);
10854 test_winproc_handles(argv
[0]);
10855 test_deferwindowpos();
10856 test_LockWindowUpdate(hwndMain
);
10858 test_display_affinity(hwndMain
);
10859 test_hide_window();
10860 test_minimize_window(hwndMain
);
10861 test_destroy_quit();
10863 /* add the tests above this line */
10864 if (hhook
) UnhookWindowsHookEx(hhook
);
10866 DestroyWindow(hwndMain2
);
10867 DestroyWindow(hwndMain
);
10869 /* Make sure that following tests are executed last, under Windows they
10870 * tend to break the tests which are sensitive to z-order and activation
10871 * state of hwndMain and hwndMain2 windows.