2 * Unit tests for window handling
4 * Copyright 2002 Bill Medland
5 * Copyright 2002 Alexandre Julliard
6 * Copyright 2003 Dmitry Timoshkov
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 /* To get ICON_SMALL2 with the MSVC headers */
24 #define _WIN32_WINNT 0x0501
36 #include "wine/test.h"
38 #ifndef SPI_GETDESKWALLPAPER
39 #define SPI_GETDESKWALLPAPER 0x0073
42 #define LONG_PTR INT_PTR
43 #define ULONG_PTR UINT_PTR
45 void dump_region(HRGN hrgn
);
47 static HWND (WINAPI
*pGetAncestor
)(HWND
,UINT
);
48 static BOOL (WINAPI
*pGetWindowInfo
)(HWND
,WINDOWINFO
*);
49 static UINT (WINAPI
*pGetWindowModuleFileNameA
)(HWND
,LPSTR
,UINT
);
50 static BOOL (WINAPI
*pGetLayeredWindowAttributes
)(HWND
,COLORREF
*,BYTE
*,DWORD
*);
51 static BOOL (WINAPI
*pSetLayeredWindowAttributes
)(HWND
,COLORREF
,BYTE
,DWORD
);
52 static BOOL (WINAPI
*pUpdateLayeredWindow
)(HWND
,HDC
,POINT
*,SIZE
*,HDC
,POINT
*,COLORREF
,BLENDFUNCTION
*,DWORD
);
53 static BOOL (WINAPI
*pUpdateLayeredWindowIndirect
)(HWND
,const UPDATELAYEREDWINDOWINFO
*);
54 static BOOL (WINAPI
*pGetMonitorInfoA
)(HMONITOR
,LPMONITORINFO
);
55 static HMONITOR (WINAPI
*pMonitorFromPoint
)(POINT
,DWORD
);
56 static int (WINAPI
*pGetWindowRgnBox
)(HWND
,LPRECT
);
57 static BOOL (WINAPI
*pGetGUIThreadInfo
)(DWORD
, GUITHREADINFO
*);
58 static BOOL (WINAPI
*pGetProcessDefaultLayout
)( DWORD
*layout
);
59 static BOOL (WINAPI
*pSetProcessDefaultLayout
)( DWORD layout
);
60 static BOOL (WINAPI
*pFlashWindowEx
)( PFLASHWINFO pfwi
);
61 static DWORD (WINAPI
*pSetLayout
)(HDC hdc
, DWORD layout
);
62 static DWORD (WINAPI
*pGetLayout
)(HDC hdc
);
63 static BOOL (WINAPI
*pMirrorRgn
)(HWND hwnd
, HRGN hrgn
);
65 static BOOL test_lbuttondown_flag
;
66 static DWORD num_gettext_msgs
;
67 static DWORD num_settext_msgs
;
68 static HWND hwndMessage
;
69 static HWND hwndMain
, hwndMain2
;
72 static const char* szAWRClass
= "Winsize";
76 static BOOL is_win9x
= FALSE
;
78 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
80 static void dump_minmax_info( const MINMAXINFO
*minmax
)
82 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
83 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
84 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
85 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
86 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
87 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
90 /* try to make sure pending X events have been processed before continuing */
91 static void flush_events( BOOL remove_messages
)
95 int min_timeout
= 100;
96 DWORD time
= GetTickCount() + diff
;
100 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
102 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
103 diff
= time
- GetTickCount();
108 static BOOL
wait_for_event(HANDLE event
, int timeout
)
110 DWORD end_time
= GetTickCount() + timeout
;
114 if(MsgWaitForMultipleObjects(1, &event
, FALSE
, timeout
, QS_ALLINPUT
) == WAIT_OBJECT_0
)
116 while(PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
117 DispatchMessageA(&msg
);
118 timeout
= end_time
- GetTickCount();
124 /* check the values returned by the various parent/owner functions on a given window */
125 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
126 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
132 res
= pGetAncestor( hwnd
, GA_PARENT
);
133 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
135 res
= (HWND
)GetWindowLongPtrA( hwnd
, GWLP_HWNDPARENT
);
136 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
137 res
= GetParent( hwnd
);
138 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
139 res
= GetWindow( hwnd
, GW_OWNER
);
140 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
143 res
= pGetAncestor( hwnd
, GA_ROOT
);
144 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
145 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
146 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
150 #define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
151 static void check_wnd_state_(const char *file
, int line
,
152 HWND active
, HWND foreground
, HWND focus
, HWND capture
)
154 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
155 /* only check foreground if it belongs to the current thread */
156 /* foreground can be moved to a different app pretty much at any time */
157 if (foreground
&& GetForegroundWindow() &&
158 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
159 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
160 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
161 ok_(file
, line
)(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
164 /* same as above but without capture test */
165 #define check_active_state(a,b,c) check_active_state_(__FILE__,__LINE__,a,b,c)
166 static void check_active_state_(const char *file
, int line
,
167 HWND active
, HWND foreground
, HWND focus
)
169 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
170 /* only check foreground if it belongs to the current thread */
171 /* foreground can be moved to a different app pretty much at any time */
172 if (foreground
&& GetForegroundWindow() &&
173 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
174 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
175 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
178 static BOOL
ignore_message( UINT message
)
180 /* these are always ignored */
181 return (message
>= 0xc000 ||
182 message
== WM_GETICON
||
183 message
== WM_GETOBJECT
||
184 message
== WM_TIMECHANGE
||
185 message
== WM_DEVICECHANGE
);
188 static BOOL CALLBACK
EnumChildProc( HWND hwndChild
, LPARAM lParam
)
191 trace("EnumChildProc on %p\n", hwndChild
);
192 if (*(LPINT
)lParam
> 1) return FALSE
;
196 /* will search for the given window */
197 static BOOL CALLBACK
EnumChildProc1( HWND hwndChild
, LPARAM lParam
)
199 trace("EnumChildProc1 on %p\n", hwndChild
);
200 if ((HWND
)lParam
== hwndChild
) return FALSE
;
204 static HWND
create_tool_window( LONG style
, HWND parent
)
206 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
207 0, 0, 100, 100, parent
, 0, 0, NULL
);
208 ok( ret
!= 0, "Creation failed\n" );
212 /* test parent and owner values for various combinations */
213 static void test_parent_owner(void)
216 HWND test
, owner
, ret
;
217 HWND desktop
= GetDesktopWindow();
218 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
221 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
223 /* child without parent, should fail */
224 SetLastError(0xdeadbeef);
225 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
226 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
227 ok( !test
, "WS_CHILD without parent created\n" );
228 ok( GetLastError() == ERROR_TLW_WITH_WSCHILD
||
229 broken(GetLastError() == 0xdeadbeef), /* win9x */
230 "CreateWindowExA error %u\n", GetLastError() );
233 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
234 style
= GetWindowLongA( desktop
, GWL_STYLE
);
235 ok( !SetWindowLongA( desktop
, GWL_STYLE
, WS_POPUP
), "Set GWL_STYLE on desktop succeeded\n" );
236 ok( !SetWindowLongA( desktop
, GWL_STYLE
, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
237 ok( GetWindowLongA( desktop
, GWL_STYLE
) == style
, "Desktop style changed\n" );
239 /* normal child window */
240 test
= create_tool_window( WS_CHILD
, hwndMain
);
241 trace( "created child %p\n", test
);
242 check_parents( test
, hwndMain
, hwndMain
, hwndMain
, 0, hwndMain
, hwndMain
);
243 SetWindowLongA( test
, GWL_STYLE
, 0 );
244 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
245 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
246 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
247 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
248 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
249 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
250 DestroyWindow( test
);
252 /* normal child window with WS_MAXIMIZE */
253 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
254 DestroyWindow( test
);
256 /* normal child window with WS_THICKFRAME */
257 test
= create_tool_window( WS_CHILD
| WS_THICKFRAME
, hwndMain
);
258 DestroyWindow( test
);
260 /* popup window with WS_THICKFRAME */
261 test
= create_tool_window( WS_POPUP
| WS_THICKFRAME
, hwndMain
);
262 DestroyWindow( test
);
264 /* child of desktop */
265 test
= create_tool_window( WS_CHILD
, desktop
);
266 trace( "created child of desktop %p\n", test
);
267 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
268 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
269 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
270 SetWindowLongA( test
, GWL_STYLE
, 0 );
271 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
272 DestroyWindow( test
);
274 /* child of desktop with WS_MAXIMIZE */
275 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, desktop
);
276 DestroyWindow( test
);
278 /* child of desktop with WS_MINIMIZE */
279 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, desktop
);
280 DestroyWindow( test
);
283 test
= create_tool_window( WS_CHILD
, child
);
284 trace( "created child of child %p\n", test
);
285 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
286 SetWindowLongA( test
, GWL_STYLE
, 0 );
287 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
288 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
289 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
290 DestroyWindow( test
);
292 /* child of child with WS_MAXIMIZE */
293 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, child
);
294 DestroyWindow( test
);
296 /* child of child with WS_MINIMIZE */
297 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, child
);
298 DestroyWindow( test
);
300 /* not owned top-level window */
301 test
= create_tool_window( 0, 0 );
302 trace( "created top-level %p\n", test
);
303 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
304 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
305 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
306 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
307 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
308 DestroyWindow( test
);
310 /* not owned top-level window with WS_MAXIMIZE */
311 test
= create_tool_window( WS_MAXIMIZE
, 0 );
312 DestroyWindow( test
);
314 /* owned top-level window */
315 test
= create_tool_window( 0, hwndMain
);
316 trace( "created owned top-level %p\n", test
);
317 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
318 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
319 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
320 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
321 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
322 DestroyWindow( test
);
324 /* owned top-level window with WS_MAXIMIZE */
325 test
= create_tool_window( WS_MAXIMIZE
, hwndMain
);
326 DestroyWindow( test
);
328 /* not owned popup */
329 test
= create_tool_window( WS_POPUP
, 0 );
330 trace( "created popup %p\n", test
);
331 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
332 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
333 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
334 SetWindowLongA( test
, GWL_STYLE
, 0 );
335 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
336 DestroyWindow( test
);
338 /* not owned popup with WS_MAXIMIZE */
339 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, 0 );
340 DestroyWindow( test
);
343 test
= create_tool_window( WS_POPUP
, hwndMain
);
344 trace( "created owned popup %p\n", test
);
345 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
346 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
347 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
348 SetWindowLongA( test
, GWL_STYLE
, 0 );
349 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
350 DestroyWindow( test
);
352 /* owned popup with WS_MAXIMIZE */
353 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, hwndMain
);
354 DestroyWindow( test
);
356 /* top-level window owned by child (same as owned by top-level) */
357 test
= create_tool_window( 0, child
);
358 trace( "created top-level owned by child %p\n", test
);
359 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
360 DestroyWindow( test
);
362 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
363 test
= create_tool_window( WS_MAXIMIZE
, child
);
364 DestroyWindow( test
);
366 /* popup owned by desktop (same as not owned) */
367 test
= create_tool_window( WS_POPUP
, desktop
);
368 trace( "created popup owned by desktop %p\n", test
);
369 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
370 DestroyWindow( test
);
372 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
373 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, desktop
);
374 DestroyWindow( test
);
376 /* popup owned by child (same as owned by top-level) */
377 test
= create_tool_window( WS_POPUP
, child
);
378 trace( "created popup owned by child %p\n", test
);
379 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
380 DestroyWindow( test
);
382 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
383 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, child
);
384 DestroyWindow( test
);
386 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
387 test
= create_tool_window( WS_POPUP
| WS_CHILD
, 0 );
388 trace( "created WS_CHILD popup %p\n", test
);
389 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
390 DestroyWindow( test
);
392 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
393 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, 0 );
394 DestroyWindow( test
);
396 /* owned popup with WS_CHILD (same as WS_POPUP only) */
397 test
= create_tool_window( WS_POPUP
| WS_CHILD
, hwndMain
);
398 trace( "created owned WS_CHILD popup %p\n", test
);
399 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
400 DestroyWindow( test
);
402 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
403 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
404 DestroyWindow( test
);
406 /******************** parent changes *************************/
407 trace( "testing parent changes\n" );
410 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
413 /* this test succeeds on NT but crashes on win9x systems */
414 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
415 ok( !ret
, "Set GWL_HWNDPARENT succeeded on desktop\n" );
416 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
417 ok( !SetParent( desktop
, hwndMain
), "SetParent succeeded on desktop\n" );
418 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
420 /* normal child window */
421 test
= create_tool_window( WS_CHILD
, hwndMain
);
422 trace( "created child %p\n", test
);
424 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
425 ok( ret
== hwndMain
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain
);
426 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
428 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
429 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
430 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
432 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)desktop
);
433 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
434 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
436 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
439 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)test
);
440 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
441 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
444 win_skip("Test creates circular window tree under Win9x/WinMe\n" );
446 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
447 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
448 check_parents( test
, desktop
, child
, desktop
, child
, test
, desktop
);
450 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
451 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
452 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
453 DestroyWindow( test
);
455 /* not owned top-level window */
456 test
= create_tool_window( 0, 0 );
457 trace( "created top-level %p\n", test
);
459 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
460 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
461 check_parents( test
, desktop
, hwndMain2
, 0, hwndMain2
, test
, test
);
463 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
464 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
465 check_parents( test
, desktop
, child
, 0, child
, test
, test
);
467 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
468 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
469 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
470 DestroyWindow( test
);
472 /* not owned popup */
473 test
= create_tool_window( WS_POPUP
, 0 );
474 trace( "created popup %p\n", test
);
476 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
477 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
478 check_parents( test
, desktop
, hwndMain2
, hwndMain2
, hwndMain2
, test
, hwndMain2
);
480 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
481 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
482 check_parents( test
, desktop
, child
, child
, child
, test
, hwndMain
);
484 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
485 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
486 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
487 DestroyWindow( test
);
489 /* normal child window */
490 test
= create_tool_window( WS_CHILD
, hwndMain
);
491 trace( "created child %p\n", test
);
493 ret
= SetParent( test
, desktop
);
494 ok( ret
== hwndMain
, "SetParent return value %p expected %p\n", ret
, hwndMain
);
495 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
497 ret
= SetParent( test
, child
);
498 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
499 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
501 ret
= SetParent( test
, hwndMain2
);
502 ok( ret
== child
, "SetParent return value %p expected %p\n", ret
, child
);
503 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
504 DestroyWindow( test
);
506 /* not owned top-level window */
507 test
= create_tool_window( 0, 0 );
508 trace( "created top-level %p\n", test
);
510 ret
= SetParent( test
, child
);
511 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
512 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
516 ShowWindow( test
, SW_SHOW
);
517 ret
= SetParent( test
, test
);
518 ok( ret
== NULL
, "SetParent return value %p expected %p\n", ret
, NULL
);
519 ok( GetWindowLongA( test
, GWL_STYLE
) & WS_VISIBLE
, "window is not visible after SetParent\n" );
520 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
523 win_skip( "Test crashes on Win9x/WinMe\n" );
524 DestroyWindow( test
);
527 test
= create_tool_window( WS_POPUP
, hwndMain2
);
528 trace( "created owned popup %p\n", test
);
530 ret
= SetParent( test
, child
);
531 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
532 check_parents( test
, child
, child
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
534 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)hwndMain
);
535 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
536 check_parents( test
, hwndMain
, hwndMain
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
537 DestroyWindow( test
);
539 /**************** test owner destruction *******************/
541 /* owned child popup */
542 owner
= create_tool_window( 0, 0 );
543 test
= create_tool_window( WS_POPUP
, owner
);
544 trace( "created owner %p and popup %p\n", owner
, test
);
545 ret
= SetParent( test
, child
);
546 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
547 check_parents( test
, child
, child
, owner
, owner
, hwndMain
, owner
);
548 /* window is now child of 'child' but owned by 'owner' */
549 DestroyWindow( owner
);
550 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
551 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
552 * while Win95, Win2k, WinXP do.
554 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
555 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
558 /* owned top-level popup */
559 owner
= create_tool_window( 0, 0 );
560 test
= create_tool_window( WS_POPUP
, owner
);
561 trace( "created owner %p and popup %p\n", owner
, test
);
562 check_parents( test
, desktop
, owner
, owner
, owner
, test
, owner
);
563 DestroyWindow( owner
);
564 ok( !IsWindow(test
), "Window %p not destroyed by owner destruction\n", test
);
566 /* top-level popup owned by child */
567 owner
= create_tool_window( WS_CHILD
, hwndMain2
);
568 test
= create_tool_window( WS_POPUP
, 0 );
569 trace( "created owner %p and popup %p\n", owner
, test
);
570 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)owner
);
571 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
572 check_parents( test
, desktop
, owner
, owner
, owner
, test
, hwndMain2
);
573 DestroyWindow( owner
);
574 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
575 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
576 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
577 * while Win95, Win2k, WinXP do.
579 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
583 DestroyWindow(child
);
586 owner
= create_tool_window( WS_OVERLAPPED
, 0 );
587 test
= create_tool_window( WS_POPUP
, desktop
);
589 ok( !GetWindow( test
, GW_OWNER
), "Wrong owner window\n" );
591 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
592 "EnumChildWindows should have returned FALSE\n" );
593 ok( numChildren
== 0, "numChildren should be 0 got %d\n", numChildren
);
595 SetWindowLongA( test
, GWL_STYLE
, (GetWindowLongA( test
, GWL_STYLE
) & ~WS_POPUP
) | WS_CHILD
);
596 ret
= SetParent( test
, owner
);
597 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
600 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
601 "EnumChildWindows should have returned TRUE\n" );
602 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
604 child
= create_tool_window( WS_CHILD
, owner
);
606 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
607 "EnumChildWindows should have returned FALSE\n" );
608 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
609 DestroyWindow( child
);
611 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
612 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
614 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
615 "EnumChildWindows should have returned TRUE\n" );
616 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
618 ret
= SetParent( child
, owner
);
619 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
620 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
622 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
623 "EnumChildWindows should have returned FALSE\n" );
624 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
626 ret
= SetParent( child
, NULL
);
627 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
628 ok( ret
== owner
, "SetParent return value %p expected %p\n", ret
, owner
);
630 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
631 "EnumChildWindows should have returned TRUE\n" );
632 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
634 /* even GW_OWNER == owner it's still a desktop's child */
635 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
636 "EnumChildWindows should have found %p and returned FALSE\n", child
);
638 DestroyWindow( child
);
639 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, NULL
);
641 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
642 "EnumChildWindows should have found %p and returned FALSE\n", child
);
644 DestroyWindow( child
);
645 DestroyWindow( test
);
646 DestroyWindow( owner
);
649 static BOOL CALLBACK
enum_proc( HWND hwnd
, LPARAM lParam
)
652 if (*(LPINT
)lParam
> 2) return FALSE
;
655 static DWORD CALLBACK
enum_thread( void *arg
)
662 if (pGetGUIThreadInfo
)
665 info
.cbSize
= sizeof(info
);
666 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
667 ok( ret
|| broken(!ret
), /* win9x */
668 "GetGUIThreadInfo failed without message queue\n" );
669 SetLastError( 0xdeadbeef );
670 info
.cbSize
= sizeof(info
) + 1;
671 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
672 ok( !ret
, "GetGUIThreadInfo succeeded with wrong size\n" );
673 ok( GetLastError() == ERROR_INVALID_PARAMETER
||
674 broken(GetLastError() == 0xdeadbeef), /* win9x */
675 "wrong error %u\n", GetLastError() );
678 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
); /* make sure we have a message queue */
681 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
682 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
683 ok( count
== 0, "count should be 0 got %d\n", count
);
685 hwnd
[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP
,
686 0, 0, 100, 100, 0, 0, 0, NULL
);
688 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
689 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
690 if (count
!= 2) /* Vista gives us two windows for the price of one */
692 ok( count
== 1, "count should be 1 got %d\n", count
);
693 hwnd
[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP
,
694 0, 0, 100, 100, 0, 0, 0, NULL
);
698 hwnd
[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP
,
699 0, 0, 100, 100, 0, 0, 0, NULL
);
701 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
702 ok( !ret
, "EnumThreadWindows should have returned FALSE\n" );
703 ok( count
== 3, "count should be 3 got %d\n", count
);
705 if (hwnd
[2]) DestroyWindow(hwnd
[2]);
706 DestroyWindow(hwnd
[1]);
707 DestroyWindow(hwnd
[0]);
711 /* test EnumThreadWindows in a separate thread */
712 static void test_enum_thread_windows(void)
715 HANDLE handle
= CreateThread( NULL
, 0, enum_thread
, 0, 0, &id
);
716 ok( !WaitForSingleObject( handle
, 10000 ), "wait failed\n" );
717 CloseHandle( handle
);
720 static struct wm_gettext_override_data
722 BOOL enabled
; /* when 1 bypasses default procedure */
723 char *buff
; /* expected text buffer pointer */
724 WCHAR
*buffW
; /* same, for W test */
725 } g_wm_gettext_override
;
727 static LRESULT WINAPI
main_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
731 case WM_GETMINMAXINFO
:
733 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
736 case WM_WINDOWPOSCHANGING
:
738 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
739 if (!(winpos
->flags
& SWP_NOMOVE
))
741 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
742 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
744 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
745 if (!(winpos
->flags
& SWP_NOSIZE
) && !is_win9x
)
747 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
748 winpos
->cx
== 32768, /* win7 doesn't truncate */
749 "bad winpos->cx %d\n", winpos
->cx
);
750 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
751 winpos
->cy
== 40000, /* win7 doesn't truncate */
752 "bad winpos->cy %d\n", winpos
->cy
);
756 case WM_WINDOWPOSCHANGED
:
759 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
760 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
761 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
763 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
764 winpos
->cx
== 32768, /* win7 doesn't truncate */
765 "bad winpos->cx %d\n", winpos
->cx
);
766 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
767 winpos
->cy
== 40000, /* win7 doesn't truncate */
768 "bad winpos->cy %d\n", winpos
->cy
);
770 GetWindowRect(hwnd
, &rc1
);
771 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
772 /* note: winpos coordinates are relative to parent */
773 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
776 /* Uncomment this once the test succeeds in all cases */
777 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
778 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
780 GetClientRect(hwnd
, &rc2
);
781 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
782 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
783 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
784 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
790 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
791 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
793 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
794 ok(got_getminmaxinfo
, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
796 ok(!got_getminmaxinfo
, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
800 if (test_lbuttondown_flag
)
802 ShowWindow((HWND
)wparam
, SW_SHOW
);
803 flush_events( FALSE
);
808 if (g_wm_gettext_override
.enabled
)
810 char *text
= (char*)lparam
;
811 ok(g_wm_gettext_override
.buff
== text
, "expected buffer %p, got %p\n", g_wm_gettext_override
.buff
, text
);
812 ok(*text
== 0, "expected empty string buffer %x\n", *text
);
821 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
824 static LRESULT WINAPI
main_window_procW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
830 if (g_wm_gettext_override
.enabled
)
832 WCHAR
*text
= (WCHAR
*)lparam
;
833 ok(g_wm_gettext_override
.buffW
== text
, "expected buffer %p, got %p\n", g_wm_gettext_override
.buffW
, text
);
834 ok(*text
== 0, "expected empty string buffer %x\n", *text
);
840 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
843 static LRESULT WINAPI
tool_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
847 case WM_GETMINMAXINFO
:
849 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
854 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
855 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
857 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
858 ok(got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
860 ok(!got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
865 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
868 static const WCHAR mainclassW
[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s','W',0};
870 static BOOL
RegisterWindowClasses(void)
875 cls
.style
= CS_DBLCLKS
;
876 cls
.lpfnWndProc
= main_window_procA
;
879 cls
.hInstance
= GetModuleHandleA(0);
881 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
882 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
883 cls
.lpszMenuName
= NULL
;
884 cls
.lpszClassName
= "MainWindowClass";
886 if(!RegisterClassA(&cls
)) return FALSE
;
888 clsW
.style
= CS_DBLCLKS
;
889 clsW
.lpfnWndProc
= main_window_procW
;
892 clsW
.hInstance
= GetModuleHandleA(0);
894 clsW
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
895 clsW
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
896 clsW
.lpszMenuName
= NULL
;
897 clsW
.lpszClassName
= mainclassW
;
899 if(!RegisterClassW(&clsW
)) return FALSE
;
902 cls
.lpfnWndProc
= tool_window_procA
;
905 cls
.hInstance
= GetModuleHandleA(0);
907 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
908 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
909 cls
.lpszMenuName
= NULL
;
910 cls
.lpszClassName
= "ToolWindowClass";
912 if(!RegisterClassA(&cls
)) return FALSE
;
917 static void verify_window_info(const char *hook
, HWND hwnd
, const WINDOWINFO
*info
)
919 RECT rcWindow
, rcClient
;
922 ok(IsWindow(hwnd
), "bad window handle %p in hook %s\n", hwnd
, hook
);
924 GetWindowRect(hwnd
, &rcWindow
);
925 ok(EqualRect(&rcWindow
, &info
->rcWindow
), "wrong rcWindow for %p in hook %s\n", hwnd
, hook
);
927 GetClientRect(hwnd
, &rcClient
);
928 /* translate to screen coordinates */
929 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rcClient
, 2);
930 ok(EqualRect(&rcClient
, &info
->rcClient
), "wrong rcClient for %p in hook %s\n", hwnd
, hook
);
932 ok(info
->dwStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_STYLE
),
933 "wrong dwStyle: %08x != %08x for %p in hook %s\n",
934 info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
), hwnd
, hook
);
935 /* Windows reports some undocumented exstyles in WINDOWINFO, but
936 * doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
938 ok((info
->dwExStyle
& ~0xe0000800) == (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
939 "wrong dwExStyle: %08x != %08x for %p in hook %s\n",
940 info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
), hwnd
, hook
);
941 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
942 if (GetForegroundWindow())
943 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04x != %04x active %p fg %p in hook %s\n",
944 info
->dwWindowStatus
, status
, GetActiveWindow(), GetForegroundWindow(), hook
);
946 /* win2k and XP return broken border info in GetWindowInfo most of
947 * the time, so there is no point in testing it.
952 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
953 "wrong cxWindowBorders %d != %d\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
954 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
955 ok(info
->cyWindowBorders
== border
,
956 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
958 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType for %p in hook %s\n",
960 ok(info
->wCreatorVersion
== 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
961 info
->wCreatorVersion
== 0x0500 /* Vista */,
962 "wrong wCreatorVersion %04x for %p in hook %s\n", info
->wCreatorVersion
, hwnd
, hook
);
965 static void FixedAdjustWindowRectEx(RECT
* rc
, LONG style
, BOOL menu
, LONG exstyle
)
967 AdjustWindowRectEx(rc
, style
, menu
, exstyle
);
968 /* AdjustWindowRectEx does not include scroll bars */
969 if (style
& WS_VSCROLL
)
971 if(exstyle
& WS_EX_LEFTSCROLLBAR
)
972 rc
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
974 rc
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
976 if (style
& WS_HSCROLL
)
977 rc
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
980 static void test_nonclient_area(HWND hwnd
)
982 DWORD style
, exstyle
;
983 RECT rc_window
, rc_client
, rc
;
987 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
988 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
989 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
991 GetWindowRect(hwnd
, &rc_window
);
992 GetClientRect(hwnd
, &rc_client
);
994 /* avoid some cases when things go wrong */
995 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
996 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
998 CopyRect(&rc
, &rc_client
);
999 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
1000 FixedAdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
1002 ok(EqualRect(&rc
, &rc_window
),
1003 "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
1004 style
, exstyle
, menu
, rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
,
1005 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1008 CopyRect(&rc
, &rc_window
);
1009 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
1010 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
1011 ok(EqualRect(&rc
, &rc_client
),
1012 "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
1013 style
, exstyle
, menu
, rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
,
1014 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1016 /* NULL rectangle shouldn't crash */
1017 ret
= DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, 0);
1018 ok(ret
== 0, "NULL rectangle returned %ld instead of 0\n", ret
);
1020 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
1024 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
1025 SetRect(&rc_client
, 0, 0, 250, 150);
1026 CopyRect(&rc_window
, &rc_client
);
1027 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
1028 FixedAdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
1030 CopyRect(&rc
, &rc_window
);
1031 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
1032 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
1033 ok(EqualRect(&rc
, &rc_client
),
1034 "synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
1035 style
, exstyle
, menu
, rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
,
1036 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
1039 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
1041 static const char *CBT_code_name
[10] = {
1048 "HCBT_CLICKSKIPPED",
1052 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
1053 HWND hwnd
= (HWND
)wParam
;
1057 case HCBT_CREATEWND
:
1059 static const RECT rc_null
;
1062 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
1063 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
1068 info
.cbSize
= sizeof(WINDOWINFO
);
1069 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1070 verify_window_info(code_name
, hwnd
, &info
);
1073 /* WS_VISIBLE should be turned off yet */
1074 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
1075 ok(style
== GetWindowLongA(hwnd
, GWL_STYLE
),
1076 "style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
1077 GetWindowLongA(hwnd
, GWL_STYLE
), style
);
1081 /* Uncomment this once the test succeeds in all cases */
1082 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1084 ok(GetParent(hwnd
) == hwndMessage
,
1085 "wrong result from GetParent %p: message window %p\n",
1086 GetParent(hwnd
), hwndMessage
);
1089 ok(!GetParent(hwnd
), "GetParent should return 0 at this point\n");
1091 ok(!GetWindow(hwnd
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
1095 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
1096 * Win9x still has them set to 0.
1098 ok(GetWindow(hwnd
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
1099 ok(GetWindow(hwnd
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
1101 ok(!GetWindow(hwnd
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
1102 ok(!GetWindow(hwnd
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
1106 /* Uncomment this once the test succeeds in all cases */
1109 ok(pGetAncestor(hwnd
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
1110 ok(pGetAncestor(hwnd
, GA_ROOT
) == hwnd
,
1111 "GA_ROOT is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOT
), hwnd
);
1113 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1114 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwndMessage
,
1115 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
1117 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwnd
,
1118 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOTOWNER
), hwnd
);
1121 ok(GetWindowRect(hwnd
, &rc
), "GetWindowRect failed\n");
1122 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
1123 ok(GetClientRect(hwnd
, &rc
), "GetClientRect failed\n");
1124 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
1131 if (pGetWindowInfo
&& IsWindow(hwnd
))
1135 /* Win98 actually does check the info.cbSize and doesn't allow
1136 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
1137 * WinXP do not check it at all.
1139 info
.cbSize
= sizeof(WINDOWINFO
);
1140 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1141 verify_window_info(code_name
, hwnd
, &info
);
1144 /* window state is undefined */
1146 case HCBT_DESTROYWND
:
1152 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
1155 static void test_shell_window(void)
1159 HMODULE hinst
, hUser32
;
1160 BOOL (WINAPI
*SetShellWindow
)(HWND
);
1161 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
1162 HWND shellWindow
, nextWnd
;
1166 win_skip("Skipping shell window test on Win9x\n");
1170 shellWindow
= GetShellWindow();
1171 hinst
= GetModuleHandleA(NULL
);
1172 hUser32
= GetModuleHandleA("user32");
1174 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
1176 trace("previous shell window: %p\n", shellWindow
);
1182 GetWindowThreadProcessId(shellWindow
, &pid
);
1183 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
1186 skip( "cannot get access to shell process\n" );
1190 SetLastError(0xdeadbeef);
1191 ret
= DestroyWindow(shellWindow
);
1192 error
= GetLastError();
1194 ok(!ret
, "DestroyWindow(shellWindow)\n");
1195 /* passes on Win XP, but not on Win98 */
1196 ok(error
==ERROR_ACCESS_DENIED
|| error
== 0xdeadbeef,
1197 "got %u after DestroyWindow(shellWindow)\n", error
);
1199 /* close old shell instance */
1200 ret
= TerminateProcess(hProcess
, 0);
1201 ok(ret
, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
1202 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
1203 CloseHandle(hProcess
);
1206 hwnd1
= CreateWindowExA(0, "#32770", "TEST1", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
1207 trace("created window 1: %p\n", hwnd1
);
1209 ret
= SetShellWindow(hwnd1
);
1210 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
1211 shellWindow
= GetShellWindow();
1212 ok(shellWindow
==hwnd1
, "wrong shell window: %p\n", shellWindow
);
1214 ret
= SetShellWindow(hwnd1
);
1215 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
1217 ret
= SetShellWindow(0);
1218 error
= GetLastError();
1219 /* passes on Win XP, but not on Win98
1220 ok(!ret, "reset shell window by SetShellWindow(0)\n");
1221 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
1223 ret
= SetShellWindow(hwnd1
);
1224 /* passes on Win XP, but not on Win98
1225 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
1227 SetWindowLongA(hwnd1
, GWL_EXSTYLE
, GetWindowLongA(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
1228 ret
= (GetWindowLongA(hwnd1
,GWL_EXSTYLE
) & WS_EX_TOPMOST
) != 0;
1229 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
1231 ret
= DestroyWindow(hwnd1
);
1232 ok(ret
, "DestroyWindow(hwnd1)\n");
1234 hwnd2
= CreateWindowExA(WS_EX_TOPMOST
, "#32770", "TEST2", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
1235 trace("created window 2: %p\n", hwnd2
);
1236 ret
= SetShellWindow(hwnd2
);
1237 ok(!ret
, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
1239 hwnd3
= CreateWindowExA(0, "#32770", "TEST3", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
1240 trace("created window 3: %p\n", hwnd3
);
1242 hwnd4
= CreateWindowExA(0, "#32770", "TEST4", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
1243 trace("created window 4: %p\n", hwnd4
);
1245 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1246 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd
);
1248 ret
= SetShellWindow(hwnd4
);
1249 ok(ret
, "SetShellWindow(hwnd4)\n");
1250 shellWindow
= GetShellWindow();
1251 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1253 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1254 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
1256 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1257 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1259 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1260 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
1262 ret
= SetShellWindow(hwnd3
);
1263 ok(!ret
, "SetShellWindow(hwnd3)\n");
1264 shellWindow
= GetShellWindow();
1265 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1267 hwnd5
= CreateWindowExA(0, "#32770", "TEST5", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
1268 trace("created window 5: %p\n", hwnd5
);
1269 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1270 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
1274 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1275 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
1278 /* destroy test windows */
1279 DestroyWindow(hwnd2
);
1280 DestroyWindow(hwnd3
);
1281 DestroyWindow(hwnd4
);
1282 DestroyWindow(hwnd5
);
1285 /************** MDI test ****************/
1287 static char mdi_lParam_test_message
[] = "just a test string";
1289 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT_PTR first_id
)
1291 MDICREATESTRUCTA mdi_cs
;
1294 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1295 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
1296 BOOL isWin9x
= FALSE
;
1298 mdi_cs
.szClass
= "MDI_child_Class_1";
1299 mdi_cs
.szTitle
= "MDI child";
1300 mdi_cs
.hOwner
= GetModuleHandleA(NULL
);
1301 mdi_cs
.x
= CW_USEDEFAULT
;
1302 mdi_cs
.y
= CW_USEDEFAULT
;
1303 mdi_cs
.cx
= CW_USEDEFAULT
;
1304 mdi_cs
.cy
= CW_USEDEFAULT
;
1306 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1307 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1308 ok(mdi_child
!= 0, "MDI child creation failed\n");
1309 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1310 ok(id
== first_id
, "wrong child id %ld\n", id
);
1311 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1312 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1314 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
1315 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1316 ok(mdi_child
!= 0, "MDI child creation failed\n");
1317 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1318 ok(id
== first_id
, "wrong child id %ld\n", id
);
1319 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1320 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1322 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
1323 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1324 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1326 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1330 ok(mdi_child
!= 0, "MDI child creation failed\n");
1331 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1332 ok(id
== first_id
, "wrong child id %ld\n", id
);
1333 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1334 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1337 /* test MDICREATESTRUCT A<->W mapping */
1338 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1340 mdi_cs
.szClass
= (LPCSTR
)classW
;
1341 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
1342 SetLastError(0xdeadbeef);
1343 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1346 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1349 ok(mdi_child
!= 0, "MDI child creation failed\n");
1353 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1354 ok(id
== first_id
, "wrong child id %ld\n", id
);
1355 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1356 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1359 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1361 CW_USEDEFAULT
, CW_USEDEFAULT
,
1362 CW_USEDEFAULT
, CW_USEDEFAULT
,
1363 mdi_client
, GetModuleHandleA(NULL
),
1364 (LPARAM
)mdi_lParam_test_message
);
1365 ok(mdi_child
!= 0, "MDI child creation failed\n");
1366 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1367 ok(id
== first_id
, "wrong child id %ld\n", id
);
1368 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1369 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1371 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1372 0x7fffffff, /* without WS_POPUP */
1373 CW_USEDEFAULT
, CW_USEDEFAULT
,
1374 CW_USEDEFAULT
, CW_USEDEFAULT
,
1375 mdi_client
, GetModuleHandleA(NULL
),
1376 (LPARAM
)mdi_lParam_test_message
);
1377 ok(mdi_child
!= 0, "MDI child creation failed\n");
1378 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1379 ok(id
== first_id
, "wrong child id %ld\n", id
);
1380 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1381 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1383 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1384 0xffffffff, /* with WS_POPUP */
1385 CW_USEDEFAULT
, CW_USEDEFAULT
,
1386 CW_USEDEFAULT
, CW_USEDEFAULT
,
1387 mdi_client
, GetModuleHandleA(NULL
),
1388 (LPARAM
)mdi_lParam_test_message
);
1389 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1391 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1395 ok(mdi_child
!= 0, "MDI child creation failed\n");
1396 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1397 ok(id
== first_id
, "wrong child id %ld\n", id
);
1398 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1399 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1402 /* test MDICREATESTRUCT A<->W mapping */
1403 SetLastError(0xdeadbeef);
1404 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1406 CW_USEDEFAULT
, CW_USEDEFAULT
,
1407 CW_USEDEFAULT
, CW_USEDEFAULT
,
1408 mdi_client
, GetModuleHandleA(NULL
),
1409 (LPARAM
)mdi_lParam_test_message
);
1412 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1415 ok(mdi_child
!= 0, "MDI child creation failed\n");
1419 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1420 ok(id
== first_id
, "wrong child id %ld\n", id
);
1421 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1422 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1425 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1427 CW_USEDEFAULT
, CW_USEDEFAULT
,
1428 CW_USEDEFAULT
, CW_USEDEFAULT
,
1429 mdi_client
, 0, GetModuleHandleA(NULL
),
1430 mdi_lParam_test_message
);
1431 ok(mdi_child
!= 0, "MDI child creation failed\n");
1432 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1433 ok(id
== first_id
, "wrong child id %ld\n", id
);
1434 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1435 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1437 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1438 0x7fffffff, /* without WS_POPUP */
1439 CW_USEDEFAULT
, CW_USEDEFAULT
,
1440 CW_USEDEFAULT
, CW_USEDEFAULT
,
1441 mdi_client
, 0, GetModuleHandleA(NULL
),
1442 mdi_lParam_test_message
);
1443 ok(mdi_child
!= 0, "MDI child creation failed\n");
1444 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1445 ok(id
== first_id
, "wrong child id %ld\n", id
);
1446 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1447 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1449 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1450 0xffffffff, /* with WS_POPUP */
1451 CW_USEDEFAULT
, CW_USEDEFAULT
,
1452 CW_USEDEFAULT
, CW_USEDEFAULT
,
1453 mdi_client
, 0, GetModuleHandleA(NULL
),
1454 mdi_lParam_test_message
);
1455 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1457 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1461 ok(mdi_child
!= 0, "MDI child creation failed\n");
1462 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1463 ok(id
== first_id
, "wrong child id %ld\n", id
);
1464 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1465 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1468 /* test MDICREATESTRUCT A<->W mapping */
1469 SetLastError(0xdeadbeef);
1470 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1472 CW_USEDEFAULT
, CW_USEDEFAULT
,
1473 CW_USEDEFAULT
, CW_USEDEFAULT
,
1474 mdi_client
, 0, GetModuleHandleA(NULL
),
1475 mdi_lParam_test_message
);
1478 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1481 ok(mdi_child
!= 0, "MDI child creation failed\n");
1485 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1486 ok(id
== first_id
, "wrong child id %ld\n", id
);
1487 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1488 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1491 /* This test fails on Win9x */
1494 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1496 CW_USEDEFAULT
, CW_USEDEFAULT
,
1497 CW_USEDEFAULT
, CW_USEDEFAULT
,
1498 parent
, 0, GetModuleHandleA(NULL
),
1499 mdi_lParam_test_message
);
1500 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1503 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1504 WS_CHILD
, /* without WS_POPUP */
1505 CW_USEDEFAULT
, CW_USEDEFAULT
,
1506 CW_USEDEFAULT
, CW_USEDEFAULT
,
1507 mdi_client
, 0, GetModuleHandleA(NULL
),
1508 mdi_lParam_test_message
);
1509 ok(mdi_child
!= 0, "MDI child creation failed\n");
1510 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1511 ok(id
== 0, "wrong child id %ld\n", id
);
1512 DestroyWindow(mdi_child
);
1514 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1515 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1516 CW_USEDEFAULT
, CW_USEDEFAULT
,
1517 CW_USEDEFAULT
, CW_USEDEFAULT
,
1518 mdi_client
, 0, GetModuleHandleA(NULL
),
1519 mdi_lParam_test_message
);
1520 ok(mdi_child
!= 0, "MDI child creation failed\n");
1521 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1522 ok(id
== 0, "wrong child id %ld\n", id
);
1523 DestroyWindow(mdi_child
);
1525 /* maximized child */
1526 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1527 WS_CHILD
| WS_MAXIMIZE
,
1528 CW_USEDEFAULT
, CW_USEDEFAULT
,
1529 CW_USEDEFAULT
, CW_USEDEFAULT
,
1530 mdi_client
, 0, GetModuleHandleA(NULL
),
1531 mdi_lParam_test_message
);
1532 ok(mdi_child
!= 0, "MDI child creation failed\n");
1533 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1534 ok(id
== 0, "wrong child id %ld\n", id
);
1535 DestroyWindow(mdi_child
);
1537 trace("Creating maximized child with a caption\n");
1538 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1539 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1540 CW_USEDEFAULT
, CW_USEDEFAULT
,
1541 CW_USEDEFAULT
, CW_USEDEFAULT
,
1542 mdi_client
, 0, GetModuleHandleA(NULL
),
1543 mdi_lParam_test_message
);
1544 ok(mdi_child
!= 0, "MDI child creation failed\n");
1545 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1546 ok(id
== 0, "wrong child id %ld\n", id
);
1547 DestroyWindow(mdi_child
);
1549 trace("Creating maximized child with a caption and a thick frame\n");
1550 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1551 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1552 CW_USEDEFAULT
, CW_USEDEFAULT
,
1553 CW_USEDEFAULT
, CW_USEDEFAULT
,
1554 mdi_client
, 0, GetModuleHandleA(NULL
),
1555 mdi_lParam_test_message
);
1556 ok(mdi_child
!= 0, "MDI child creation failed\n");
1557 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1558 ok(id
== 0, "wrong child id %ld\n", id
);
1559 DestroyWindow(mdi_child
);
1562 static void test_MDI_child_stack(HWND mdi_client
)
1564 HWND child_1
, child_2
, child_3
, child_4
;
1566 MDICREATESTRUCTA cs
;
1568 cs
.szClass
= "MDI_child_Class_1";
1569 cs
.szTitle
= "MDI child";
1570 cs
.hOwner
= GetModuleHandleA(0);
1571 cs
.x
= CW_USEDEFAULT
;
1572 cs
.y
= CW_USEDEFAULT
;
1573 cs
.cx
= CW_USEDEFAULT
;
1574 cs
.cy
= CW_USEDEFAULT
;
1576 cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1578 child_1
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1579 ok(child_1
!= 0, "expected child_1 to be non NULL\n");
1580 child_2
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1581 ok(child_2
!= 0, "expected child_2 to be non NULL\n");
1582 child_3
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1583 ok(child_3
!= 0, "expected child_3 to be non NULL\n");
1584 child_4
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1585 ok(child_4
!= 0, "expected child_4 to be non NULL\n");
1587 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1588 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1589 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1590 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1591 trace("Initial MDI child stack: %p->%p->%p->%p\n", stack
[0], stack
[1], stack
[2], stack
[3]);
1592 ok(stack
[0] == child_4
&& stack
[1] == child_3
&&
1593 stack
[2] == child_2
&& stack
[3] == child_1
,
1594 "Unexpected initial order, should be: %p->%p->%p->%p\n",
1595 child_4
, child_3
, child_2
, child_1
);
1597 trace("Activate child next to %p\n", child_3
);
1598 SendMessageA(mdi_client
, WM_MDINEXT
, (WPARAM
)child_3
, 0);
1600 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1601 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1602 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1603 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1604 ok(stack
[0] == child_2
&& stack
[1] == child_4
&&
1605 stack
[2] == child_1
&& stack
[3] == child_3
,
1606 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1607 child_2
, child_4
, child_1
, child_3
, stack
[0], stack
[1], stack
[2], stack
[3]);
1609 trace("Activate child previous to %p\n", child_1
);
1610 SendMessageA(mdi_client
, WM_MDINEXT
, (WPARAM
)child_1
, 1);
1612 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1613 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1614 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1615 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1616 ok(stack
[0] == child_4
&& stack
[1] == child_2
&&
1617 stack
[2] == child_1
&& stack
[3] == child_3
,
1618 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1619 child_4
, child_2
, child_1
, child_3
, stack
[0], stack
[1], stack
[2], stack
[3]);
1621 DestroyWindow(child_1
);
1622 DestroyWindow(child_2
);
1623 DestroyWindow(child_3
);
1624 DestroyWindow(child_4
);
1627 /**********************************************************************
1628 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1630 * Note: The rule here is that client rect of the maximized MDI child
1631 * is equal to the client rect of the MDI client window.
1633 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1637 GetClientRect( client
, &rect
);
1638 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1639 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1641 rect
.right
-= rect
.left
;
1642 rect
.bottom
-= rect
.top
;
1643 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1644 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1646 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1647 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1649 trace("max rect (%d,%d - %d, %d)\n",
1650 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1653 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1660 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1661 MDICREATESTRUCTA
*mdi_cs
= cs
->lpCreateParams
;
1663 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1664 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1666 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1667 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1668 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1669 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1670 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1672 /* MDICREATESTRUCT should have original values */
1673 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff,
1674 "mdi_cs->style does not match (%08x)\n", mdi_cs
->style
);
1675 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1676 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1677 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1678 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1680 /* CREATESTRUCT should have fixed values */
1681 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1682 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1684 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1685 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1686 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1688 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1690 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1692 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1693 ok(cs
->style
== style
,
1694 "cs->style does not match (%08x)\n", cs
->style
);
1698 LONG style
= mdi_cs
->style
;
1700 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1701 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1702 ok(cs
->style
== style
,
1703 "cs->style does not match (%08x)\n", cs
->style
);
1708 case WM_GETMINMAXINFO
:
1710 HWND client
= GetParent(hwnd
);
1712 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1713 MINMAXINFO my_minmax
;
1714 LONG style
, exstyle
;
1716 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1717 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1719 GetClientRect(client
, &rc
);
1721 GetClientRect(client
, &rc
);
1722 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1723 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1724 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1725 trace("MDI child: calculated max window size = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1726 dump_minmax_info( minmax
);
1728 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1729 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1730 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1731 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1733 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1735 trace("DefMDIChildProc returned:\n");
1736 dump_minmax_info( minmax
);
1738 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1739 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %d != %d\n",
1740 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1741 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %d != %d\n",
1742 minmax
->ptMaxSize
.y
, my_minmax
.ptMaxSize
.y
);
1747 case WM_MDIACTIVATE
:
1749 HWND active
, client
= GetParent(hwnd
);
1750 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1751 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
1752 if (hwnd
== (HWND
)lparam
) /* if we are being activated */
1753 ok (active
== (HWND
)lparam
, "new active %p != active %p\n", (HWND
)lparam
, active
);
1755 ok (active
== (HWND
)wparam
, "old active %p != active %p\n", (HWND
)wparam
, active
);
1759 return DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1762 static LRESULT WINAPI
mdi_child_wnd_proc_2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1769 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1771 trace("%s: x %d, y %d, cx %d, cy %d\n", (msg
== WM_NCCREATE
) ? "WM_NCCREATE" : "WM_CREATE",
1772 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1774 ok(!(cs
->dwExStyle
& WS_EX_MDICHILD
), "WS_EX_MDICHILD should not be set\n");
1775 ok(cs
->lpCreateParams
== mdi_lParam_test_message
, "wrong cs->lpCreateParams\n");
1777 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_2"), "wrong class name\n");
1778 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1780 /* CREATESTRUCT should have fixed values */
1781 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1783 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1784 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1786 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1787 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1788 while Win95, Win2k, WinXP do. */
1789 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1790 ok(cs
->cy
== 0, "%d != 0\n", cs
->cy
);
1794 case WM_GETMINMAXINFO
:
1796 HWND parent
= GetParent(hwnd
);
1798 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1799 LONG style
, exstyle
;
1801 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1802 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1804 GetClientRect(parent
, &rc
);
1805 trace("WM_GETMINMAXINFO: parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
1807 GetClientRect(parent
, &rc
);
1808 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1809 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1810 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1811 dump_minmax_info( minmax
);
1813 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1814 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1815 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1816 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1820 case WM_WINDOWPOSCHANGED
:
1822 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1825 GetWindowRect(hwnd
, &rc1
);
1826 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1827 /* note: winpos coordinates are relative to parent */
1828 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1829 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=(%d,%d)-(%d,%d) pos=(%d,%d)-(%d,%d)\n",
1830 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
1831 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1832 GetWindowRect(hwnd
, &rc1
);
1833 GetClientRect(hwnd
, &rc2
);
1834 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1835 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1836 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
1837 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
1838 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1841 case WM_WINDOWPOSCHANGING
:
1843 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1844 WINDOWPOS my_winpos
= *winpos
;
1846 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1847 (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
1848 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1849 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1851 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1853 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1854 "DefWindowProc should not change WINDOWPOS: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1855 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1856 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1861 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1864 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1866 static HWND mdi_client
;
1872 CLIENTCREATESTRUCT client_cs
;
1875 GetClientRect(hwnd
, &rc
);
1877 client_cs
.hWindowMenu
= 0;
1878 client_cs
.idFirstChild
= 1;
1880 /* MDIClient without MDIS_ALLCHILDSTYLES */
1881 mdi_client
= CreateWindowExA(0, "mdiclient",
1883 WS_CHILD
/*| WS_VISIBLE*/,
1884 /* tests depend on a not zero MDIClient size */
1885 0, 0, rc
.right
, rc
.bottom
,
1886 hwnd
, 0, GetModuleHandleA(NULL
),
1889 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1890 DestroyWindow(mdi_client
);
1892 /* MDIClient with MDIS_ALLCHILDSTYLES */
1893 mdi_client
= CreateWindowExA(0, "mdiclient",
1895 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
1896 /* tests depend on a not zero MDIClient size */
1897 0, 0, rc
.right
, rc
.bottom
,
1898 hwnd
, 0, GetModuleHandleA(NULL
),
1901 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1902 DestroyWindow(mdi_client
);
1904 /* Test child window stack management */
1905 mdi_client
= CreateWindowExA(0, "mdiclient",
1908 0, 0, rc
.right
, rc
.bottom
,
1909 hwnd
, 0, GetModuleHandleA(NULL
),
1912 test_MDI_child_stack(mdi_client
);
1913 DestroyWindow(mdi_client
);
1917 case WM_WINDOWPOSCHANGED
:
1919 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1922 GetWindowRect(hwnd
, &rc1
);
1923 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1924 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1925 /* note: winpos coordinates are relative to parent */
1926 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1927 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1928 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1930 GetWindowRect(hwnd
, &rc1
);
1931 GetClientRect(hwnd
, &rc2
);
1932 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1933 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1934 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1937 case WM_WINDOWPOSCHANGING
:
1939 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1940 WINDOWPOS my_winpos
= *winpos
;
1942 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1943 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1944 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1945 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1947 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1949 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1950 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1951 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1953 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1954 "DefWindowProc should not change WINDOWPOS values\n");
1963 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
1966 static BOOL
mdi_RegisterWindowClasses(void)
1971 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
1974 cls
.hInstance
= GetModuleHandleA(0);
1976 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
1977 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1978 cls
.lpszMenuName
= NULL
;
1979 cls
.lpszClassName
= "MDI_parent_Class";
1980 if(!RegisterClassA(&cls
)) return FALSE
;
1982 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
1983 cls
.lpszClassName
= "MDI_child_Class_1";
1984 if(!RegisterClassA(&cls
)) return FALSE
;
1986 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
1987 cls
.lpszClassName
= "MDI_child_Class_2";
1988 if(!RegisterClassA(&cls
)) return FALSE
;
1993 static void test_mdi(void)
1998 if (!mdi_RegisterWindowClasses()) assert(0);
2000 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
2001 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
2002 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
2003 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
2004 GetDesktopWindow(), 0,
2005 GetModuleHandleA(NULL
), NULL
);
2006 assert(mdi_hwndMain
);
2008 while(GetMessage(&msg, 0, 0, 0))
2010 TranslateMessage(&msg);
2011 DispatchMessage(&msg);
2014 DestroyWindow(mdi_hwndMain
);
2017 static void test_icons(void)
2021 HICON icon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
2022 HICON icon2
= LoadIconA(0, (LPCSTR
)IDI_QUESTION
);
2023 HICON small_icon
= LoadImageA(0, (LPCSTR
)IDI_APPLICATION
, IMAGE_ICON
,
2024 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
2027 cls
.cbSize
= sizeof(cls
);
2029 cls
.lpfnWndProc
= DefWindowProcA
;
2033 cls
.hIcon
= LoadIconA(0, (LPCSTR
)IDI_HAND
);
2034 cls
.hIconSm
= small_icon
;
2035 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
2036 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
2037 cls
.lpszMenuName
= NULL
;
2038 cls
.lpszClassName
= "IconWindowClass";
2040 RegisterClassExA(&cls
);
2042 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
2043 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
2046 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2047 ok( res
== 0, "wrong big icon %p/0\n", res
);
2048 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
2049 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
2050 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2051 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
2052 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
2053 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
2054 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2055 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
2057 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2058 ok( res
== 0, "wrong small icon %p/0\n", res
);
2059 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL2
, 0 );
2060 ok( (res
&& res
!= small_icon
&& res
!= icon2
) || broken(!res
), "wrong small2 icon %p\n", res
);
2061 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
2062 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
2063 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2064 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
2065 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL2
, 0 );
2066 ok( res
== icon
|| broken(!res
), "wrong small2 icon after set %p/%p\n", res
, icon
);
2067 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
2068 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
2069 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2070 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
2071 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL2
, 0 );
2072 ok( res
== small_icon
|| broken(!res
), "wrong small2 icon after set %p/%p\n", res
, small_icon
);
2074 /* make sure the big icon hasn't changed */
2075 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2076 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
2078 DestroyWindow( hwnd
);
2081 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2083 if (msg
== WM_NCCALCSIZE
)
2085 RECT
*rect
= (RECT
*)lparam
;
2086 /* first time around increase the rectangle, next time decrease it */
2087 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
2088 else InflateRect( rect
, -10, -10 );
2091 return DefWindowProcA( hwnd
, msg
, wparam
, lparam
);
2094 static void test_SetWindowPos(HWND hwnd
, HWND hwnd2
)
2096 RECT orig_win_rc
, rect
;
2098 HWND hwnd_grandchild
, hwnd_child
, hwnd_child2
;
2103 SetRect(&rect
, 111, 222, 333, 444);
2104 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
2105 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
2106 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2108 SetRect(&rect
, 111, 222, 333, 444);
2109 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
2110 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
2111 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2113 GetWindowRect(hwnd
, &orig_win_rc
);
2115 old_proc
= SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
2116 ret
= SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
2117 ok(ret
, "Got %d\n", ret
);
2118 GetWindowRect( hwnd
, &rect
);
2119 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
2120 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2121 GetClientRect( hwnd
, &rect
);
2122 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2123 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
2124 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2126 ret
= SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
2127 ok(ret
, "Got %d\n", ret
);
2128 GetWindowRect( hwnd
, &rect
);
2129 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
2130 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2131 GetClientRect( hwnd
, &rect
);
2132 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2133 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
2134 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2136 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2137 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2138 ok(ret
, "Got %d\n", ret
);
2139 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, old_proc
);
2141 /* Win9x truncates coordinates to 16-bit irrespectively */
2144 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
2145 ok(ret
, "Got %d\n", ret
);
2146 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
2147 ok(ret
, "Got %d\n", ret
);
2149 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
2150 ok(ret
, "Got %d\n", ret
);
2151 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
2152 ok(ret
, "Got %d\n", ret
);
2155 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2156 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2157 ok(ret
, "Got %d\n", ret
);
2159 ok(!(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
2160 ret
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2161 ok(ret
, "Got %d\n", ret
);
2162 ok(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
2163 ret
= SetWindowPos(hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2164 ok(ret
, "Got %d\n", ret
);
2165 ok(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
2166 ret
= SetWindowPos(hwnd
, HWND_NOTOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2167 ok(ret
, "Got %d\n", ret
);
2168 ok(!(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
2170 hwnd_desktop
= GetDesktopWindow();
2171 ok(!!hwnd_desktop
, "Failed to get hwnd_desktop window (%d).\n", GetLastError());
2172 hwnd_child
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2173 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2174 hwnd_grandchild
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd_child
);
2175 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2176 hwnd_child2
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2177 ok(!!hwnd_child2
, "Failed to create second child window (%d)\n", GetLastError());
2179 ret
= SetWindowPos(hwnd
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2180 ok(ret
, "Got %d\n", ret
);
2181 check_active_state(hwnd
, hwnd
, hwnd
);
2183 ret
= SetWindowPos(hwnd2
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2184 ok(ret
, "Got %d\n", ret
);
2185 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2187 /* Returns TRUE also for windows that are not siblings */
2188 ret
= SetWindowPos(hwnd_child
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2189 ok(ret
, "Got %d\n", ret
);
2190 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2192 ret
= SetWindowPos(hwnd2
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2193 ok(ret
, "Got %d\n", ret
);
2194 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2196 /* Does not seem to do anything even without passing flags, still returns TRUE */
2197 GetWindowRect(hwnd_child
, &rc1
);
2198 ret
= SetWindowPos(hwnd_child
, hwnd2
, 1, 2, 3, 4, 0);
2199 ok(ret
, "Got %d\n", ret
);
2200 GetWindowRect(hwnd_child
, &rc2
);
2201 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2202 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2203 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2204 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2205 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2207 /* Same thing the other way around. */
2208 GetWindowRect(hwnd2
, &rc1
);
2209 ret
= SetWindowPos(hwnd2
, hwnd_child
, 1, 2, 3, 4, 0);
2210 ok(ret
, "Got %d\n", ret
);
2211 GetWindowRect(hwnd2
, &rc2
);
2212 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2213 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2214 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2215 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2216 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2218 /* .. and with these windows. */
2219 GetWindowRect(hwnd_grandchild
, &rc1
);
2220 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, 0);
2221 ok(ret
, "Got %d\n", ret
);
2222 GetWindowRect(hwnd_grandchild
, &rc2
);
2223 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2224 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2225 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2226 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2227 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2229 /* Add SWP_NOZORDER and it will be properly resized. */
2230 GetWindowRect(hwnd_grandchild
, &rc1
);
2231 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, SWP_NOZORDER
);
2232 ok(ret
, "Got %d\n", ret
);
2233 GetWindowRect(hwnd_grandchild
, &rc2
);
2234 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2235 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2236 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2237 rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2238 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2240 /* Given a sibling window, the window is properly resized. */
2241 GetWindowRect(hwnd_child
, &rc1
);
2242 ret
= SetWindowPos(hwnd_child
, hwnd_child2
, 1, 2, 3, 4, 0);
2243 ok(ret
, "Got %d\n", ret
);
2244 GetWindowRect(hwnd_child
, &rc2
);
2245 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2246 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2247 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2248 rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2249 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2251 /* Involving the desktop window changes things. */
2252 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2253 ok(!ret
, "Got %d\n", ret
);
2254 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2256 GetWindowRect(hwnd_child
, &rc1
);
2257 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, 0);
2258 ok(!ret
, "Got %d\n", ret
);
2259 GetWindowRect(hwnd_child
, &rc2
);
2260 ok(rc1
.top
== rc2
.top
&& rc1
.left
== rc2
.left
&&
2261 rc1
.bottom
== rc2
.bottom
&& rc1
.right
== rc2
.right
,
2262 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2263 rc1
.top
, rc1
.left
, rc1
.bottom
, rc1
.right
, rc2
.top
, rc2
.left
, rc2
.bottom
, rc2
.right
);
2264 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2266 ret
= SetWindowPos(hwnd_desktop
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2267 ok(!ret
, "Got %d\n", ret
);
2268 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2270 ret
= SetWindowPos(hwnd_desktop
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2271 ok(!ret
, "Got %d\n", ret
);
2272 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2274 ret
= SetWindowPos(hwnd
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2275 ok(!ret
, "Got %d\n", ret
);
2276 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2278 DestroyWindow(hwnd_grandchild
);
2279 DestroyWindow(hwnd_child
);
2280 DestroyWindow(hwnd_child2
);
2282 hwnd_child
= create_tool_window(WS_CHILD
|WS_POPUP
|WS_SYSMENU
, hwnd2
);
2283 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2284 ret
= SetWindowPos(hwnd_child
, NULL
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2285 ok(ret
, "Got %d\n", ret
);
2286 flush_events( TRUE
);
2287 todo_wine
check_active_state(hwnd2
, hwnd2
, hwnd2
);
2288 DestroyWindow(hwnd_child
);
2291 static void test_SetMenu(HWND parent
)
2298 hMenu
= CreateMenu();
2301 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2304 /* fails on (at least) Wine, NT4, XP SP2 */
2305 test_nonclient_area(parent
);
2307 ret
= GetMenu(parent
);
2308 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2309 /* test whether we can destroy a menu assigned to a window */
2310 retok
= DestroyMenu(hMenu
);
2311 ok( retok
, "DestroyMenu error %d\n", GetLastError());
2312 retok
= IsMenu(hMenu
);
2313 ok(!retok
|| broken(retok
) /* nt4 */, "menu handle should be not valid after DestroyMenu\n");
2314 ret
= GetMenu(parent
);
2315 /* This test fails on Win9x */
2317 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2318 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2319 test_nonclient_area(parent
);
2321 hMenu
= CreateMenu();
2325 ret
= GetMenu(parent
);
2326 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2328 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2329 test_nonclient_area(parent
);
2330 ret
= GetMenu(parent
);
2331 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2333 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2336 /* fails on (at least) Wine, NT4, XP SP2 */
2337 test_nonclient_area(parent
);
2339 ret
= GetMenu(parent
);
2340 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2342 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2343 test_nonclient_area(parent
);
2344 ret
= GetMenu(parent
);
2345 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2348 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
2351 ret
= GetMenu(child
);
2352 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2354 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2355 test_nonclient_area(child
);
2356 ret
= GetMenu(child
);
2357 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2359 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
2360 test_nonclient_area(child
);
2361 ret
= GetMenu(child
);
2362 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2364 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
2365 test_nonclient_area(child
);
2366 ret
= GetMenu(child
);
2367 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2369 style
= GetWindowLongA(child
, GWL_STYLE
);
2370 SetWindowLongA(child
, GWL_STYLE
, style
| WS_POPUP
);
2371 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
2372 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
2373 SetWindowLongA(child
, GWL_STYLE
, style
);
2375 SetWindowLongA(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
2376 ok(!SetMenu(child
, hMenu
), "SetMenu on an overlapped child window should fail\n");
2377 SetWindowLongA(child
, GWL_STYLE
, style
);
2379 DestroyWindow(child
);
2383 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
2385 HWND child
[5], hwnd
;
2390 hwnd
= GetWindow(parent
, GW_CHILD
);
2391 ok(!hwnd
, "have to start without children to perform the test\n");
2393 for (i
= 0; i
< total
; i
++)
2395 if (style
[i
] & DS_CONTROL
)
2397 child
[i
] = CreateWindowExA(0, (LPCSTR
)MAKEINTATOM(32770), "", style
[i
] & ~WS_VISIBLE
,
2398 0,0,0,0, parent
, (HMENU
)i
, 0, NULL
);
2399 if (style
[i
] & WS_VISIBLE
)
2400 ShowWindow(child
[i
], SW_SHOW
);
2402 SetWindowPos(child
[i
], HWND_BOTTOM
, 0,0,10,10, SWP_NOACTIVATE
);
2405 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
2406 parent
, (HMENU
)i
, 0, NULL
);
2407 trace("child[%ld] = %p\n", i
, child
[i
]);
2408 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
2411 hwnd
= GetWindow(parent
, GW_CHILD
);
2412 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
2413 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
2414 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
2416 for (i
= 0; i
< total
; i
++)
2418 trace("hwnd[%ld] = %p\n", i
, hwnd
);
2419 ok(child
[order
[i
]] == hwnd
, "Z order of child #%ld is wrong\n", i
);
2421 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
2424 for (i
= 0; i
< total
; i
++)
2425 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
2428 static void test_children_zorder(HWND parent
)
2430 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
2432 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
2434 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
2435 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
2436 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
2437 const int complex_order_1
[1] = { 0 };
2438 const int complex_order_2
[2] = { 1, 0 };
2439 const int complex_order_3
[3] = { 1, 0, 2 };
2440 const int complex_order_4
[4] = { 1, 0, 2, 3 };
2441 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
2442 const DWORD complex_style_6
[3] = { WS_CHILD
| WS_VISIBLE
,
2443 WS_CHILD
| WS_CLIPSIBLINGS
| DS_CONTROL
| WS_VISIBLE
,
2444 WS_CHILD
| WS_VISIBLE
};
2445 const int complex_order_6
[3] = { 0, 1, 2 };
2447 /* simple WS_CHILD */
2448 test_window_tree(parent
, simple_style
, simple_order
, 5);
2450 /* complex children styles */
2451 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
2452 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
2453 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
2454 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
2455 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
2457 /* another set of complex children styles */
2458 test_window_tree(parent
, complex_style_6
, complex_order_6
, 3);
2461 #define check_z_order(hwnd, next, prev, owner, topmost) \
2462 check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
2465 static void check_z_order_debug(HWND hwnd
, HWND next
, HWND prev
, HWND owner
,
2466 BOOL topmost
, const char *file
, int line
)
2471 test
= GetWindow(hwnd
, GW_HWNDNEXT
);
2472 /* skip foreign windows */
2473 while (test
&& test
!= next
&&
2474 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2475 UlongToHandle(GetWindowLongPtrA(test
, GWLP_HINSTANCE
)) != GetModuleHandleA(NULL
) ||
2476 GetWindow(test
, GW_OWNER
) == next
))
2478 /*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2479 test
= GetWindow(test
, GW_HWNDNEXT
);
2481 ok_(file
, line
)(next
== test
, "%p: expected next %p, got %p\n", hwnd
, next
, test
);
2483 test
= GetWindow(hwnd
, GW_HWNDPREV
);
2484 /* skip foreign windows */
2485 while (test
&& test
!= prev
&&
2486 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2487 UlongToHandle(GetWindowLongPtrA(test
, GWLP_HINSTANCE
)) != GetModuleHandleA(NULL
) ||
2488 GetWindow(test
, GW_OWNER
) == hwnd
))
2490 /*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2491 test
= GetWindow(test
, GW_HWNDPREV
);
2493 ok_(file
, line
)(prev
== test
, "%p: expected prev %p, got %p\n", hwnd
, prev
, test
);
2495 test
= GetWindow(hwnd
, GW_OWNER
);
2496 ok_(file
, line
)(owner
== test
, "%p: expected owner %p, got %p\n", hwnd
, owner
, test
);
2498 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
2499 ok_(file
, line
)(!(ex_style
& WS_EX_TOPMOST
) == !topmost
, "%p: expected %stopmost\n",
2500 hwnd
, topmost
? "" : "NOT ");
2503 static void test_popup_zorder(HWND hwnd_D
, HWND hwnd_E
, DWORD style
)
2505 HWND hwnd_A
, hwnd_B
, hwnd_C
, hwnd_F
;
2507 trace("hwnd_D %p, hwnd_E %p\n", hwnd_D
, hwnd_E
);
2509 SetWindowPos(hwnd_E
, hwnd_D
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2511 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2512 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2514 hwnd_F
= CreateWindowExA(0, "MainWindowClass", "Owner window",
2515 WS_OVERLAPPED
| WS_CAPTION
,
2517 0, 0, GetModuleHandleA(NULL
), NULL
);
2518 trace("hwnd_F %p\n", hwnd_F
);
2519 check_z_order(hwnd_F
, hwnd_D
, 0, 0, FALSE
);
2521 SetWindowPos(hwnd_F
, hwnd_E
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2522 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2523 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2524 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2526 hwnd_C
= CreateWindowExA(0, "MainWindowClass", NULL
,
2529 hwnd_F
, 0, GetModuleHandleA(NULL
), NULL
);
2530 trace("hwnd_C %p\n", hwnd_C
);
2531 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2532 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2533 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2534 check_z_order(hwnd_C
, hwnd_D
, 0, hwnd_F
, FALSE
);
2536 hwnd_B
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2539 hwnd_F
, 0, GetModuleHandleA(NULL
), NULL
);
2540 trace("hwnd_B %p\n", hwnd_B
);
2541 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2542 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2543 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2544 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2545 check_z_order(hwnd_B
, hwnd_C
, 0, hwnd_F
, TRUE
);
2547 hwnd_A
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2550 0, 0, GetModuleHandleA(NULL
), NULL
);
2551 trace("hwnd_A %p\n", hwnd_A
);
2552 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2553 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2554 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2555 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2556 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2557 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2559 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
);
2561 /* move hwnd_F and its popups up */
2562 SetWindowPos(hwnd_F
, HWND_TOP
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2563 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2564 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2565 check_z_order(hwnd_F
, hwnd_D
, hwnd_C
, 0, FALSE
);
2566 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2567 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2568 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2570 /* move hwnd_F and its popups down */
2571 #if 0 /* enable once Wine is fixed to pass this test */
2572 SetWindowPos(hwnd_F
, HWND_BOTTOM
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2573 check_z_order(hwnd_F
, 0, hwnd_C
, 0, FALSE
);
2574 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2575 check_z_order(hwnd_B
, hwnd_C
, hwnd_E
, hwnd_F
, FALSE
);
2576 check_z_order(hwnd_E
, hwnd_B
, hwnd_D
, 0, FALSE
);
2577 check_z_order(hwnd_D
, hwnd_E
, hwnd_A
, 0, FALSE
);
2578 check_z_order(hwnd_A
, hwnd_D
, 0, 0, TRUE
);
2581 /* make hwnd_C owned by a topmost window */
2582 DestroyWindow( hwnd_C
);
2583 hwnd_C
= CreateWindowExA(0, "MainWindowClass", NULL
,
2586 hwnd_A
, 0, GetModuleHandleA(NULL
), NULL
);
2587 trace("hwnd_C %p\n", hwnd_C
);
2588 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2589 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2590 check_z_order(hwnd_F
, hwnd_D
, hwnd_B
, 0, FALSE
);
2591 check_z_order(hwnd_B
, hwnd_F
, hwnd_A
, hwnd_F
, TRUE
);
2592 check_z_order(hwnd_A
, hwnd_B
, hwnd_C
, 0, TRUE
);
2593 check_z_order(hwnd_C
, hwnd_A
, 0, hwnd_A
, TRUE
);
2595 DestroyWindow(hwnd_A
);
2596 DestroyWindow(hwnd_B
);
2597 DestroyWindow(hwnd_C
);
2598 DestroyWindow(hwnd_F
);
2601 static void test_vis_rgn( HWND hwnd
)
2603 RECT win_rect
, rgn_rect
;
2604 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
2607 ShowWindow(hwnd
,SW_SHOW
);
2608 hdc
= GetDC( hwnd
);
2609 ok( GetRandomRgn( hdc
, hrgn
, SYSRGN
) != 0, "GetRandomRgn failed\n" );
2610 GetWindowRect( hwnd
, &win_rect
);
2611 GetRgnBox( hrgn
, &rgn_rect
);
2614 trace("win9x, mapping to screen coords\n");
2615 MapWindowPoints( hwnd
, 0, (POINT
*)&rgn_rect
, 2 );
2617 trace("win: %d,%d-%d,%d\n", win_rect
.left
, win_rect
.top
, win_rect
.right
, win_rect
.bottom
);
2618 trace("rgn: %d,%d-%d,%d\n", rgn_rect
.left
, rgn_rect
.top
, rgn_rect
.right
, rgn_rect
.bottom
);
2619 ok( win_rect
.left
<= rgn_rect
.left
, "rgn left %d not inside win rect %d\n",
2620 rgn_rect
.left
, win_rect
.left
);
2621 ok( win_rect
.top
<= rgn_rect
.top
, "rgn top %d not inside win rect %d\n",
2622 rgn_rect
.top
, win_rect
.top
);
2623 ok( win_rect
.right
>= rgn_rect
.right
, "rgn right %d not inside win rect %d\n",
2624 rgn_rect
.right
, win_rect
.right
);
2625 ok( win_rect
.bottom
>= rgn_rect
.bottom
, "rgn bottom %d not inside win rect %d\n",
2626 rgn_rect
.bottom
, win_rect
.bottom
);
2627 ReleaseDC( hwnd
, hdc
);
2630 static LRESULT WINAPI
set_focus_on_activate_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
2632 if (msg
== WM_ACTIVATE
&& LOWORD(wp
) == WA_ACTIVE
)
2634 HWND child
= GetWindow(hwnd
, GW_CHILD
);
2635 ok(child
!= 0, "couldn't find child window\n");
2637 ok(GetFocus() == child
, "Focus should be on child %p\n", child
);
2640 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
2643 static void test_SetFocus(HWND hwnd
)
2645 HWND child
, child2
, ret
;
2646 WNDPROC old_wnd_proc
;
2648 /* check if we can set focus to non-visible windows */
2650 ShowWindow(hwnd
, SW_SHOW
);
2653 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2654 ok( GetWindowLongA(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
2655 ShowWindow(hwnd
, SW_HIDE
);
2658 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
2659 ok( !(GetWindowLongA(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
2660 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2663 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
2664 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2665 ShowWindow(child
, SW_SHOW
);
2666 ok( GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
2667 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
2668 ShowWindow(child
, SW_HIDE
);
2669 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2670 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2671 ShowWindow(child
, SW_SHOW
);
2672 child2
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, child
, 0, 0, NULL
);
2674 ShowWindow(child2
, SW_SHOW
);
2676 ShowWindow(child
, SW_HIDE
);
2677 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2678 ok( GetFocus() == child2
, "Focus should be on %p, not %p\n", child2
, GetFocus() );
2679 ShowWindow(child
, SW_SHOW
);
2681 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2682 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
2683 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2685 ShowWindow(child
, SW_HIDE
);
2687 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2688 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
2689 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2690 ShowWindow(child
, SW_HIDE
);
2691 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2693 ShowWindow(hwnd
, SW_SHOW
);
2694 ShowWindow(child
, SW_SHOW
);
2696 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2697 EnableWindow(hwnd
, FALSE
);
2698 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2699 EnableWindow(hwnd
, TRUE
);
2701 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2702 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2703 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2705 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2706 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2707 ShowWindow(hwnd
, SW_RESTORE
);
2708 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2709 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2710 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2711 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2712 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2714 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2715 old_wnd_proc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)set_focus_on_activate_proc
);
2716 ShowWindow(hwnd
, SW_RESTORE
);
2717 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2719 ok( GetFocus() == child
, "Focus should be on child %p, not %p\n", child
, GetFocus() );
2720 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)old_wnd_proc
);
2723 SetParent( child
, GetDesktopWindow());
2724 SetParent( child2
, child
);
2725 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2726 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2727 ret
= SetFocus( child2
);
2728 ok( ret
== 0, "SetFocus %p should fail\n", child2
);
2729 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2730 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2731 ret
= SetFocus( child
);
2732 ok( ret
== 0, "SetFocus %p should fail\n", child
);
2733 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2734 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2735 SetWindowLongW( child
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
2737 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
2738 ok( GetFocus() == child2
, "Focus should be on child2 %p\n", child2
);
2740 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2741 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2743 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
2744 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2746 DestroyWindow( child2
);
2747 DestroyWindow( child
);
2750 static void test_SetActiveWindow(HWND hwnd
)
2754 flush_events( TRUE
);
2755 ShowWindow(hwnd
, SW_HIDE
);
2758 check_wnd_state(0, 0, 0, 0);
2760 /*trace("testing SetActiveWindow %p\n", hwnd);*/
2762 ShowWindow(hwnd
, SW_SHOW
);
2763 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2765 hwnd2
= SetActiveWindow(0);
2766 ok(hwnd2
== hwnd
, "SetActiveWindow returned %p instead of %p\n", hwnd2
, hwnd
);
2767 if (!GetActiveWindow()) /* doesn't always work on vista */
2769 check_wnd_state(0, 0, 0, 0);
2770 hwnd2
= SetActiveWindow(hwnd
);
2771 ok(hwnd2
== 0, "SetActiveWindow returned %p instead of 0\n", hwnd2
);
2773 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2775 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2776 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2778 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2779 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2781 ShowWindow(hwnd
, SW_HIDE
);
2782 check_wnd_state(0, 0, 0, 0);
2784 /*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/
2785 SetActiveWindow(hwnd
);
2786 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2788 ShowWindow(hwnd
, SW_SHOW
);
2789 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2791 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2792 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2794 DestroyWindow(hwnd2
);
2795 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2797 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2798 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2800 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2801 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2803 DestroyWindow(hwnd2
);
2804 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2807 struct create_window_thread_params
2810 HANDLE window_created
;
2811 HANDLE test_finished
;
2814 static DWORD WINAPI
create_window_thread(void *param
)
2816 struct create_window_thread_params
*p
= param
;
2820 p
->window
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
2822 ret
= SetEvent(p
->window_created
);
2823 ok(ret
, "SetEvent failed, last error %#x.\n", GetLastError());
2825 res
= WaitForSingleObject(p
->test_finished
, INFINITE
);
2826 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
2828 DestroyWindow(p
->window
);
2832 static void test_SetForegroundWindow(HWND hwnd
)
2834 struct create_window_thread_params thread_params
;
2842 flush_events( TRUE
);
2843 ShowWindow(hwnd
, SW_HIDE
);
2846 check_wnd_state(0, 0, 0, 0);
2848 /*trace("testing SetForegroundWindow %p\n", hwnd);*/
2850 ShowWindow(hwnd
, SW_SHOW
);
2851 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2853 hwnd2
= SetActiveWindow(0);
2854 ok(hwnd2
== hwnd
, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2
, hwnd
);
2855 if (GetActiveWindow() == hwnd
) /* doesn't always work on vista */
2856 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2858 check_wnd_state(0, 0, 0, 0);
2860 ret
= SetForegroundWindow(hwnd
);
2863 skip( "SetForegroundWindow not working\n" );
2866 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2868 SetLastError(0xdeadbeef);
2869 ret
= SetForegroundWindow(0);
2870 ok(!ret
, "SetForegroundWindow returned TRUE instead of FALSE\n");
2871 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
2872 broken(GetLastError() == 0xdeadbeef), /* win9x */
2873 "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
2874 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2876 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2877 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2879 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2880 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2882 hwnd2
= GetForegroundWindow();
2883 ok(hwnd2
== hwnd
, "Wrong foreground window %p\n", hwnd2
);
2884 ret
= SetForegroundWindow( GetDesktopWindow() );
2885 ok(ret
, "SetForegroundWindow(desktop) error: %d\n", GetLastError());
2886 hwnd2
= GetForegroundWindow();
2887 ok(hwnd2
!= hwnd
, "Wrong foreground window %p\n", hwnd2
);
2889 ShowWindow(hwnd
, SW_HIDE
);
2890 check_wnd_state(0, 0, 0, 0);
2892 /*trace("testing SetForegroundWindow on an invisible window %p\n", hwnd);*/
2893 ret
= SetForegroundWindow(hwnd
);
2894 ok(ret
|| broken(!ret
), /* win98 */ "SetForegroundWindow returned FALSE instead of TRUE\n");
2895 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2897 ShowWindow(hwnd
, SW_SHOW
);
2898 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2900 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2901 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2903 DestroyWindow(hwnd2
);
2904 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2906 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2907 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2909 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2910 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2912 DestroyWindow(hwnd2
);
2913 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2915 hwnd2
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
2916 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2918 thread_params
.window_created
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2919 ok(!!thread_params
.window_created
, "CreateEvent failed, last error %#x.\n", GetLastError());
2920 thread_params
.test_finished
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2921 ok(!!thread_params
.test_finished
, "CreateEvent failed, last error %#x.\n", GetLastError());
2922 thread
= CreateThread(NULL
, 0, create_window_thread
, &thread_params
, 0, &tid
);
2923 ok(!!thread
, "Failed to create thread, last error %#x.\n", GetLastError());
2924 res
= WaitForSingleObject(thread_params
.window_created
, INFINITE
);
2925 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
2926 check_wnd_state(hwnd2
, thread_params
.window
, hwnd2
, 0);
2928 SetForegroundWindow(hwnd2
);
2929 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2931 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2932 if (0) check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2933 todo_wine
ok(GetActiveWindow() == hwnd2
, "Expected active window %p, got %p.\n", hwnd2
, GetActiveWindow());
2934 todo_wine
ok(GetFocus() == hwnd2
, "Expected focus window %p, got %p.\n", hwnd2
, GetFocus());
2936 SetForegroundWindow(hwnd
);
2937 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2938 style
= GetWindowLongA(hwnd2
, GWL_STYLE
) | WS_CHILD
;
2939 ok(SetWindowLongA(hwnd2
, GWL_STYLE
, style
), "SetWindowLong failed\n");
2940 ok(SetForegroundWindow(hwnd2
), "SetForegroundWindow failed\n");
2941 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2943 SetForegroundWindow(hwnd
);
2944 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2945 ok(SetWindowLongA(hwnd2
, GWL_STYLE
, style
& (~WS_POPUP
)), "SetWindowLong failed\n");
2946 ok(!SetForegroundWindow(hwnd2
), "SetForegroundWindow failed\n");
2947 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2949 SetEvent(thread_params
.test_finished
);
2950 WaitForSingleObject(thread
, INFINITE
);
2951 CloseHandle(thread_params
.test_finished
);
2952 CloseHandle(thread_params
.window_created
);
2953 CloseHandle(thread
);
2954 DestroyWindow(hwnd2
);
2957 static WNDPROC old_button_proc
;
2959 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2964 key_state
= GetKeyState(VK_LBUTTON
);
2965 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
2967 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
2969 if (msg
== WM_LBUTTONDOWN
)
2973 check_wnd_state(button
, button
, button
, button
);
2975 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2977 trace("hwnd %p\n", hwnd
);
2979 check_wnd_state(button
, button
, button
, button
);
2981 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2983 check_wnd_state(button
, button
, button
, button
);
2985 DestroyWindow(hwnd
);
2987 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2989 trace("hwnd %p\n", hwnd
);
2991 check_wnd_state(button
, button
, button
, button
);
2993 /* button wnd proc should release capture on WM_KILLFOCUS if it does
2994 * match internal button state.
2996 SendMessageA(button
, WM_KILLFOCUS
, 0, 0);
2997 check_wnd_state(button
, button
, button
, 0);
2999 ShowWindow(hwnd
, SW_SHOW
);
3000 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
3002 capture
= SetCapture(hwnd
);
3003 ok(capture
== 0, "SetCapture() = %p\n", capture
);
3005 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
3007 DestroyWindow(hwnd
);
3009 check_wnd_state(button
, 0, button
, 0);
3015 static void test_capture_1(void)
3017 HWND button
, capture
;
3019 capture
= GetCapture();
3020 ok(capture
== 0, "GetCapture() = %p\n", capture
);
3022 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3024 trace("button %p\n", button
);
3026 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
3028 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
3030 capture
= SetCapture(button
);
3031 ok(capture
== 0, "SetCapture() = %p\n", capture
);
3032 check_wnd_state(button
, 0, button
, button
);
3034 DestroyWindow(button
);
3035 /* old active window test depends on previously executed window
3036 * activation tests, and fails under NT4.
3037 check_wnd_state(oldActive, 0, oldFocus, 0);*/
3040 static void test_capture_2(void)
3042 HWND button
, hwnd
, capture
, oldFocus
, oldActive
;
3044 oldFocus
= GetFocus();
3045 oldActive
= GetActiveWindow();
3046 check_wnd_state(oldActive
, 0, oldFocus
, 0);
3048 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3050 trace("button %p\n", button
);
3052 check_wnd_state(button
, button
, button
, 0);
3054 capture
= SetCapture(button
);
3055 ok(capture
== 0, "SetCapture() = %p\n", capture
);
3057 check_wnd_state(button
, button
, button
, button
);
3059 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
3060 * internal button state.
3062 SendMessageA(button
, WM_KILLFOCUS
, 0, 0);
3063 check_wnd_state(button
, button
, button
, button
);
3065 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3067 trace("hwnd %p\n", hwnd
);
3069 check_wnd_state(button
, button
, button
, button
);
3071 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
3073 check_wnd_state(button
, button
, button
, button
);
3075 DestroyWindow(hwnd
);
3077 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3079 trace("hwnd %p\n", hwnd
);
3081 check_wnd_state(button
, button
, button
, button
);
3083 ShowWindow(hwnd
, SW_SHOW
);
3085 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
3087 capture
= SetCapture(hwnd
);
3088 ok(capture
== button
, "SetCapture() = %p\n", capture
);
3090 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
3092 DestroyWindow(hwnd
);
3093 check_wnd_state(button
, button
, button
, 0);
3095 DestroyWindow(button
);
3096 check_wnd_state(oldActive
, 0, oldFocus
, 0);
3099 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
3103 ShowWindow(hwnd1
, SW_HIDE
);
3104 ShowWindow(hwnd2
, SW_HIDE
);
3106 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
3107 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
3110 check_wnd_state(0, 0, 0, hwnd1
);
3113 check_wnd_state(0, 0, 0, hwnd2
);
3115 ShowWindow(hwnd1
, SW_SHOW
);
3116 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
3118 ret
= ReleaseCapture();
3119 ok (ret
, "releasecapture did not return TRUE.\n");
3120 ret
= ReleaseCapture();
3121 ok (ret
, "releasecapture did not return TRUE after second try.\n");
3124 static LRESULT CALLBACK
test_capture_4_proc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3127 HWND cap_wnd
, cap_wnd2
, set_cap_wnd
;
3131 case WM_CAPTURECHANGED
:
3133 /* now try to release capture from menu. this should fail */
3134 if (pGetGUIThreadInfo
)
3136 memset(>i
, 0, sizeof(GUITHREADINFO
));
3137 gti
.cbSize
= sizeof(GUITHREADINFO
);
3138 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
3139 ok(status
, "GetGUIThreadInfo() failed!\n");
3140 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
3142 cap_wnd
= GetCapture();
3144 ok(cap_wnd
== (HWND
)lParam
, "capture window %p does not match lparam %lx\n", cap_wnd
, lParam
);
3145 todo_wine
ok(cap_wnd
== hWnd
, "capture window %p does not match hwnd %p\n", cap_wnd
, hWnd
);
3147 /* check that re-setting the capture for the menu fails */
3148 set_cap_wnd
= SetCapture(cap_wnd
);
3149 ok(!set_cap_wnd
|| broken(set_cap_wnd
== cap_wnd
), /* nt4 */
3150 "SetCapture should have failed!\n");
3153 DestroyWindow(hWnd
);
3157 /* check that SetCapture fails for another window and that it does not touch the error code */
3158 set_cap_wnd
= SetCapture(hWnd
);
3159 ok(!set_cap_wnd
, "SetCapture should have failed!\n");
3161 /* check that ReleaseCapture fails and does not touch the error code */
3162 status
= ReleaseCapture();
3163 ok(!status
, "ReleaseCapture should have failed!\n");
3165 /* check that thread info did not change */
3166 if (pGetGUIThreadInfo
)
3168 memset(>i
, 0, sizeof(GUITHREADINFO
));
3169 gti
.cbSize
= sizeof(GUITHREADINFO
);
3170 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
3171 ok(status
, "GetGUIThreadInfo() failed!\n");
3172 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
3175 /* verify that no capture change took place */
3176 cap_wnd2
= GetCapture();
3177 ok(cap_wnd2
== cap_wnd
, "Capture changed!\n");
3179 /* we are done. kill the window */
3180 DestroyWindow(hWnd
);
3184 return( DefWindowProcA( hWnd
, msg
, wParam
, lParam
) );
3189 /* Test that no-one can mess around with the current capture while a menu is open */
3190 static void test_capture_4(void)
3196 HINSTANCE hInstance
= GetModuleHandleA( NULL
);
3199 if (!pGetGUIThreadInfo
)
3201 win_skip("GetGUIThreadInfo is not available\n");
3204 wclass
.lpszClassName
= "TestCapture4Class";
3205 wclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
3206 wclass
.lpfnWndProc
= test_capture_4_proc
;
3207 wclass
.hInstance
= hInstance
;
3208 wclass
.hIcon
= LoadIconA( 0, (LPCSTR
)IDI_APPLICATION
);
3209 wclass
.hCursor
= LoadCursorA( 0, (LPCSTR
)IDC_ARROW
);
3210 wclass
.hbrBackground
= (HBRUSH
)( COLOR_WINDOW
+ 1 );
3211 wclass
.lpszMenuName
= 0;
3212 wclass
.cbClsExtra
= 0;
3213 wclass
.cbWndExtra
= 0;
3214 aclass
= RegisterClassA( &wclass
);
3215 ok( aclass
, "RegisterClassA failed with error %d\n", GetLastError());
3216 hwnd
= CreateWindowA( wclass
.lpszClassName
, "MenuTest",
3217 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0,
3218 400, 200, NULL
, NULL
, hInstance
, NULL
);
3219 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
3221 hmenu
= CreatePopupMenu();
3223 ret
= AppendMenuA( hmenu
, MF_STRING
, 1, "winetest2");
3224 ok( ret
, "AppendMenuA has failed!\n");
3226 /* set main window to have initial capture */
3231 win_skip("TrackPopupMenu test crashes on Win9x/WinMe\n");
3235 /* create popup (it will self-destruct) */
3236 ret
= TrackPopupMenu(hmenu
, TPM_RETURNCMD
, 100, 100, 0, hwnd
, NULL
);
3237 ok( ret
== 0, "TrackPopupMenu returned %d expected zero\n", ret
);
3242 DestroyWindow(hwnd
);
3245 /* PeekMessage wrapper that ignores the messages we don't care about */
3246 static BOOL
peek_message( MSG
*msg
)
3251 ret
= PeekMessageA(msg
, 0, 0, 0, PM_REMOVE
);
3252 } while (ret
&& (msg
->message
== WM_TIMER
|| ignore_message(msg
->message
)));
3256 static void test_keyboard_input(HWND hwnd
)
3261 flush_events( TRUE
);
3262 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_SHOWWINDOW
);
3264 flush_events( TRUE
);
3266 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
3269 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3271 flush_events( TRUE
);
3273 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3274 ret
= peek_message(&msg
);
3275 ok( ret
, "no message available\n");
3276 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3277 ret
= peek_message(&msg
);
3278 ok( !ret
, "message %04x available\n", msg
.message
);
3280 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3282 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3283 ret
= peek_message(&msg
);
3284 ok(ret
, "no message available\n");
3285 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3286 ret
= peek_message(&msg
);
3287 ok( !ret
, "message %04x available\n", msg
.message
);
3289 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3291 keybd_event(VK_SPACE
, 0, 0, 0);
3292 if (!peek_message(&msg
))
3294 skip( "keybd_event didn't work, skipping keyboard test\n" );
3297 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3298 ret
= peek_message(&msg
);
3299 ok( !ret
, "message %04x available\n", msg
.message
);
3302 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3304 flush_events( TRUE
);
3306 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3307 ret
= peek_message(&msg
);
3308 ok(ret
, "no message available\n");
3309 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3310 ret
= peek_message(&msg
);
3311 ok( !ret
, "message %04x available\n", msg
.message
);
3313 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3315 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3316 ret
= peek_message(&msg
);
3317 ok(ret
, "no message available\n");
3318 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3319 ret
= peek_message(&msg
);
3320 ok( !ret
, "message %04x available\n", msg
.message
);
3322 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3324 keybd_event(VK_SPACE
, 0, 0, 0);
3325 ret
= peek_message(&msg
);
3326 ok(ret
, "no message available\n");
3327 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3328 ret
= peek_message(&msg
);
3329 ok( !ret
, "message %04x available\n", msg
.message
);
3332 static BOOL
wait_for_message( MSG
*msg
)
3338 ret
= peek_message(msg
);
3341 if (msg
->message
== WM_PAINT
) DispatchMessageA(msg
);
3344 else if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
3346 if (!ret
) msg
->message
= 0;
3350 static void test_mouse_input(HWND hwnd
)
3360 ShowWindow(hwnd
, SW_SHOWNORMAL
);
3362 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3364 GetWindowRect(hwnd
, &rc
);
3365 trace("main window %p: (%d,%d)-(%d,%d)\n", hwnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3367 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
3368 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
3371 ShowWindow(popup
, SW_SHOW
);
3372 UpdateWindow(popup
);
3373 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3375 GetWindowRect(popup
, &rc
);
3376 trace("popup window %p: (%d,%d)-(%d,%d)\n", popup
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3378 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
3379 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
3380 trace("setting cursor to (%d,%d)\n", x
, y
);
3384 if (x
!= pt
.x
|| y
!= pt
.y
)
3386 skip( "failed to set mouse position, skipping mouse input tests\n" );
3390 flush_events( TRUE
);
3392 /* Check that setting the same position may generate WM_MOUSEMOVE */
3395 ret
= peek_message(&msg
);
3398 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n",
3399 msg
.hwnd
, msg
.message
);
3400 ok(msg
.pt
.x
== x
&& msg
.pt
.y
== y
, "wrong message coords (%d,%d)/(%d,%d)\n",
3401 x
, y
, msg
.pt
.x
, msg
.pt
.y
);
3404 /* force the system to update its internal queue mouse position,
3405 * otherwise it won't generate relative mouse movements below.
3407 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3408 flush_events( TRUE
);
3411 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3412 flush_events( FALSE
);
3413 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
3414 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
3416 if (msg
.message
== WM_TIMER
|| ignore_message(msg
.message
)) continue;
3417 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
,
3418 "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3419 DispatchMessageA(&msg
);
3421 ret
= peek_message(&msg
);
3422 ok( !ret
, "message %04x available\n", msg
.message
);
3424 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3425 ShowWindow(popup
, SW_HIDE
);
3426 ret
= wait_for_message( &msg
);
3428 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3429 flush_events( TRUE
);
3431 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3432 ShowWindow(hwnd
, SW_HIDE
);
3433 ret
= wait_for_message( &msg
);
3434 ok( !ret
, "message %04x available\n", msg
.message
);
3435 flush_events( TRUE
);
3437 /* test mouse clicks */
3439 ShowWindow(hwnd
, SW_SHOW
);
3440 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3441 flush_events( TRUE
);
3442 ShowWindow(popup
, SW_SHOW
);
3443 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3444 flush_events( TRUE
);
3446 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3447 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3448 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3449 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3451 ret
= wait_for_message( &msg
);
3454 skip( "simulating mouse click doesn't work, skipping mouse button tests\n" );
3457 if (msg
.message
== WM_MOUSEMOVE
) /* win2k has an extra WM_MOUSEMOVE here */
3459 ret
= wait_for_message( &msg
);
3460 ok(ret
, "no message available\n");
3463 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3464 msg
.hwnd
, popup
, msg
.message
);
3466 ret
= wait_for_message( &msg
);
3467 ok(ret
, "no message available\n");
3468 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3469 msg
.hwnd
, popup
, msg
.message
);
3471 ret
= wait_for_message( &msg
);
3472 ok(ret
, "no message available\n");
3473 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p/%p message %04x\n",
3474 msg
.hwnd
, popup
, msg
.message
);
3476 ret
= wait_for_message( &msg
);
3477 ok(ret
, "no message available\n");
3478 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3479 msg
.hwnd
, popup
, msg
.message
);
3481 ret
= peek_message(&msg
);
3482 ok(!ret
, "message %04x available\n", msg
.message
);
3484 ShowWindow(popup
, SW_HIDE
);
3485 flush_events( TRUE
);
3487 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3488 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3489 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3490 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3492 ret
= wait_for_message( &msg
);
3493 ok(ret
, "no message available\n");
3494 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3495 msg
.hwnd
, hwnd
, msg
.message
);
3496 ret
= wait_for_message( &msg
);
3497 ok(ret
, "no message available\n");
3498 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3499 msg
.hwnd
, hwnd
, msg
.message
);
3501 test_lbuttondown_flag
= TRUE
;
3502 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
3503 test_lbuttondown_flag
= FALSE
;
3505 ret
= wait_for_message( &msg
);
3506 ok(ret
, "no message available\n");
3507 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3508 msg
.hwnd
, popup
, msg
.message
);
3509 ok(peek_message(&msg
), "no message available\n");
3510 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3511 msg
.hwnd
, popup
, msg
.message
);
3512 ok(peek_message(&msg
), "no message available\n");
3514 /* Test WM_MOUSEACTIVATE */
3515 #define TEST_MOUSEACTIVATE(A,B) \
3516 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
3517 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
3519 TEST_MOUSEACTIVATE(HTERROR
,MA_ACTIVATE
);
3520 TEST_MOUSEACTIVATE(HTTRANSPARENT
,MA_ACTIVATE
);
3521 TEST_MOUSEACTIVATE(HTNOWHERE
,MA_ACTIVATE
);
3522 TEST_MOUSEACTIVATE(HTCLIENT
,MA_ACTIVATE
);
3523 TEST_MOUSEACTIVATE(HTCAPTION
,MA_ACTIVATE
);
3524 TEST_MOUSEACTIVATE(HTSYSMENU
,MA_ACTIVATE
);
3525 TEST_MOUSEACTIVATE(HTSIZE
,MA_ACTIVATE
);
3526 TEST_MOUSEACTIVATE(HTMENU
,MA_ACTIVATE
);
3527 TEST_MOUSEACTIVATE(HTHSCROLL
,MA_ACTIVATE
);
3528 TEST_MOUSEACTIVATE(HTVSCROLL
,MA_ACTIVATE
);
3529 TEST_MOUSEACTIVATE(HTMINBUTTON
,MA_ACTIVATE
);
3530 TEST_MOUSEACTIVATE(HTMAXBUTTON
,MA_ACTIVATE
);
3531 TEST_MOUSEACTIVATE(HTLEFT
,MA_ACTIVATE
);
3532 TEST_MOUSEACTIVATE(HTRIGHT
,MA_ACTIVATE
);
3533 TEST_MOUSEACTIVATE(HTTOP
,MA_ACTIVATE
);
3534 TEST_MOUSEACTIVATE(HTTOPLEFT
,MA_ACTIVATE
);
3535 TEST_MOUSEACTIVATE(HTTOPRIGHT
,MA_ACTIVATE
);
3536 TEST_MOUSEACTIVATE(HTBOTTOM
,MA_ACTIVATE
);
3537 TEST_MOUSEACTIVATE(HTBOTTOMLEFT
,MA_ACTIVATE
);
3538 TEST_MOUSEACTIVATE(HTBOTTOMRIGHT
,MA_ACTIVATE
);
3539 TEST_MOUSEACTIVATE(HTBORDER
,MA_ACTIVATE
);
3540 TEST_MOUSEACTIVATE(HTOBJECT
,MA_ACTIVATE
);
3541 TEST_MOUSEACTIVATE(HTCLOSE
,MA_ACTIVATE
);
3542 TEST_MOUSEACTIVATE(HTHELP
,MA_ACTIVATE
);
3545 /* Clear any messages left behind by WM_MOUSEACTIVATE tests */
3546 flush_events( TRUE
);
3548 DestroyWindow(popup
);
3551 static void test_validatergn(HWND hwnd
)
3557 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
3558 ShowWindow(hwnd
, SW_SHOW
);
3559 UpdateWindow( hwnd
);
3560 /* test that ValidateRect validates children*/
3561 InvalidateRect( child
, NULL
, 1);
3562 GetWindowRect( child
, &rc
);
3563 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3564 ret
= GetUpdateRect( child
, &rc2
, 0);
3565 ok( ret
== 1, "Expected GetUpdateRect to return non-zero, got %d\n", ret
);
3566 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
3567 "Update rectangle is empty!\n");
3568 ValidateRect( hwnd
, &rc
);
3569 ret
= GetUpdateRect( child
, &rc2
, 0);
3570 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3571 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3572 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
3573 rc2
.right
, rc2
.bottom
);
3575 /* now test ValidateRgn */
3576 InvalidateRect( child
, NULL
, 1);
3577 GetWindowRect( child
, &rc
);
3578 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3579 rgn
= CreateRectRgnIndirect( &rc
);
3580 ValidateRgn( hwnd
, rgn
);
3581 ret
= GetUpdateRect( child
, &rc2
, 0);
3582 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3583 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3584 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
3585 rc2
.right
, rc2
.bottom
);
3588 DestroyWindow( child
);
3591 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
3594 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
3595 GetWindowRect( hwnd
, prc
);
3597 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
3598 trace("window rect is %d,%d - %d,%d, nccalc rect is %d,%d - %d,%d\n",
3599 rc
.left
,rc
.top
,rc
.right
,rc
.bottom
, prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
3602 static void test_nccalcscroll(HWND parent
)
3605 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
3606 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
3607 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
3608 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
3609 10, 10, 200, 200, parent
, 0, 0, NULL
);
3610 ShowWindow( parent
, SW_SHOW
);
3611 UpdateWindow( parent
);
3613 /* test window too low for a horizontal scroll bar */
3614 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
3615 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %d,%d - %d,%d\n",
3616 sbheight
, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3618 /* test window just high enough for a horizontal scroll bar */
3619 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
3620 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be %d size is %d,%d - %d,%d\n",
3621 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3623 /* test window too narrow for a vertical scroll bar */
3624 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
3625 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %d,%d - %d,%d\n",
3626 sbwidth
- 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3628 /* test window just wide enough for a vertical scroll bar */
3629 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
3630 ok( rc1
.right
- rc1
.left
== 0, "Width should be %d size is %d,%d - %d,%d\n",
3631 0, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3633 /* same test, but with client edge: not enough width */
3634 SetWindowLongA( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLongA( hwnd
, GWL_EXSTYLE
));
3635 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
3636 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
3637 "Width should be %d size is %d,%d - %d,%d\n",
3638 sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
), rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3640 DestroyWindow( hwnd
);
3643 static void test_SetParent(void)
3645 HWND desktop
= GetDesktopWindow();
3647 HWND ret
, parent
, child1
, child2
, child3
, child4
, sibling
, popup
;
3650 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3651 100, 100, 200, 200, 0, 0, 0, NULL
);
3652 assert(parent
!= 0);
3653 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3654 0, 0, 50, 50, parent
, 0, 0, NULL
);
3655 assert(child1
!= 0);
3656 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3657 0, 0, 50, 50, child1
, 0, 0, NULL
);
3658 assert(child2
!= 0);
3659 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3660 0, 0, 50, 50, child2
, 0, 0, NULL
);
3661 assert(child3
!= 0);
3662 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3663 0, 0, 50, 50, child3
, 0, 0, NULL
);
3664 assert(child4
!= 0);
3666 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
3667 parent
, child1
, child2
, child3
, child4
);
3669 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
3670 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
3671 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3672 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3673 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3675 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
3676 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
3677 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
3678 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
3679 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
3681 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
3682 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
3683 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
3684 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
3685 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
3686 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
3687 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
3688 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
3689 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
3691 if (!is_win9x
) /* Win9x doesn't survive this test */
3693 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
3694 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
3695 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
3696 ret
= SetParent(parent
, child2
);
3697 todo_wine
ok( !ret
|| broken( ret
!= 0 ), "SetParent should fail\n");
3698 if (ret
) /* nt4, win2k */
3700 ret
= SetParent(parent
, child3
);
3701 ok(ret
!= 0, "SetParent should not fail\n");
3702 ret
= SetParent(child2
, parent
);
3703 ok(!ret
, "SetParent should fail\n");
3704 ret
= SetParent(parent
, child4
);
3705 ok(ret
!= 0, "SetParent should not fail\n");
3706 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
3707 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
3708 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3709 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3710 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3714 ret
= SetParent(parent
, child3
);
3715 ok(ret
!= 0, "SetParent should not fail\n");
3716 ret
= SetParent(child2
, parent
);
3717 ok(!ret
, "SetParent should fail\n");
3718 ret
= SetParent(parent
, child4
);
3719 ok(!ret
, "SetParent should fail\n");
3720 check_parents(parent
, child3
, child3
, 0, 0, child2
, parent
);
3721 check_parents(child1
, parent
, parent
, parent
, 0, child2
, parent
);
3722 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3723 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3724 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3728 skip("Win9x/WinMe crash\n");
3730 hMenu
= CreateMenu();
3731 sibling
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3732 100, 100, 200, 200, 0, hMenu
, 0, NULL
);
3733 assert(sibling
!= 0);
3735 ok(SetParent(sibling
, parent
) != 0, "SetParent should not fail\n");
3736 ok(GetMenu(sibling
) == hMenu
, "SetParent should not remove menu\n");
3738 ok(SetParent(parent
, desktop
) != 0, "SetParent should not fail\n");
3739 ok(SetParent(child4
, child3
) != 0, "SetParent should not fail\n");
3740 ok(SetParent(child3
, child2
) != 0, "SetParent should not fail\n");
3741 ok(SetParent(child2
, child1
) != 0, "SetParent should not fail\n");
3742 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
3743 SetWindowLongW(child4
, GWL_STYLE
, WS_CHILD
);
3744 ok(IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
3745 ok(IsChild(child2
, child4
), "wrong parent/child %p/%p\n", child2
, child4
);
3746 ok(!IsChild(child1
, child4
), "wrong parent/child %p/%p\n", child1
, child4
);
3747 SetWindowLongW(child2
, GWL_STYLE
, WS_CHILD
);
3748 ok(IsChild(child1
, child4
), "wrong parent/child %p/%p\n", child1
, child4
);
3749 ok(IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
3751 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
3753 ok(!IsWindow(parent
), "parent still exists\n");
3754 ok(!IsWindow(sibling
), "sibling still exists\n");
3755 ok(!IsWindow(child1
), "child1 still exists\n");
3756 ok(!IsWindow(child2
), "child2 still exists\n");
3757 ok(!IsWindow(child3
), "child3 still exists\n");
3758 ok(!IsWindow(child4
), "child4 still exists\n");
3760 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3761 100, 100, 200, 200, 0, 0, 0, NULL
);
3762 assert(parent
!= 0);
3763 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3764 0, 0, 50, 50, parent
, 0, 0, NULL
);
3765 assert(child1
!= 0);
3766 popup
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3767 0, 0, 50, 50, 0, 0, 0, NULL
);
3770 trace("parent %p, child %p, popup %p\n", parent
, child1
, popup
);
3772 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
3773 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
3774 check_parents(popup
, desktop
, 0, 0, 0, popup
, popup
);
3776 SetActiveWindow(parent
);
3778 check_active_state(parent
, 0, parent
);
3780 ret
= SetParent(popup
, child1
);
3781 ok(ret
== desktop
, "expected %p, got %p\n", desktop
, ret
);
3782 check_parents(popup
, child1
, child1
, 0, 0, parent
, popup
);
3783 check_active_state(popup
, 0, popup
);
3785 SetActiveWindow(parent
);
3787 check_active_state(popup
, 0, popup
);
3789 EnableWindow(child1
, FALSE
);
3790 check_active_state(popup
, 0, popup
);
3792 check_active_state(parent
, 0, parent
);
3794 check_active_state(popup
, 0, popup
);
3795 EnableWindow(child1
, TRUE
);
3797 ShowWindow(child1
, SW_MINIMIZE
);
3799 check_active_state(parent
, 0, parent
);
3801 check_active_state(popup
, 0, popup
);
3802 ShowWindow(child1
, SW_HIDE
);
3804 SetActiveWindow(parent
);
3806 check_active_state(parent
, 0, parent
);
3808 bret
= SetForegroundWindow(popup
);
3809 ok(bret
, "SetForegroundWindow() failed\n");
3810 check_active_state(popup
, popup
, popup
);
3812 ShowWindow(parent
, SW_SHOW
);
3813 SetActiveWindow(popup
);
3814 ok(DestroyWindow(popup
), "DestroyWindow() failed\n");
3815 check_active_state(parent
, parent
, parent
);
3817 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
3819 ok(!IsWindow(parent
), "parent still exists\n");
3820 ok(!IsWindow(child1
), "child1 still exists\n");
3821 ok(!IsWindow(popup
), "popup still exists\n");
3824 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3826 LPCREATESTRUCTA lpcs
;
3833 lpcs
= (LPCREATESTRUCTA
)lparam
;
3834 lpss
= lpcs
->lpCreateParams
;
3837 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
3838 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
3839 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
3840 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
3842 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
3844 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
3845 "Ex style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
3846 lpss
->styleOld
, lpcs
->dwExStyle
);
3848 ok(lpss
->styleNew
== lpcs
->style
,
3849 "Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
3850 lpss
->styleNew
, lpcs
->style
);
3854 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
3857 static ATOM atomStyleCheckClass
;
3859 static void register_style_check_class(void)
3867 GetModuleHandleA(NULL
),
3869 LoadCursorA(0, (LPCSTR
)IDC_ARROW
),
3870 (HBRUSH
)(COLOR_BTNFACE
+1),
3875 atomStyleCheckClass
= RegisterClassA(&wc
);
3876 assert(atomStyleCheckClass
);
3879 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
3881 DWORD dwActualStyle
;
3882 DWORD dwActualExStyle
;
3885 HWND hwndParent
= NULL
;
3887 ss
.styleNew
= dwStyleIn
;
3888 ss
.styleOld
= dwExStyleIn
;
3890 if (dwStyleIn
& WS_CHILD
)
3892 hwndParent
= CreateWindowExA(0, (LPCSTR
)MAKEINTATOM(atomStyleCheckClass
), NULL
,
3893 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
3896 hwnd
= CreateWindowExA(dwExStyleIn
, (LPCSTR
)MAKEINTATOM(atomStyleCheckClass
), NULL
,
3897 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
3900 flush_events( TRUE
);
3902 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
3903 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3904 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3905 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3907 /* try setting the styles explicitly */
3908 SetWindowLongA( hwnd
, GWL_EXSTYLE
, dwExStyleIn
);
3909 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
3910 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3911 /* WS_EX_WINDOWEDGE can't always be changed */
3912 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
3913 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3914 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
3915 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3917 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
3918 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3919 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3921 SetWindowLongA( hwnd
, GWL_STYLE
, dwStyleIn
);
3922 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
3923 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3924 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3925 if ((dwStyleIn
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
) dwStyleOut
= dwStyleIn
;
3926 else dwStyleOut
= dwStyleIn
| WS_CLIPSIBLINGS
;
3927 /* WS_EX_WINDOWEDGE can't always be changed */
3928 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
3929 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3930 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
3931 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3933 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
3934 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3935 /* FIXME: Remove the condition below once Wine is fixed */
3936 if (dwActualExStyle
!= dwExStyleOut
)
3937 todo_wine
ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3939 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3941 DestroyWindow(hwnd
);
3942 if (hwndParent
) DestroyWindow(hwndParent
);
3945 /* tests what window styles the window manager automatically adds */
3946 static void test_window_styles(void)
3948 register_style_check_class();
3950 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3951 check_window_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3952 check_window_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3953 check_window_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
3954 check_window_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
3955 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
3956 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
3957 check_window_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
3958 check_window_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
3959 check_window_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
3960 check_window_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
3961 check_window_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3962 check_window_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
3963 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3964 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3965 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3966 check_window_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3967 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3968 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3969 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3970 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3971 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
3972 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3973 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3974 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
3975 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3976 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3977 check_window_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3978 check_window_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3979 check_window_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3980 check_window_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3981 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
3982 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
3984 if (pGetLayeredWindowAttributes
)
3986 check_window_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
);
3987 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_WINDOWEDGE
);
3988 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
3989 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
);
3993 static INT_PTR WINAPI
empty_dlg_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3998 static void check_dialog_style(DWORD style_in
, DWORD ex_style_in
, DWORD style_out
, DWORD ex_style_out
)
4008 DWORD style
, ex_style
;
4009 HWND hwnd
, parent
= 0;
4011 if (style_in
& WS_CHILD
)
4012 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
4013 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
4015 dlg_data
.dt
.style
= style_in
;
4016 dlg_data
.dt
.dwExtendedStyle
= ex_style_in
;
4017 dlg_data
.dt
.cdit
= 0;
4020 dlg_data
.dt
.cx
= 100;
4021 dlg_data
.dt
.cy
= 100;
4022 dlg_data
.menu_name
= 0;
4023 dlg_data
.class_id
= 0;
4024 dlg_data
.class_atom
= 0;
4025 dlg_data
.caption
[0] = 0;
4027 hwnd
= CreateDialogIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, parent
, empty_dlg_proc
, 0);
4028 ok(hwnd
!= 0, "dialog creation failed, style %#x, exstyle %#x\n", style_in
, ex_style_in
);
4030 flush_events( TRUE
);
4032 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4033 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4034 ok(style
== (style_out
| DS_3DLOOK
), "got %#x\n", style
);
4035 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4037 /* try setting the styles explicitly */
4038 SetWindowLongA(hwnd
, GWL_EXSTYLE
, ex_style_in
);
4039 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4040 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4041 ok(style
== (style_out
| DS_3DLOOK
), "got %#x\n", style
);
4042 /* WS_EX_WINDOWEDGE can't always be changed */
4043 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
4044 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4045 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
4046 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4048 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
4049 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4051 SetWindowLongA(hwnd
, GWL_STYLE
, style_in
);
4052 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4053 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4054 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
4055 if ((style_in
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
) style_out
= style_in
;
4056 else style_out
= style_in
| WS_CLIPSIBLINGS
;
4057 ok(style
== style_out
, "expected style %#x, got %#x\n", style_out
, style
);
4058 /* WS_EX_WINDOWEDGE can't always be changed */
4059 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
4060 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4061 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
4062 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4064 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
4065 /* FIXME: Remove the condition below once Wine is fixed */
4066 if (ex_style
!= ex_style_out
)
4067 todo_wine
ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4069 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4071 DestroyWindow(hwnd
);
4072 DestroyWindow(parent
);
4075 static void test_dialog_styles(void)
4077 check_dialog_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4078 check_dialog_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4079 check_dialog_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4080 check_dialog_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4081 check_dialog_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4082 check_dialog_style(DS_CONTROL
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
|DS_CONTROL
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4083 check_dialog_style(WS_CAPTION
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4084 check_dialog_style(WS_BORDER
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4085 check_dialog_style(WS_DLGFRAME
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4086 check_dialog_style(WS_BORDER
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4087 check_dialog_style(WS_DLGFRAME
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4088 check_dialog_style(WS_CAPTION
|WS_SYSMENU
, 0, WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4089 check_dialog_style(WS_SYSMENU
, 0, WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4090 check_dialog_style(WS_CAPTION
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4091 check_dialog_style(WS_SYSMENU
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4092 check_dialog_style(WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4093 check_dialog_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4094 check_dialog_style(WS_CHILD
, 0, WS_CHILD
, 0);
4095 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
4096 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
4097 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
4098 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
4099 check_dialog_style(WS_CHILD
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4100 check_dialog_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
4101 check_dialog_style(WS_CHILD
|WS_BORDER
, 0, WS_CHILD
|WS_BORDER
, 0);
4102 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
4103 check_dialog_style(WS_CHILD
|WS_BORDER
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4104 check_dialog_style(WS_CHILD
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4105 check_dialog_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
4106 check_dialog_style(WS_CHILD
|WS_SYSMENU
, 0, WS_CHILD
|WS_SYSMENU
, 0);
4107 check_dialog_style(WS_CHILD
|WS_CAPTION
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4108 check_dialog_style(WS_CHILD
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4109 check_dialog_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4110 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4111 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4112 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4113 check_dialog_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4114 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4115 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4116 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4117 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4118 check_dialog_style(WS_CHILD
|WS_POPUP
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4119 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
, 0, WS_CHILD
|WS_POPUP
|WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4120 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_BORDER
, 0, WS_CHILD
|WS_POPUP
|WS_BORDER
|WS_CLIPSIBLINGS
, 0);
4121 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4122 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_BORDER
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4123 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4124 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
);
4125 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_SYSMENU
, 0, WS_CHILD
|WS_POPUP
|WS_SYSMENU
|WS_CLIPSIBLINGS
, 0);
4126 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4127 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4128 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
);
4129 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
4130 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4131 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4132 check_dialog_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
|WS_EX_CONTROLPARENT
);
4133 check_dialog_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4134 check_dialog_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4135 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4136 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4137 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4138 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4139 check_dialog_style(WS_POPUP
|DS_CONTROL
, 0, WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4140 check_dialog_style(WS_POPUP
|WS_CAPTION
, 0, WS_POPUP
|WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4141 check_dialog_style(WS_POPUP
|WS_BORDER
, 0, WS_POPUP
|WS_BORDER
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4142 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4143 check_dialog_style(WS_POPUP
|WS_BORDER
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4144 check_dialog_style(WS_POPUP
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4145 check_dialog_style(WS_POPUP
|WS_CAPTION
|WS_SYSMENU
, 0, WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4146 check_dialog_style(WS_POPUP
|WS_SYSMENU
, 0, WS_POPUP
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4147 check_dialog_style(WS_POPUP
|WS_CAPTION
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4148 check_dialog_style(WS_POPUP
|WS_SYSMENU
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4149 check_dialog_style(WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4150 check_dialog_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4151 check_dialog_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4153 if (pGetLayeredWindowAttributes
)
4155 check_dialog_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4156 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
);
4157 check_dialog_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
4158 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4162 static void test_scrollwindow( HWND hwnd
)
4168 ShowWindow( hwnd
, SW_SHOW
);
4169 UpdateWindow( hwnd
);
4170 flush_events( TRUE
);
4171 GetClientRect( hwnd
, &rc
);
4173 /* test ScrollWindow(Ex) with no clip rectangle */
4174 /* paint the lower half of the window black */
4176 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4177 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4178 /* paint the upper half of the window white */
4179 rc2
.bottom
= rc2
.top
;
4181 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
4182 /* scroll lower half up */
4184 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4185 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, NULL
, NULL
, NULL
, SW_ERASE
);
4186 flush_events(FALSE
);
4187 /* expected: black should have scrolled to the upper half */
4188 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
4189 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4190 /* Repeat that test of ScrollWindow(Ex) now with clip rectangle */
4191 /* paint the lower half of the window black */
4193 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4194 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4195 /* paint the upper half of the window white */
4196 rc2
.bottom
= rc2
.top
;
4198 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
4199 /* scroll lower half up */
4201 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4203 rc3
.left
= rc3
.right
/ 4;
4204 rc3
.right
-= rc3
.right
/ 4;
4205 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, &rc3
, NULL
, NULL
, SW_ERASE
);
4206 flush_events(FALSE
);
4207 /* expected: black should have scrolled to the upper half */
4208 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
4209 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4212 ReleaseDC( hwnd
, hdc
);
4215 static void test_scrollvalidate( HWND parent
)
4218 HRGN hrgn
=CreateRectRgn(0,0,0,0);
4219 HRGN exprgn
, tmprgn
, clipping
;
4220 RECT rc
, rcu
, cliprc
;
4221 /* create two overlapping child windows. The visual region
4222 * of hwnd1 is clipped by the overlapping part of
4223 * hwnd2 because of the WS_CLIPSIBLING style */
4226 clipping
= CreateRectRgn(0,0,0,0);
4227 tmprgn
= CreateRectRgn(0,0,0,0);
4228 exprgn
= CreateRectRgn(0,0,0,0);
4229 hwnd2
= CreateWindowExA(0, "static", NULL
,
4230 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4231 75, 30, 100, 100, parent
, 0, 0, NULL
);
4232 hwnd1
= CreateWindowExA(0, "static", NULL
,
4233 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4234 25, 50, 100, 100, parent
, 0, 0, NULL
);
4235 ShowWindow( parent
, SW_SHOW
);
4236 UpdateWindow( parent
);
4237 GetClientRect( hwnd1
, &rc
);
4239 SetRectRgn( clipping
, 10, 10, 90, 90);
4240 hdc
= GetDC( hwnd1
);
4241 /* for a visual touch */
4242 TextOutA( hdc
, 0,10, "0123456789", 10);
4243 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4244 if (winetest_debug
> 0) dump_region(hrgn
);
4245 /* create a region with what is expected */
4246 SetRectRgn( exprgn
, 39,0,49,74);
4247 SetRectRgn( tmprgn
, 88,79,98,93);
4248 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4249 SetRectRgn( tmprgn
, 0,93,98,98);
4250 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4251 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4252 trace("update rect is %d,%d - %d,%d\n",
4253 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
4254 /* now with clipping region */
4255 SelectClipRgn( hdc
, clipping
);
4256 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4257 if (winetest_debug
> 0) dump_region(hrgn
);
4258 /* create a region with what is expected */
4259 SetRectRgn( exprgn
, 39,10,49,74);
4260 SetRectRgn( tmprgn
, 80,79,90,85);
4261 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4262 SetRectRgn( tmprgn
, 10,85,90,90);
4263 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4264 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4265 trace("update rect is %d,%d - %d,%d\n",
4266 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
4267 ReleaseDC( hwnd1
, hdc
);
4269 /* test scrolling a window with an update region */
4270 DestroyWindow( hwnd2
);
4271 ValidateRect( hwnd1
, NULL
);
4272 SetRect( &rc
, 40,40, 50,50);
4273 InvalidateRect( hwnd1
, &rc
, 1);
4274 GetClientRect( hwnd1
, &rc
);
4276 ScrollWindowEx( hwnd1
, -10, 0, &rc
, &cliprc
, hrgn
, &rcu
,
4277 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4278 if (winetest_debug
> 0) dump_region(hrgn
);
4279 SetRectRgn( exprgn
, 88,0,98,98);
4280 SetRectRgn( tmprgn
, 30, 40, 50, 50);
4281 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4282 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4284 /* clear an update region */
4285 UpdateWindow( hwnd1
);
4287 SetRect( &rc
, 0,40, 100,60);
4288 SetRect( &cliprc
, 0,0, 100,100);
4289 ScrollWindowEx( hwnd1
, 0, -25, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4290 if (winetest_debug
> 0) dump_region( hrgn
);
4291 SetRectRgn( exprgn
, 0, 40, 98, 60 );
4292 ok( EqualRgn( exprgn
, hrgn
), "wrong update region in excessive scroll\n");
4294 /* now test ScrollWindowEx with a combination of
4295 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
4296 /* make hwnd2 the child of hwnd1 */
4297 hwnd2
= CreateWindowExA(0, "static", NULL
,
4298 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
4299 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
4300 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
4301 GetClientRect( hwnd1
, &rc
);
4304 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
4305 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
4306 ValidateRect( hwnd1
, NULL
);
4307 ValidateRect( hwnd2
, NULL
);
4308 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
4309 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4310 if (winetest_debug
> 0) dump_region(hrgn
);
4311 SetRectRgn( exprgn
, 88,0,98,88);
4312 SetRectRgn( tmprgn
, 0,88,98,98);
4313 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4314 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4316 /* SW_SCROLLCHILDREN */
4317 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
4318 ValidateRect( hwnd1
, NULL
);
4319 ValidateRect( hwnd2
, NULL
);
4320 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4321 if (winetest_debug
> 0) dump_region(hrgn
);
4322 /* expected region is the same as in previous test */
4323 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4325 /* no SW_SCROLLCHILDREN */
4326 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
4327 ValidateRect( hwnd1
, NULL
);
4328 ValidateRect( hwnd2
, NULL
);
4329 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4330 if (winetest_debug
> 0) dump_region(hrgn
);
4331 /* expected region is the same as in previous test */
4332 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4334 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
4335 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
4336 ValidateRect( hwnd1
, NULL
);
4337 ValidateRect( hwnd2
, NULL
);
4338 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4339 if (winetest_debug
> 0) dump_region(hrgn
);
4340 SetRectRgn( exprgn
, 88,0,98,20);
4341 SetRectRgn( tmprgn
, 20,20,98,30);
4342 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4343 SetRectRgn( tmprgn
, 20,30,30,88);
4344 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4345 SetRectRgn( tmprgn
, 0,88,30,98);
4346 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4347 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4350 DeleteObject( hrgn
);
4351 DeleteObject( exprgn
);
4352 DeleteObject( tmprgn
);
4353 DestroyWindow( hwnd1
);
4354 DestroyWindow( hwnd2
);
4357 /* couple of tests of return values of scrollbar functions
4358 * called on a scrollbarless window */
4359 static void test_scroll(void)
4364 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
4365 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
4366 100, 100, 200, 200, 0, 0, 0, NULL
);
4368 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
4369 if (!ret
) /* win9x */
4371 win_skip( "GetScrollRange doesn't work\n" );
4372 DestroyWindow( hwnd
);
4375 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
4376 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
4377 si
.cbSize
= sizeof( si
);
4378 si
.fMask
= SIF_PAGE
;
4379 si
.nPage
= 0xdeadbeef;
4380 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
4381 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
4382 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
4384 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
4385 ok( ret
, "GetScrollRange returns FALSE\n");
4386 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
4387 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
4388 si
.cbSize
= sizeof( si
);
4389 si
.fMask
= SIF_PAGE
;
4390 si
.nPage
= 0xdeadbeef;
4391 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
4392 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
4393 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
4395 DestroyWindow( hwnd
);
4398 static void test_scrolldc( HWND parent
)
4401 HRGN exprgn
, tmprgn
, hrgn
;
4402 RECT rc
, rc2
, rcu
, cliprc
;
4406 hrgn
= CreateRectRgn(0,0,0,0);
4407 tmprgn
= CreateRectRgn(0,0,0,0);
4408 exprgn
= CreateRectRgn(0,0,0,0);
4410 hwnd1
= CreateWindowExA(0, "static", NULL
,
4411 WS_CHILD
| WS_VISIBLE
,
4412 25, 50, 100, 100, parent
, 0, 0, NULL
);
4413 ShowWindow( parent
, SW_SHOW
);
4414 UpdateWindow( parent
);
4415 flush_events( TRUE
);
4416 GetClientRect( hwnd1
, &rc
);
4417 hdc
= GetDC( hwnd1
);
4418 /* paint the upper half of the window black */
4420 rc2
.bottom
= ( rc
.top
+ rc
.bottom
) /2;
4421 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4422 /* clip region is the lower half */
4424 cliprc
.top
= (rc
.top
+ rc
.bottom
) /2;
4425 /* test whether scrolled pixels are properly clipped */
4426 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
4427 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4428 /* this scroll should not cause any visible changes */
4429 ScrollDC( hdc
, 5, -20, &rc
, &cliprc
, hrgn
, &rcu
);
4430 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
4431 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4432 /* test with NULL clip rect */
4433 ScrollDC( hdc
, 20, -20, &rc
, NULL
, hrgn
, &rcu
);
4434 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
4435 trace("update rect: %d,%d - %d,%d\n",
4436 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
4437 if (winetest_debug
> 0) dump_region(hrgn
);
4438 SetRect(&rc2
, 0, 0, 100, 100);
4439 ok(EqualRect(&rcu
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
4440 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
4442 SetRectRgn( exprgn
, 0, 0, 20, 80);
4443 SetRectRgn( tmprgn
, 0, 80, 100, 100);
4444 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
4445 if (winetest_debug
> 0) dump_region(exprgn
);
4446 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
4447 /* test clip rect > scroll rect */
4448 FillRect( hdc
, &rc
, GetStockObject(WHITE_BRUSH
));
4450 InflateRect( &rc2
, -(rc
.right
-rc
.left
)/4, -(rc
.bottom
-rc
.top
)/4);
4451 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4452 ScrollDC( hdc
, 10, 10, &rc2
, &rc
, hrgn
, &rcu
);
4453 SetRectRgn( exprgn
, 25, 25, 75, 35);
4454 SetRectRgn( tmprgn
, 25, 35, 35, 75);
4455 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
4456 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
4457 trace("update rect: %d,%d - %d,%d\n",
4458 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
4459 if (winetest_debug
> 0) dump_region(hrgn
);
4463 DeleteObject(exprgn
);
4464 DeleteObject(tmprgn
);
4465 DestroyWindow(hwnd1
);
4468 static void test_params(void)
4473 ok(!IsWindow(0), "IsWindow(0)\n");
4474 ok(!IsWindow(HWND_BROADCAST
), "IsWindow(HWND_BROADCAST)\n");
4475 ok(!IsWindow(HWND_TOPMOST
), "IsWindow(HWND_TOPMOST)\n");
4477 /* Just a param check */
4478 if (pGetMonitorInfoA
)
4480 SetLastError(0xdeadbeef);
4481 rc
= GetWindowTextA(hwndMain2
, NULL
, 1024);
4482 ok( rc
==0, "GetWindowText: rc=%d err=%d\n",rc
,GetLastError());
4486 /* Skips actually on Win95 and NT4 */
4487 win_skip("Test would crash on Win95\n");
4490 SetLastError(0xdeadbeef);
4491 hwnd
=CreateWindowA("LISTBOX", "TestList",
4492 (LBS_STANDARD
& ~LBS_SORT
),
4494 NULL
, (HMENU
)1, NULL
, 0);
4496 ok(!hwnd
|| broken(hwnd
!= NULL
), /* w2k3 sp2 */
4497 "CreateWindow with invalid menu handle should fail\n");
4499 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
|| /* NT */
4500 GetLastError() == 0xdeadbeef, /* Win9x */
4501 "wrong last error value %d\n", GetLastError());
4504 static void test_AWRwindow(LPCSTR
class, LONG style
, LONG exStyle
, BOOL menu
)
4508 hwnd
= CreateWindowExA(exStyle
, class, class, style
,
4515 trace("Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style
, exStyle
);
4518 ShowWindow(hwnd
, SW_SHOW
);
4520 test_nonclient_area(hwnd
);
4523 DestroyWindow(hwnd
);
4526 static BOOL
AWR_init(void)
4530 class.style
= CS_HREDRAW
| CS_VREDRAW
;
4531 class.lpfnWndProc
= DefWindowProcA
;
4532 class.cbClsExtra
= 0;
4533 class.cbWndExtra
= 0;
4534 class.hInstance
= 0;
4535 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
4536 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4537 class.hbrBackground
= 0;
4538 class.lpszMenuName
= 0;
4539 class.lpszClassName
= szAWRClass
;
4541 if (!RegisterClassA(&class)) {
4542 ok(FALSE
, "RegisterClass failed\n");
4546 hmenu
= CreateMenu();
4549 ok(hmenu
!= 0, "Failed to create menu\n");
4550 ok(AppendMenuA(hmenu
, MF_STRING
, 1, "Test!"), "Failed to create menu item\n");
4556 static void test_AWR_window_size(BOOL menu
)
4560 WS_MAXIMIZE
, WS_BORDER
, WS_DLGFRAME
,
4563 WS_MINIMIZEBOX
, WS_MAXIMIZEBOX
,
4564 WS_HSCROLL
, WS_VSCROLL
4568 WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
,
4571 /* These styles have problems on (at least) WinXP (SP2) and Wine */
4572 WS_EX_DLGMODALFRAME
,
4579 /* A exhaustive check of all the styles takes too long
4580 * so just do a (hopefully representative) sample
4582 for (i
= 0; i
< COUNTOF(styles
); ++i
)
4583 test_AWRwindow(szAWRClass
, styles
[i
], 0, menu
);
4584 for (i
= 0; i
< COUNTOF(exStyles
); ++i
) {
4585 test_AWRwindow(szAWRClass
, WS_POPUP
, exStyles
[i
], menu
);
4586 test_AWRwindow(szAWRClass
, WS_THICKFRAME
, exStyles
[i
], menu
);
4591 #define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
4593 static void test_AdjustWindowRect(void)
4598 SHOWSYSMETRIC(SM_CYCAPTION
);
4599 SHOWSYSMETRIC(SM_CYSMCAPTION
);
4600 SHOWSYSMETRIC(SM_CYMENU
);
4601 SHOWSYSMETRIC(SM_CXEDGE
);
4602 SHOWSYSMETRIC(SM_CYEDGE
);
4603 SHOWSYSMETRIC(SM_CXVSCROLL
);
4604 SHOWSYSMETRIC(SM_CYHSCROLL
);
4605 SHOWSYSMETRIC(SM_CXFRAME
);
4606 SHOWSYSMETRIC(SM_CYFRAME
);
4607 SHOWSYSMETRIC(SM_CXDLGFRAME
);
4608 SHOWSYSMETRIC(SM_CYDLGFRAME
);
4609 SHOWSYSMETRIC(SM_CXBORDER
);
4610 SHOWSYSMETRIC(SM_CYBORDER
);
4612 test_AWR_window_size(FALSE
);
4613 test_AWR_window_size(TRUE
);
4617 #undef SHOWSYSMETRIC
4620 /* Global variables to trigger exit from loop */
4621 static int redrawComplete
, WMPAINT_count
;
4623 static LRESULT WINAPI
redraw_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4628 trace("doing WM_PAINT %d\n", WMPAINT_count
);
4630 if (WMPAINT_count
> 10 && redrawComplete
== 0) {
4632 BeginPaint(hwnd
, &ps
);
4633 EndPaint(hwnd
, &ps
);
4638 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4641 /* Ensure we exit from RedrawNow regardless of invalidated area */
4642 static void test_redrawnow(void)
4647 cls
.style
= CS_DBLCLKS
;
4648 cls
.lpfnWndProc
= redraw_window_procA
;
4651 cls
.hInstance
= GetModuleHandleA(0);
4653 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4654 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4655 cls
.lpszMenuName
= NULL
;
4656 cls
.lpszClassName
= "RedrawWindowClass";
4658 if(!RegisterClassA(&cls
)) {
4659 trace("Register failed %d\n", GetLastError());
4663 hwndMain
= CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
4664 CW_USEDEFAULT
, 0, 100, 100, NULL
, NULL
, 0, NULL
);
4666 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4667 ShowWindow(hwndMain
, SW_SHOW
);
4668 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4669 RedrawWindow(hwndMain
, NULL
,NULL
,RDW_UPDATENOW
| RDW_ALLCHILDREN
);
4670 ok( WMPAINT_count
== 1 || broken(WMPAINT_count
== 0), /* sometimes on win9x */
4671 "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4672 redrawComplete
= TRUE
;
4673 ok( WMPAINT_count
< 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count
);
4676 DestroyWindow( hwndMain
);
4679 struct parentdc_stat
{
4685 struct parentdc_test
{
4686 struct parentdc_stat main
, main_todo
;
4687 struct parentdc_stat child1
, child1_todo
;
4688 struct parentdc_stat child2
, child2_todo
;
4691 static LRESULT WINAPI
parentdc_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4696 struct parentdc_stat
*t
= (struct parentdc_stat
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
4701 GetClientRect(hwnd
, &rc
);
4702 CopyRect(&t
->client
, &rc
);
4703 GetWindowRect(hwnd
, &rc
);
4704 trace("WM_PAINT: hwnd %p, client rect (%d,%d)-(%d,%d), window rect (%d,%d)-(%d,%d)\n", hwnd
,
4705 t
->client
.left
, t
->client
.top
, t
->client
.right
, t
->client
.bottom
,
4706 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4707 BeginPaint(hwnd
, &ps
);
4708 CopyRect(&t
->paint
, &ps
.rcPaint
);
4709 GetClipBox(ps
.hdc
, &rc
);
4710 CopyRect(&t
->clip
, &rc
);
4711 trace("clip rect (%d,%d)-(%d,%d), paint rect (%d,%d)-(%d,%d)\n",
4712 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
4713 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
4714 EndPaint(hwnd
, &ps
);
4717 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4720 static void zero_parentdc_stat(struct parentdc_stat
*t
)
4722 SetRectEmpty(&t
->client
);
4723 SetRectEmpty(&t
->clip
);
4724 SetRectEmpty(&t
->paint
);
4727 static void zero_parentdc_test(struct parentdc_test
*t
)
4729 zero_parentdc_stat(&t
->main
);
4730 zero_parentdc_stat(&t
->child1
);
4731 zero_parentdc_stat(&t
->child2
);
4734 #define parentdc_field_ok(t, w, r, f, got) \
4735 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
4736 ": expected %d, got %d\n", \
4739 #define parentdc_todo_field_ok(t, w, r, f, got) \
4740 if (t.w##_todo.r.f) todo_wine { parentdc_field_ok(t, w, r, f, got); } \
4741 else parentdc_field_ok(t, w, r, f, got)
4743 #define parentdc_rect_ok(t, w, r, got) \
4744 parentdc_todo_field_ok(t, w, r, left, got); \
4745 parentdc_todo_field_ok(t, w, r, top, got); \
4746 parentdc_todo_field_ok(t, w, r, right, got); \
4747 parentdc_todo_field_ok(t, w, r, bottom, got);
4749 #define parentdc_win_ok(t, w, got) \
4750 parentdc_rect_ok(t, w, client, got); \
4751 parentdc_rect_ok(t, w, clip, got); \
4752 parentdc_rect_ok(t, w, paint, got);
4754 #define parentdc_ok(t, got) \
4755 parentdc_win_ok(t, main, got); \
4756 parentdc_win_ok(t, child1, got); \
4757 parentdc_win_ok(t, child2, got);
4759 static void test_csparentdc(void)
4761 WNDCLASSA clsMain
, cls
;
4762 HWND hwndMain
, hwnd1
, hwnd2
;
4765 struct parentdc_test test_answer
;
4767 #define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
4768 const struct parentdc_test test1
=
4770 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo
,
4771 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4772 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4775 const struct parentdc_test test2
=
4777 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo
,
4778 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4779 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4782 const struct parentdc_test test3
=
4784 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4785 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4786 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4789 const struct parentdc_test test4
=
4791 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo
,
4792 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo
,
4793 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4796 const struct parentdc_test test5
=
4798 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo
,
4799 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4800 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4803 const struct parentdc_test test6
=
4805 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4806 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4807 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4810 const struct parentdc_test test7
=
4812 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4813 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4814 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4818 clsMain
.style
= CS_DBLCLKS
;
4819 clsMain
.lpfnWndProc
= parentdc_window_procA
;
4820 clsMain
.cbClsExtra
= 0;
4821 clsMain
.cbWndExtra
= 0;
4822 clsMain
.hInstance
= GetModuleHandleA(0);
4824 clsMain
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4825 clsMain
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4826 clsMain
.lpszMenuName
= NULL
;
4827 clsMain
.lpszClassName
= "ParentDcMainWindowClass";
4829 if(!RegisterClassA(&clsMain
)) {
4830 trace("Register failed %d\n", GetLastError());
4834 cls
.style
= CS_DBLCLKS
| CS_PARENTDC
;
4835 cls
.lpfnWndProc
= parentdc_window_procA
;
4838 cls
.hInstance
= GetModuleHandleA(0);
4840 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4841 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4842 cls
.lpszMenuName
= NULL
;
4843 cls
.lpszClassName
= "ParentDcWindowClass";
4845 if(!RegisterClassA(&cls
)) {
4846 trace("Register failed %d\n", GetLastError());
4850 SetRect(&rc
, 0, 0, 150, 150);
4851 AdjustWindowRectEx(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
, 0);
4852 hwndMain
= CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
4853 CW_USEDEFAULT
, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, NULL
, NULL
, 0, NULL
);
4854 SetWindowLongPtrA(hwndMain
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.main
);
4855 hwnd1
= CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD
,
4856 20, 20, 40, 40, hwndMain
, NULL
, 0, NULL
);
4857 SetWindowLongPtrA(hwnd1
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child1
);
4858 hwnd2
= CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD
,
4859 40, 40, 40, 40, hwndMain
, NULL
, 0, NULL
);
4860 SetWindowLongPtrA(hwnd2
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child2
);
4861 ShowWindow(hwndMain
, SW_SHOW
);
4862 ShowWindow(hwnd1
, SW_SHOW
);
4863 ShowWindow(hwnd2
, SW_SHOW
);
4864 SetWindowPos(hwndMain
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
4865 flush_events( TRUE
);
4867 zero_parentdc_test(&test_answer
);
4868 InvalidateRect(hwndMain
, NULL
, TRUE
);
4869 flush_events( TRUE
);
4870 parentdc_ok(test1
, test_answer
);
4872 zero_parentdc_test(&test_answer
);
4873 SetRect(&rc
, 0, 0, 50, 50);
4874 InvalidateRect(hwndMain
, &rc
, TRUE
);
4875 flush_events( TRUE
);
4876 parentdc_ok(test2
, test_answer
);
4878 zero_parentdc_test(&test_answer
);
4879 SetRect(&rc
, 0, 0, 10, 10);
4880 InvalidateRect(hwndMain
, &rc
, TRUE
);
4881 flush_events( TRUE
);
4882 parentdc_ok(test3
, test_answer
);
4884 zero_parentdc_test(&test_answer
);
4885 SetRect(&rc
, 40, 40, 50, 50);
4886 InvalidateRect(hwndMain
, &rc
, TRUE
);
4887 flush_events( TRUE
);
4888 parentdc_ok(test4
, test_answer
);
4890 zero_parentdc_test(&test_answer
);
4891 SetRect(&rc
, 20, 20, 60, 60);
4892 InvalidateRect(hwndMain
, &rc
, TRUE
);
4893 flush_events( TRUE
);
4894 parentdc_ok(test5
, test_answer
);
4896 zero_parentdc_test(&test_answer
);
4897 SetRect(&rc
, 0, 0, 10, 10);
4898 InvalidateRect(hwnd1
, &rc
, TRUE
);
4899 flush_events( TRUE
);
4900 parentdc_ok(test6
, test_answer
);
4902 zero_parentdc_test(&test_answer
);
4903 SetRect(&rc
, -5, -5, 65, 65);
4904 InvalidateRect(hwnd1
, &rc
, TRUE
);
4905 flush_events( TRUE
);
4906 parentdc_ok(test7
, test_answer
);
4908 DestroyWindow(hwndMain
);
4909 DestroyWindow(hwnd1
);
4910 DestroyWindow(hwnd2
);
4913 static LRESULT WINAPI
def_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4915 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4918 static LRESULT WINAPI
def_window_procW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4920 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
4923 static void test_IsWindowUnicode(void)
4925 static const char ansi_class_nameA
[] = "ansi class name";
4926 static const WCHAR ansi_class_nameW
[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
4927 static const char unicode_class_nameA
[] = "unicode class name";
4928 static const WCHAR unicode_class_nameW
[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
4934 memset(&classW
, 0, sizeof(classW
));
4935 classW
.hInstance
= GetModuleHandleA(0);
4936 classW
.lpfnWndProc
= def_window_procW
;
4937 classW
.lpszClassName
= unicode_class_nameW
;
4938 if (!RegisterClassW(&classW
)) return; /* this catches Win9x as well */
4940 memset(&classA
, 0, sizeof(classA
));
4941 classA
.hInstance
= GetModuleHandleA(0);
4942 classA
.lpfnWndProc
= def_window_procA
;
4943 classA
.lpszClassName
= ansi_class_nameA
;
4944 atom
= RegisterClassA(&classA
);
4947 /* unicode class: window proc */
4948 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
4949 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4952 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4953 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4954 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4955 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4956 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4958 DestroyWindow(hwnd
);
4960 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
4961 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4964 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4965 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4966 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4967 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4968 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4970 DestroyWindow(hwnd
);
4972 /* ansi class: window proc */
4973 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
4974 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4977 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4978 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4979 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4980 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4981 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4983 DestroyWindow(hwnd
);
4985 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
4986 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4989 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4990 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4991 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4992 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4993 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4995 DestroyWindow(hwnd
);
4997 /* unicode class: class proc */
4998 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
4999 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5002 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5003 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5004 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5005 /* do not restore class window proc back to unicode */
5007 DestroyWindow(hwnd
);
5009 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
5010 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5013 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5014 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5015 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5017 DestroyWindow(hwnd
);
5019 /* ansi class: class proc */
5020 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
5021 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5024 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5025 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
5026 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
5027 /* do not restore class window proc back to ansi */
5029 DestroyWindow(hwnd
);
5031 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
5032 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
5035 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5036 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
5037 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
5039 DestroyWindow(hwnd
);
5042 static LRESULT CALLBACK
minmax_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
5046 if (msg
!= WM_GETMINMAXINFO
)
5047 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5049 minmax
= (MINMAXINFO
*)lp
;
5051 if ((GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
5053 minmax
->ptReserved
.x
= 0;
5054 minmax
->ptReserved
.y
= 0;
5055 minmax
->ptMaxSize
.x
= 400;
5056 minmax
->ptMaxSize
.y
= 400;
5057 minmax
->ptMaxPosition
.x
= 300;
5058 minmax
->ptMaxPosition
.y
= 300;
5059 minmax
->ptMaxTrackSize
.x
= 200;
5060 minmax
->ptMaxTrackSize
.y
= 200;
5061 minmax
->ptMinTrackSize
.x
= 100;
5062 minmax
->ptMinTrackSize
.y
= 100;
5065 DefWindowProcA(hwnd
, msg
, wp
, lp
);
5069 static int expected_cx
, expected_cy
;
5070 static RECT expected_rect
, broken_rect
;
5072 static LRESULT CALLBACK
winsizes_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
5076 case WM_GETMINMAXINFO
:
5079 GetWindowRect( hwnd
, &rect
);
5080 ok( !rect
.left
&& !rect
.top
&& !rect
.right
&& !rect
.bottom
,
5081 "wrong rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5082 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5087 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
5089 GetWindowRect( hwnd
, &rect
);
5090 trace( "hwnd %p msg %x size %dx%d rect %d,%d-%d,%d\n",
5091 hwnd
, msg
, cs
->cx
, cs
->cy
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5092 ok( cs
->cx
== expected_cx
|| broken(cs
->cx
== (short)expected_cx
),
5093 "wrong x size %d/%d\n", cs
->cx
, expected_cx
);
5094 ok( cs
->cy
== expected_cy
|| broken(cs
->cy
== (short)expected_cy
),
5095 "wrong y size %d/%d\n", cs
->cy
, expected_cy
);
5096 ok( (rect
.right
- rect
.left
== expected_rect
.right
- expected_rect
.left
&&
5097 rect
.bottom
- rect
.top
== expected_rect
.bottom
- expected_rect
.top
) ||
5098 (rect
.right
- rect
.left
== min( 65535, expected_rect
.right
- expected_rect
.left
) &&
5099 rect
.bottom
- rect
.top
== min( 65535, expected_rect
.bottom
- expected_rect
.top
)) ||
5100 broken( rect
.right
- rect
.left
== broken_rect
.right
- broken_rect
.left
&&
5101 rect
.bottom
- rect
.top
== broken_rect
.bottom
- broken_rect
.top
) ||
5102 broken( rect
.right
- rect
.left
== (short)broken_rect
.right
- (short)broken_rect
.left
&&
5103 rect
.bottom
- rect
.top
== (short)broken_rect
.bottom
- (short)broken_rect
.top
),
5104 "wrong rect %d,%d-%d,%d / %d,%d-%d,%d\n",
5105 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
5106 expected_rect
.left
, expected_rect
.top
, expected_rect
.right
, expected_rect
.bottom
);
5107 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5111 RECT rect
, *r
= (RECT
*)lp
;
5112 GetWindowRect( hwnd
, &rect
);
5113 ok( !memcmp( &rect
, r
, sizeof(rect
) ),
5114 "passed rect %d,%d-%d,%d doesn't match window rect %d,%d-%d,%d\n",
5115 r
->left
, r
->top
, r
->right
, r
->bottom
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5116 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5119 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5123 static void test_CreateWindow(void)
5132 #define expect_menu(window, menu) \
5133 SetLastError(0xdeadbeef); \
5134 res = (GetMenu(window) == (HMENU)menu); \
5135 ok(res, "GetMenu error %d\n", GetLastError())
5137 #define expect_style(window, style)\
5138 ok((ULONG)GetWindowLongA(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLongA(window, GWL_STYLE))
5140 #define expect_ex_style(window, ex_style)\
5141 ok((ULONG)GetWindowLongA(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLongA(window, GWL_EXSTYLE))
5143 #define expect_gle_broken_9x(gle)\
5144 ok(GetLastError() == gle ||\
5145 broken(GetLastError() == 0xdeadbeef),\
5146 "IsMenu set error %d\n", GetLastError())
5148 hmenu
= CreateMenu();
5150 parent
= GetDesktopWindow();
5151 assert(parent
!= 0);
5153 SetLastError(0xdeadbeef);
5154 res
= IsMenu(hmenu
);
5155 ok(res
, "IsMenu error %d\n", GetLastError());
5158 SetLastError(0xdeadbeef);
5159 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
,
5160 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5161 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5162 expect_menu(hwnd
, 1);
5163 expect_style(hwnd
, WS_CHILD
);
5164 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5165 DestroyWindow(hwnd
);
5167 SetLastError(0xdeadbeef);
5168 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_CAPTION
,
5169 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5170 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5171 expect_menu(hwnd
, 1);
5172 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
5173 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5174 DestroyWindow(hwnd
);
5176 SetLastError(0xdeadbeef);
5177 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
5178 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5179 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5180 expect_menu(hwnd
, 1);
5181 expect_style(hwnd
, WS_CHILD
);
5182 expect_ex_style(hwnd
, 0);
5183 DestroyWindow(hwnd
);
5185 SetLastError(0xdeadbeef);
5186 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_CAPTION
,
5187 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5188 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5189 expect_menu(hwnd
, 1);
5190 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
5191 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5192 DestroyWindow(hwnd
);
5195 SetLastError(0xdeadbeef);
5196 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5197 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5198 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5199 expect_menu(hwnd
, hmenu
);
5200 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
5201 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5202 DestroyWindow(hwnd
);
5203 SetLastError(0xdeadbeef);
5204 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5205 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5207 hmenu
= CreateMenu();
5209 SetLastError(0xdeadbeef);
5210 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
| WS_CAPTION
,
5211 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5212 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5213 expect_menu(hwnd
, hmenu
);
5214 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5215 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5216 DestroyWindow(hwnd
);
5217 SetLastError(0xdeadbeef);
5218 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5219 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5221 hmenu
= CreateMenu();
5223 SetLastError(0xdeadbeef);
5224 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
5225 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5226 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5227 expect_menu(hwnd
, hmenu
);
5228 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
5229 expect_ex_style(hwnd
, 0);
5230 DestroyWindow(hwnd
);
5231 SetLastError(0xdeadbeef);
5232 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5233 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5235 hmenu
= CreateMenu();
5237 SetLastError(0xdeadbeef);
5238 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
| WS_CAPTION
,
5239 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5240 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5241 expect_menu(hwnd
, hmenu
);
5242 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5243 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5244 DestroyWindow(hwnd
);
5245 SetLastError(0xdeadbeef);
5246 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5247 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5249 /* WS_CHILD | WS_POPUP */
5250 SetLastError(0xdeadbeef);
5251 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5252 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5253 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5254 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5256 DestroyWindow(hwnd
);
5258 hmenu
= CreateMenu();
5260 SetLastError(0xdeadbeef);
5261 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5262 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5263 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5264 expect_menu(hwnd
, hmenu
);
5265 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
5266 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5267 DestroyWindow(hwnd
);
5268 SetLastError(0xdeadbeef);
5269 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5270 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5272 SetLastError(0xdeadbeef);
5273 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5274 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5275 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5276 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5278 DestroyWindow(hwnd
);
5280 hmenu
= CreateMenu();
5282 SetLastError(0xdeadbeef);
5283 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5284 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5285 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5286 expect_menu(hwnd
, hmenu
);
5287 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5288 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5289 DestroyWindow(hwnd
);
5290 SetLastError(0xdeadbeef);
5291 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5292 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5294 SetLastError(0xdeadbeef);
5295 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
5296 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5297 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5298 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5300 DestroyWindow(hwnd
);
5302 hmenu
= CreateMenu();
5304 SetLastError(0xdeadbeef);
5305 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
5306 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5307 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5308 expect_menu(hwnd
, hmenu
);
5309 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
5310 expect_ex_style(hwnd
, 0);
5311 DestroyWindow(hwnd
);
5312 SetLastError(0xdeadbeef);
5313 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5314 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5316 SetLastError(0xdeadbeef);
5317 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5318 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5319 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5320 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5322 DestroyWindow(hwnd
);
5324 hmenu
= CreateMenu();
5326 SetLastError(0xdeadbeef);
5327 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5328 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5329 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5330 expect_menu(hwnd
, hmenu
);
5331 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5332 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5333 DestroyWindow(hwnd
);
5334 SetLastError(0xdeadbeef);
5335 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5336 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5338 /* test child window sizing */
5340 cls
.lpfnWndProc
= minmax_wnd_proc
;
5343 cls
.hInstance
= GetModuleHandleA(NULL
);
5345 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5346 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5347 cls
.lpszMenuName
= NULL
;
5348 cls
.lpszClassName
= "MinMax_WndClass";
5349 RegisterClassA(&cls
);
5351 SetLastError(0xdeadbeef);
5352 parent
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
5353 0, 0, 100, 100, 0, 0, 0, NULL
);
5354 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
5355 expect_menu(parent
, 0);
5356 expect_style(parent
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
| WS_CLIPSIBLINGS
);
5357 expect_ex_style(parent
, WS_EX_WINDOWEDGE
);
5359 memset(&minmax
, 0, sizeof(minmax
));
5360 SendMessageA(parent
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
5361 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxSize
.x
, minmax
.ptMaxSize
.y
);
5362 ok(IsRectEmpty(&rc_minmax
), "ptMaxSize is not empty\n");
5363 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
5364 ok(IsRectEmpty(&rc_minmax
), "ptMaxTrackSize is not empty\n");
5366 GetWindowRect(parent
, &rc
);
5367 ok(!IsRectEmpty(&rc
), "parent window rect is empty\n");
5368 GetClientRect(parent
, &rc
);
5369 ok(!IsRectEmpty(&rc
), "parent client rect is empty\n");
5371 InflateRect(&rc
, 200, 200);
5372 trace("creating child with rect (%d,%d-%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5374 SetLastError(0xdeadbeef);
5375 hwnd
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
5376 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
5377 parent
, (HMENU
)1, 0, NULL
);
5378 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5379 expect_menu(hwnd
, 1);
5380 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
);
5381 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5383 memset(&minmax
, 0, sizeof(minmax
));
5384 SendMessageA(hwnd
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
5385 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
5387 GetWindowRect(hwnd
, &rc
);
5388 OffsetRect(&rc
, -rc
.left
, -rc
.top
);
5389 ok(EqualRect(&rc
, &rc_minmax
), "rects don't match: (%d,%d-%d,%d) and (%d,%d-%d,%d)\n",
5390 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
5391 rc_minmax
.left
, rc_minmax
.top
, rc_minmax
.right
, rc_minmax
.bottom
);
5392 DestroyWindow(hwnd
);
5394 cls
.lpfnWndProc
= winsizes_wnd_proc
;
5395 cls
.lpszClassName
= "Sizes_WndClass";
5396 RegisterClassA(&cls
);
5398 expected_cx
= expected_cy
= 200000;
5399 SetRect( &expected_rect
, 0, 0, 200000, 200000 );
5400 broken_rect
= expected_rect
;
5401 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 300000, 300000, 200000, 200000, parent
, 0, 0, NULL
);
5402 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5403 GetClientRect( hwnd
, &rc
);
5404 ok( rc
.right
== 200000 || rc
.right
== 65535 || broken(rc
.right
== (short)200000),
5405 "invalid rect right %u\n", rc
.right
);
5406 ok( rc
.bottom
== 200000 || rc
.bottom
== 65535 || broken(rc
.bottom
== (short)200000),
5407 "invalid rect bottom %u\n", rc
.bottom
);
5408 DestroyWindow(hwnd
);
5410 expected_cx
= expected_cy
= -10;
5411 SetRect( &expected_rect
, 0, 0, 0, 0 );
5412 SetRect( &broken_rect
, 0, 0, -10, -10 );
5413 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -20, -20, -10, -10, parent
, 0, 0, NULL
);
5414 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5415 GetClientRect( hwnd
, &rc
);
5416 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
5417 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
5418 DestroyWindow(hwnd
);
5420 expected_cx
= expected_cy
= -200000;
5421 SetRect( &expected_rect
, 0, 0, 0, 0 );
5422 SetRect( &broken_rect
, 0, 0, -200000, -200000 );
5423 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -300000, -300000, -200000, -200000, parent
, 0, 0, NULL
);
5424 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5425 GetClientRect( hwnd
, &rc
);
5426 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
5427 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
5428 DestroyWindow(hwnd
);
5430 /* we need a parent at 0,0 so that child coordinates match */
5431 DestroyWindow(parent
);
5432 parent
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_POPUP
, 0, 0, 100, 100, 0, 0, 0, NULL
);
5433 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
5436 expected_cy
= 0x7fffffff;
5437 SetRect( &expected_rect
, 10, 10, 110, 0x7fffffff );
5438 SetRect( &broken_rect
, 10, 10, 110, 0x7fffffffU
+ 10 );
5439 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 10, 10, 100, 0x7fffffff, parent
, 0, 0, NULL
);
5440 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5441 GetClientRect( hwnd
, &rc
);
5442 ok( rc
.right
== 100, "invalid rect right %u\n", rc
.right
);
5443 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.bottom
==65535 || broken(rc
.bottom
== 0),
5444 "invalid rect bottom %u\n", rc
.bottom
);
5445 DestroyWindow(hwnd
);
5447 expected_cx
= 0x7fffffff;
5448 expected_cy
= 0x7fffffff;
5449 SetRect( &expected_rect
, 20, 10, 0x7fffffff, 0x7fffffff );
5450 SetRect( &broken_rect
, 20, 10, 0x7fffffffU
+ 20, 0x7fffffffU
+ 10 );
5451 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 20, 10, 0x7fffffff, 0x7fffffff, parent
, 0, 0, NULL
);
5452 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5453 GetClientRect( hwnd
, &rc
);
5454 ok( rc
.right
== 0x7fffffff - 20 || rc
.right
== 65535 || broken(rc
.right
== 0),
5455 "invalid rect right %u\n", rc
.right
);
5456 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.right
== 65535 || broken(rc
.bottom
== 0),
5457 "invalid rect bottom %u\n", rc
.bottom
);
5458 DestroyWindow(hwnd
);
5460 /* top level window */
5461 expected_cx
= expected_cy
= 200000;
5462 SetRect( &expected_rect
, 0, 0, GetSystemMetrics(SM_CXMAXTRACK
), GetSystemMetrics(SM_CYMAXTRACK
) );
5463 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_OVERLAPPEDWINDOW
, 300000, 300000, 200000, 200000, 0, 0, 0, NULL
);
5464 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5465 GetClientRect( hwnd
, &rc
);
5466 ok( rc
.right
<= expected_cx
, "invalid rect right %u\n", rc
.right
);
5467 ok( rc
.bottom
<= expected_cy
, "invalid rect bottom %u\n", rc
.bottom
);
5468 DestroyWindow(hwnd
);
5470 if (pGetLayout
&& pSetLayout
)
5472 HDC hdc
= GetDC( parent
);
5473 pSetLayout( hdc
, LAYOUT_RTL
);
5474 if (pGetLayout( hdc
))
5476 ReleaseDC( parent
, hdc
);
5477 DestroyWindow( parent
);
5478 SetLastError( 0xdeadbeef );
5479 parent
= CreateWindowExA(WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
,
5480 0, 0, 100, 100, 0, 0, 0, NULL
);
5481 ok( parent
!= 0, "creation failed err %u\n", GetLastError());
5482 expect_ex_style( parent
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
5483 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5484 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5485 expect_ex_style( hwnd
, WS_EX_LAYOUTRTL
);
5486 DestroyWindow( hwnd
);
5487 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5488 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5489 expect_ex_style( hwnd
, 0 );
5490 DestroyWindow( hwnd
);
5491 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
| WS_EX_NOINHERITLAYOUT
);
5492 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5493 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5494 expect_ex_style( hwnd
, 0 );
5495 DestroyWindow( hwnd
);
5497 if (pGetProcessDefaultLayout
&& pSetProcessDefaultLayout
)
5501 SetLastError( 0xdeadbeef );
5502 ok( !pGetProcessDefaultLayout( NULL
), "GetProcessDefaultLayout succeeded\n" );
5503 ok( GetLastError() == ERROR_NOACCESS
, "wrong error %u\n", GetLastError() );
5504 SetLastError( 0xdeadbeef );
5505 res
= pGetProcessDefaultLayout( &layout
);
5506 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5507 ok( layout
== 0, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5508 SetLastError( 0xdeadbeef );
5509 res
= pSetProcessDefaultLayout( 7 );
5510 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
5511 res
= pGetProcessDefaultLayout( &layout
);
5512 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5513 ok( layout
== 7, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5514 SetLastError( 0xdeadbeef );
5515 res
= pSetProcessDefaultLayout( LAYOUT_RTL
);
5516 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
5517 res
= pGetProcessDefaultLayout( &layout
);
5518 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5519 ok( layout
== LAYOUT_RTL
, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5520 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5521 0, 0, 100, 100, 0, 0, 0, NULL
);
5522 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5523 expect_ex_style( hwnd
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
5524 DestroyWindow( hwnd
);
5525 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5526 0, 0, 100, 100, parent
, 0, 0, NULL
);
5527 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5528 expect_ex_style( hwnd
, WS_EX_APPWINDOW
);
5529 DestroyWindow( hwnd
);
5530 pSetProcessDefaultLayout( 0 );
5532 else win_skip( "SetProcessDefaultLayout not supported\n" );
5534 else win_skip( "SetLayout not supported\n" );
5536 else win_skip( "SetLayout not available\n" );
5538 DestroyWindow(parent
);
5540 UnregisterClassA("MinMax_WndClass", GetModuleHandleA(NULL
));
5541 UnregisterClassA("Sizes_WndClass", GetModuleHandleA(NULL
));
5543 #undef expect_gle_broken_9x
5546 #undef expect_ex_style
5549 /* function that remembers whether the system the test is running on sets the
5550 * last error for user32 functions to make the tests stricter */
5551 static int check_error(DWORD actual
, DWORD expected
)
5553 static int sets_last_error
= -1;
5554 if (sets_last_error
== -1)
5555 sets_last_error
= (actual
!= 0xdeadbeef);
5556 return (!sets_last_error
&& (actual
== 0xdeadbeef)) || (actual
== expected
);
5559 static void test_SetWindowLong(void)
5562 WNDPROC old_window_procW
;
5564 SetLastError(0xdeadbeef);
5565 retval
= SetWindowLongPtrA(NULL
, GWLP_WNDPROC
, 0);
5566 ok(!retval
, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval
);
5567 ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE
),
5568 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instead of %d\n", GetLastError());
5570 SetLastError(0xdeadbeef);
5571 retval
= SetWindowLongPtrA(hwndMain
, 0xdeadbeef, 0);
5572 ok(!retval
, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval
);
5573 ok(check_error(GetLastError(), ERROR_INVALID_INDEX
),
5574 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instead of %d\n", GetLastError());
5576 SetLastError(0xdeadbeef);
5577 retval
= SetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
, 0);
5578 ok((WNDPROC
)retval
== main_window_procA
|| broken(!retval
), /* win9x */
5579 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval
);
5580 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
5581 retval
= GetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
);
5582 ok((WNDPROC
)retval
== main_window_procA
,
5583 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
5584 ok(!IsWindowUnicode(hwndMain
), "hwndMain shouldn't be Unicode\n");
5586 old_window_procW
= (WNDPROC
)GetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
);
5587 SetLastError(0xdeadbeef);
5588 retval
= SetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
, 0);
5589 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED
)
5591 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
5592 ok(retval
!= 0, "SetWindowLongPtr error %d\n", GetLastError());
5593 ok((WNDPROC
)retval
== old_window_procW
,
5594 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
5595 ok(IsWindowUnicode(hwndMain
), "hwndMain should now be Unicode\n");
5597 /* set it back to ANSI */
5598 SetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
, 0);
5602 static void test_ShowWindow(void)
5606 RECT rcMain
, rc
, rcMinimized
;
5609 SetRect(&rcMain
, 120, 120, 210, 210);
5611 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
5612 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
5613 WS_MAXIMIZEBOX
| WS_POPUP
,
5614 rcMain
.left
, rcMain
.top
,
5615 rcMain
.right
- rcMain
.left
, rcMain
.bottom
- rcMain
.top
,
5619 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5620 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5621 ok(!(style
& WS_VISIBLE
), "window should not be visible\n");
5622 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5623 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5624 GetWindowRect(hwnd
, &rc
);
5625 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5626 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5627 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5629 ret
= ShowWindow(hwnd
, SW_SHOW
);
5630 ok(!ret
, "not expected ret: %lu\n", ret
);
5631 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5632 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5633 ok(style
& WS_VISIBLE
, "window should be visible\n");
5634 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5635 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5636 GetWindowRect(hwnd
, &rc
);
5637 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5638 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5639 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5641 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
5642 ok(ret
, "not expected ret: %lu\n", ret
);
5643 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5644 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5645 ok(style
& WS_VISIBLE
, "window should be visible\n");
5646 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5647 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5648 GetWindowRect(hwnd
, &rcMinimized
);
5649 ok(!EqualRect(&rcMain
, &rcMinimized
), "rects shouldn't match\n");
5650 /* shouldn't be able to resize minimized windows */
5651 ret
= SetWindowPos(hwnd
, 0, 0, 0,
5652 (rcMinimized
.right
- rcMinimized
.left
) * 2,
5653 (rcMinimized
.bottom
- rcMinimized
.top
) * 2,
5654 SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
5655 ok(ret
, "not expected ret: %lu\n", ret
);
5656 GetWindowRect(hwnd
, &rc
);
5657 ok(EqualRect(&rc
, &rcMinimized
), "rects should match\n");
5659 ShowWindow(hwnd
, SW_RESTORE
);
5660 ok(ret
, "not expected ret: %lu\n", ret
);
5661 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5662 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5663 ok(style
& WS_VISIBLE
, "window should be visible\n");
5664 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5665 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5666 GetWindowRect(hwnd
, &rc
);
5667 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5668 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5669 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5671 ret
= EnableWindow(hwnd
, FALSE
);
5672 ok(!ret
, "not expected ret: %lu\n", ret
);
5673 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5674 ok(style
& WS_DISABLED
, "window should be disabled\n");
5676 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
5677 ok(!ret
, "not expected ret: %lu\n", ret
);
5678 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5679 ok(style
& WS_DISABLED
, "window should be disabled\n");
5680 ok(style
& WS_VISIBLE
, "window should be visible\n");
5681 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5682 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5683 GetWindowRect(hwnd
, &rc
);
5684 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5685 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5686 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5688 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_MAXIMIZE
, 0);
5689 ok(!ret
, "not expected ret: %lu\n", ret
);
5690 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5691 ok(style
& WS_DISABLED
, "window should be disabled\n");
5692 ok(style
& WS_VISIBLE
, "window should be visible\n");
5693 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5694 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5695 GetWindowRect(hwnd
, &rc
);
5696 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5697 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5698 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5700 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
5701 ok(ret
, "not expected ret: %lu\n", ret
);
5702 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5703 ok(style
& WS_DISABLED
, "window should be disabled\n");
5704 ok(style
& WS_VISIBLE
, "window should be visible\n");
5705 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5706 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5707 GetWindowRect(hwnd
, &rc
);
5708 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
5710 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0);
5711 ok(!ret
, "not expected ret: %lu\n", ret
);
5712 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5713 ok(style
& WS_DISABLED
, "window should be disabled\n");
5714 ok(style
& WS_VISIBLE
, "window should be visible\n");
5715 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5716 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5717 GetWindowRect(hwnd
, &rc
);
5718 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
5720 ret
= ShowWindow(hwnd
, SW_RESTORE
);
5721 ok(ret
, "not expected ret: %lu\n", ret
);
5722 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5723 ok(style
& WS_DISABLED
, "window should be disabled\n");
5724 ok(style
& WS_VISIBLE
, "window should be visible\n");
5725 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5726 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5727 GetWindowRect(hwnd
, &rc
);
5728 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5729 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5730 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5732 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
5733 ok(!ret
, "not expected ret: %lu\n", ret
);
5734 ok(IsWindow(hwnd
), "window should exist\n");
5736 ret
= EnableWindow(hwnd
, TRUE
);
5737 ok(ret
, "not expected ret: %lu\n", ret
);
5739 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
5740 ok(!ret
, "not expected ret: %lu\n", ret
);
5741 ok(!IsWindow(hwnd
), "window should not exist\n");
5744 static DWORD CALLBACK
gettext_msg_thread( LPVOID arg
)
5750 /* test GetWindowTextA */
5751 num_gettext_msgs
= 0;
5752 memset( buf
, 0, sizeof(buf
) );
5753 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
5754 ok( buf_len
!= 0, "expected a nonempty window text\n" );
5755 ok( !strcmp(buf
, "another_caption"), "got wrong window text '%s'\n", buf
);
5756 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5761 static DWORD CALLBACK
settext_msg_thread( LPVOID arg
)
5766 /* test SetWindowTextA */
5767 num_settext_msgs
= 0;
5768 success
= SetWindowTextA( hwnd
, "thread_caption" );
5769 ok( success
, "SetWindowTextA failed\n" );
5770 ok( num_settext_msgs
== 1, "got %u WM_SETTEXT messages\n", num_settext_msgs
);
5775 static void test_gettext(void)
5777 DWORD tid
, num_msgs
;
5787 hwnd
= CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP
, 0, 0, 0, 0, 0, 0, 0, NULL
);
5788 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
5790 /* test GetWindowTextA */
5791 num_gettext_msgs
= 0;
5792 memset( buf
, 0, sizeof(buf
) );
5793 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
5794 ok( buf_len
!= 0, "expected a nonempty window text\n" );
5795 ok( !strcmp(buf
, "caption"), "got wrong window text '%s'\n", buf
);
5796 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5798 /* other process window */
5800 buf_len
= GetWindowTextA( GetDesktopWindow(), buf
, sizeof(buf
) );
5801 ok( buf_len
== 0, "expected a nonempty window text\n" );
5802 ok( *buf
== 0, "got wrong window text '%s'\n", buf
);
5804 strcpy( buf
, "blah" );
5805 buf_len
= GetWindowTextA( GetDesktopWindow(), buf
, 0 );
5806 ok( buf_len
== 0, "expected a nonempty window text\n" );
5807 ok( !strcmp(buf
, "blah"), "got wrong window text '%s'\n", buf
);
5810 buf_len
= GetWindowTextW( GetDesktopWindow(), bufW
, 0 );
5811 ok( buf_len
== 0, "expected a nonempty window text\n" );
5812 ok( bufW
[0] == 0xcc, "got %x\n", bufW
[0] );
5814 g_wm_gettext_override
.enabled
= TRUE
;
5816 num_gettext_msgs
= 0;
5817 memset( buf
, 0xcc, sizeof(buf
) );
5818 g_wm_gettext_override
.buff
= buf
;
5819 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
5820 ok( buf_len
== 0, "got %d\n", buf_len
);
5821 ok( *buf
== 0, "got %x\n", *buf
);
5822 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5824 num_gettext_msgs
= 0;
5825 strcpy( buf
, "blah" );
5826 g_wm_gettext_override
.buff
= buf
;
5827 buf_len
= GetWindowTextA( hwnd
, buf
, 0 );
5828 ok( buf_len
== 0, "got %d\n", buf_len
);
5829 ok( !strcmp(buf
, "blah"), "got %s\n", buf
);
5830 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5832 g_wm_gettext_override
.enabled
= FALSE
;
5834 /* same for W window */
5835 hwnd2
= CreateWindowExW( 0, mainclassW
, NULL
, WS_POPUP
, 0, 0, 0, 0, 0, 0, 0, NULL
);
5836 ok( hwnd2
!= 0, "CreateWindowExA error %d\n", GetLastError() );
5838 g_wm_gettext_override
.enabled
= TRUE
;
5840 num_gettext_msgs
= 0;
5841 memset( bufW
, 0xcc, sizeof(bufW
) );
5842 g_wm_gettext_override
.buffW
= bufW
;
5843 buf_len
= GetWindowTextW( hwnd2
, bufW
, sizeof(bufW
)/sizeof(WCHAR
) );
5844 ok( buf_len
== 0, "got %d\n", buf_len
);
5845 ok( *bufW
== 0, "got %x\n", *bufW
);
5846 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5848 num_gettext_msgs
= 0;
5849 memset( bufW
, 0xcc, sizeof(bufW
) );
5850 g_wm_gettext_override
.buffW
= bufW
;
5851 buf_len
= GetWindowTextW( hwnd2
, bufW
, 0 );
5852 ok( buf_len
== 0, "got %d\n", buf_len
);
5853 ok( *bufW
== 0xcccc, "got %x\n", *bufW
);
5854 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5856 g_wm_gettext_override
.enabled
= FALSE
;
5858 DestroyWindow( hwnd2
);
5860 /* test WM_GETTEXT */
5861 num_gettext_msgs
= 0;
5862 memset( buf
, 0, sizeof(buf
) );
5863 r
= SendMessageA( hwnd
, WM_GETTEXT
, sizeof(buf
), (LONG_PTR
)buf
);
5864 ok( r
!= 0, "expected a nonempty window text\n" );
5865 ok( !strcmp(buf
, "caption"), "got wrong window text '%s'\n", buf
);
5866 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5868 /* test SetWindowTextA */
5869 num_settext_msgs
= 0;
5870 success
= SetWindowTextA( hwnd
, "new_caption" );
5871 ok( success
, "SetWindowTextA failed\n" );
5872 ok( num_settext_msgs
== 1, "got %u WM_SETTEXT messages\n", num_settext_msgs
);
5874 num_gettext_msgs
= 0;
5875 memset( buf
, 0, sizeof(buf
) );
5876 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
5877 ok( buf_len
!= 0, "expected a nonempty window text\n" );
5878 ok( !strcmp(buf
, "new_caption"), "got wrong window text '%s'\n", buf
);
5879 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5881 /* test WM_SETTEXT */
5882 num_settext_msgs
= 0;
5883 r
= SendMessageA( hwnd
, WM_SETTEXT
, 0, (ULONG_PTR
)"another_caption" );
5884 ok( r
!= 0, "WM_SETTEXT failed\n" );
5885 ok( num_settext_msgs
== 1, "got %u WM_SETTEXT messages\n", num_settext_msgs
);
5887 num_gettext_msgs
= 0;
5888 memset( buf
, 0, sizeof(buf
) );
5889 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
5890 ok( buf_len
!= 0, "expected a nonempty window text\n" );
5891 ok( !strcmp(buf
, "another_caption"), "got wrong window text '%s'\n", buf
);
5892 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5894 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
))
5895 DispatchMessageA( &msg
);
5897 /* test interthread GetWindowTextA */
5899 thread
= CreateThread( NULL
, 0, gettext_msg_thread
, hwnd
, 0, &tid
);
5900 ok(thread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
5901 while (MsgWaitForMultipleObjects( 1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
5903 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
))
5904 DispatchMessageA( &msg
);
5907 CloseHandle( thread
);
5908 ok( num_msgs
>= 1, "got %u wakeups from MsgWaitForMultipleObjects\n", num_msgs
);
5910 /* test interthread SetWindowText */
5912 thread
= CreateThread( NULL
, 0, settext_msg_thread
, hwnd
, 0, &tid
);
5913 ok(thread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
5914 while (MsgWaitForMultipleObjects( 1, &thread
, FALSE
, INFINITE
, QS_SENDMESSAGE
) != WAIT_OBJECT_0
)
5916 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
| PM_QS_SENDMESSAGE
))
5917 DispatchMessageA( &msg
);
5920 CloseHandle( thread
);
5921 ok( num_msgs
>= 1, "got %u wakeups from MsgWaitForMultipleObjects\n", num_msgs
);
5923 num_gettext_msgs
= 0;
5924 memset( buf
, 0, sizeof(buf
) );
5925 buf_len
= GetWindowTextA( hwnd
, buf
, sizeof(buf
) );
5926 ok( buf_len
!= 0, "expected a nonempty window text\n" );
5927 ok( !strcmp(buf
, "thread_caption"), "got wrong window text '%s'\n", buf
);
5928 ok( num_gettext_msgs
== 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
5930 /* seems to crash on every modern Windows version */
5933 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x10, 0x1000);
5934 ok( r
== 0, "settext should return zero\n");
5936 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x10000, 0);
5937 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5939 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0xff000000, 0x1000);
5940 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5942 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x1000, 0xff000000);
5943 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5946 DestroyWindow(hwnd
);
5950 static void test_GetUpdateRect(void)
5953 BOOL ret
, parent_wm_paint
, grandparent_wm_paint
;
5955 HWND hgrandparent
, hparent
, hchild
;
5957 static const char classNameA
[] = "GetUpdateRectClass";
5959 hgrandparent
= CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW
,
5960 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
5962 hparent
= CreateWindowA("static", "parent", WS_CHILD
|WS_VISIBLE
,
5963 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
5965 hchild
= CreateWindowA("static", "child", WS_CHILD
|WS_VISIBLE
,
5966 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
5968 ShowWindow(hgrandparent
, SW_SHOW
);
5969 UpdateWindow(hgrandparent
);
5970 flush_events( TRUE
);
5972 ShowWindow(hchild
, SW_HIDE
);
5973 SetRect(&rc2
, 0, 0, 0, 0);
5974 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
5975 ok(!ret
, "GetUpdateRect returned not empty region\n");
5976 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5977 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5978 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5980 SetRect(&rc2
, 10, 10, 40, 40);
5981 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
5982 ok(ret
, "GetUpdateRect returned empty region\n");
5983 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5984 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5985 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5987 parent_wm_paint
= FALSE
;
5988 grandparent_wm_paint
= FALSE
;
5989 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
5991 if (msg
.message
== WM_PAINT
)
5993 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
5994 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
5996 DispatchMessageA(&msg
);
5998 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
5999 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
6001 DestroyWindow(hgrandparent
);
6004 cls
.lpfnWndProc
= DefWindowProcA
;
6007 cls
.hInstance
= GetModuleHandleA(0);
6009 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6010 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6011 cls
.lpszMenuName
= NULL
;
6012 cls
.lpszClassName
= classNameA
;
6014 if(!RegisterClassA(&cls
)) {
6015 trace("Register failed %d\n", GetLastError());
6019 hgrandparent
= CreateWindowA(classNameA
, "grandparent", WS_OVERLAPPEDWINDOW
,
6020 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
6022 hparent
= CreateWindowA(classNameA
, "parent", WS_CHILD
|WS_VISIBLE
,
6023 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
6025 hchild
= CreateWindowA(classNameA
, "child", WS_CHILD
|WS_VISIBLE
,
6026 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
6028 ShowWindow(hgrandparent
, SW_SHOW
);
6029 UpdateWindow(hgrandparent
);
6030 flush_events( TRUE
);
6032 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
6033 ok(!ret
, "GetUpdateRect returned not empty region\n");
6035 ShowWindow(hchild
, SW_HIDE
);
6037 SetRect(&rc2
, 0, 0, 0, 0);
6038 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
6039 ok(!ret
, "GetUpdateRect returned not empty region\n");
6040 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
6041 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
6042 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
6044 SetRect(&rc2
, 10, 10, 40, 40);
6045 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
6046 ok(ret
, "GetUpdateRect returned empty region\n");
6047 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
6048 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
6049 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
6051 parent_wm_paint
= FALSE
;
6052 grandparent_wm_paint
= FALSE
;
6053 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
6055 if (msg
.message
== WM_PAINT
)
6057 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
6058 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
6060 DispatchMessageA(&msg
);
6062 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
6063 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
6065 DestroyWindow(hgrandparent
);
6069 static LRESULT CALLBACK
TestExposedRegion_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
6077 const int waitTime
= 2000;
6079 BeginPaint(hwnd
, &ps
);
6081 /* create and destroy window to create an exposed region on this window */
6082 win
= CreateWindowA("static", "win", WS_VISIBLE
,
6083 10,10,50,50, NULL
, NULL
, 0, NULL
);
6086 waitResult
= MsgWaitForMultipleObjects( 0, NULL
, FALSE
, waitTime
, QS_PAINT
);
6088 ValidateRect(hwnd
, NULL
);
6089 EndPaint(hwnd
, &ps
);
6091 if(waitResult
!= WAIT_TIMEOUT
)
6093 GetUpdateRect(hwnd
, &updateRect
, FALSE
);
6094 ok(IsRectEmpty(&updateRect
), "Exposed rect should be empty\n");
6099 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
6102 static void test_Expose(void)
6107 memset(&cls
, 0, sizeof(WNDCLASSA
));
6108 cls
.lpfnWndProc
= TestExposedRegion_WndProc
;
6109 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6110 cls
.lpszClassName
= "TestExposeClass";
6111 RegisterClassA(&cls
);
6113 mw
= CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
6114 0, 0, 200, 100, NULL
, NULL
, 0, NULL
);
6120 static LRESULT CALLBACK
TestNCRedraw_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
6122 static UINT ncredrawflags
;
6128 ncredrawflags
= *(UINT
*) (((CREATESTRUCTA
*)lParam
)->lpCreateParams
);
6131 RedrawWindow(hwnd
, NULL
, NULL
, ncredrawflags
);
6134 BeginPaint(hwnd
, &ps
);
6135 EndPaint(hwnd
, &ps
);
6138 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
6141 static void run_NCRedrawLoop(UINT flags
)
6148 hwnd
= CreateWindowA("TestNCRedrawClass", "MainWindow",
6149 WS_OVERLAPPEDWINDOW
, 0, 0, 200, 100,
6150 NULL
, NULL
, 0, &flags
);
6151 ShowWindow(hwnd
, SW_SHOW
);
6153 flush_events( FALSE
);
6154 while (PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
))
6156 if (msg
.message
== WM_PAINT
) loopcount
++;
6157 if (loopcount
>= 100) break;
6158 TranslateMessage(&msg
);
6159 DispatchMessageA(&msg
);
6160 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, QS_ALLINPUT
);
6162 if (flags
== (RDW_INVALIDATE
| RDW_FRAME
))
6163 todo_wine
ok(loopcount
< 100, "Detected infinite WM_PAINT loop (%x).\n", flags
);
6165 ok(loopcount
< 100, "Detected infinite WM_PAINT loop (%x).\n", flags
);
6166 DestroyWindow(hwnd
);
6169 static void test_NCRedraw(void)
6173 wndclass
.lpszClassName
= "TestNCRedrawClass";
6174 wndclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
6175 wndclass
.lpfnWndProc
= TestNCRedraw_WndProc
;
6176 wndclass
.cbClsExtra
= 0;
6177 wndclass
.cbWndExtra
= 0;
6178 wndclass
.hInstance
= 0;
6179 wndclass
.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
6180 wndclass
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6181 wndclass
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6182 wndclass
.lpszMenuName
= NULL
;
6184 RegisterClassA(&wndclass
);
6186 run_NCRedrawLoop(RDW_INVALIDATE
| RDW_FRAME
);
6187 run_NCRedrawLoop(RDW_INVALIDATE
);
6190 static void test_GetWindowModuleFileName(void)
6195 char buf1
[MAX_PATH
], buf2
[MAX_PATH
];
6197 if (!pGetWindowModuleFileNameA
)
6199 win_skip("GetWindowModuleFileNameA is not available\n");
6203 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
6206 hinst
= (HINSTANCE
)GetWindowLongPtrA(hwnd
, GWLP_HINSTANCE
);
6207 ok(hinst
== 0 || broken(hinst
== GetModuleHandleA(NULL
)), /* win9x */ "expected 0, got %p\n", hinst
);
6210 SetLastError(0xdeadbeef);
6211 ret1
= GetModuleFileNameA(hinst
, buf1
, sizeof(buf1
));
6212 ok(ret1
, "GetModuleFileName error %u\n", GetLastError());
6215 SetLastError(0xdeadbeef);
6216 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
6217 ok(ret2
|| broken(!ret2
), /* nt4 sp 3 */
6218 "GetWindowModuleFileNameA error %u\n", GetLastError());
6222 ok(ret1
== ret2
|| broken(ret2
== ret1
+ 1), /* win98 */ "%u != %u\n", ret1
, ret2
);
6223 ok(!strcmp(buf1
, buf2
), "%s != %s\n", buf1
, buf2
);
6225 hinst
= GetModuleHandleA(NULL
);
6227 SetLastError(0xdeadbeef);
6228 ret2
= GetModuleFileNameA(hinst
, buf2
, ret1
- 2);
6229 ok(ret2
== ret1
- 2 || broken(ret2
== ret1
- 3), /* win98 */
6230 "expected %u, got %u\n", ret1
- 2, ret2
);
6231 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6232 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6233 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6235 SetLastError(0xdeadbeef);
6236 ret2
= GetModuleFileNameA(hinst
, buf2
, 0);
6237 ok(!ret2
, "GetModuleFileName should return 0\n");
6238 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6239 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6240 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6242 SetLastError(0xdeadbeef);
6243 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, ret1
- 2);
6244 ok(ret2
== ret1
- 2 || broken(ret2
== ret1
- 3) /* win98 */ || broken(!ret2
), /* nt4 sp3 */
6245 "expected %u, got %u\n", ret1
- 2, ret2
);
6246 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6247 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6248 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6250 SetLastError(0xdeadbeef);
6251 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, 0);
6252 ok(!ret2
, "expected 0, got %u\n", ret2
);
6253 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6254 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6255 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6257 DestroyWindow(hwnd
);
6260 hwnd
= (HWND
)0xdeadbeef;
6261 SetLastError(0xdeadbeef);
6262 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
6263 ok(!ret1
, "expected 0, got %u\n", ret1
);
6264 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
6265 "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
6267 hwnd
= FindWindowA("Shell_TrayWnd", NULL
);
6268 ok(IsWindow(hwnd
) || broken(!hwnd
), "got invalid tray window %p\n", hwnd
);
6269 SetLastError(0xdeadbeef);
6270 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
6271 ok(!ret1
|| broken(ret1
), /* win98 */ "expected 0, got %u\n", ret1
);
6273 if (!ret1
) /* inter-process GetWindowModuleFileName works on win9x, so don't test the desktop there */
6275 ret1
= GetModuleFileNameA(0, buf1
, sizeof(buf1
));
6276 hwnd
= GetDesktopWindow();
6277 ok(IsWindow(hwnd
), "got invalid desktop window %p\n", hwnd
);
6278 SetLastError(0xdeadbeef);
6279 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
6281 ret1
== ret2
|| /* vista */
6282 broken(ret2
), /* some win98 return user.exe as file name */
6283 "expected 0 or %u, got %u %s\n", ret1
, ret2
, buf2
);
6287 static void test_hwnd_message(void)
6289 static const WCHAR mainwindowclassW
[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
6290 static const WCHAR message_windowW
[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
6292 HWND parent
= 0, hwnd
, found
;
6295 /* HWND_MESSAGE is not supported below w2k, but win9x return != 0
6296 on CreateWindowExA and crash later in the test.
6297 Use UNICODE here to fail on win9x */
6298 hwnd
= CreateWindowExW(0, mainwindowclassW
, message_windowW
, WS_CAPTION
| WS_VISIBLE
,
6299 100, 100, 200, 200, HWND_MESSAGE
, 0, 0, NULL
);
6302 win_skip("CreateWindowExW with parent HWND_MESSAGE failed\n");
6306 ok( !GetParent(hwnd
), "GetParent should return 0 for message only windows\n" );
6310 HWND root
, desktop
= GetDesktopWindow();
6312 parent
= pGetAncestor(hwnd
, GA_PARENT
);
6313 ok(parent
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
6314 ok(parent
!= desktop
, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
6315 root
= pGetAncestor(hwnd
, GA_ROOT
);
6316 ok(root
== hwnd
, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
6317 ok( !pGetAncestor(parent
, GA_PARENT
) || broken(pGetAncestor(parent
, GA_PARENT
) != 0), /* win2k */
6318 "parent shouldn't have parent %p\n", pGetAncestor(parent
, GA_PARENT
) );
6319 trace("parent %p root %p desktop %p\n", parent
, root
, desktop
);
6320 if (!GetClassNameA( parent
, buffer
, sizeof(buffer
) )) buffer
[0] = 0;
6321 ok( !lstrcmpiA( buffer
, "Message" ), "wrong parent class '%s'\n", buffer
);
6322 GetWindowRect( parent
, &rect
);
6323 ok( rect
.left
== 0 && rect
.right
== 100 && rect
.top
== 0 && rect
.bottom
== 100,
6324 "wrong parent rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6326 GetWindowRect( hwnd
, &rect
);
6327 ok( rect
.left
== 100 && rect
.right
== 300 && rect
.top
== 100 && rect
.bottom
== 300,
6328 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6330 /* test FindWindow behavior */
6332 found
= FindWindowExA( 0, 0, 0, "message window" );
6333 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
6334 SetLastError(0xdeadbeef);
6335 found
= FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
6336 ok( found
== 0, "found message window %p/%p\n", found
, hwnd
);
6337 ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %d\n", GetLastError() );
6340 found
= FindWindowExA( parent
, 0, 0, "message window" );
6341 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
6344 /* test IsChild behavior */
6346 if (parent
) ok( !IsChild( parent
, hwnd
), "HWND_MESSAGE is child of top window\n" );
6348 /* test IsWindowVisible behavior */
6350 ok( !IsWindowVisible( hwnd
), "HWND_MESSAGE window is visible\n" );
6351 if (parent
) ok( !IsWindowVisible( parent
), "HWND_MESSAGE parent is visible\n" );
6353 DestroyWindow(hwnd
);
6356 static void test_layered_window(void)
6362 POINT pt
= { 0, 0 };
6363 SIZE sz
= { 200, 200 };
6368 if (!pGetLayeredWindowAttributes
|| !pSetLayeredWindowAttributes
|| !pUpdateLayeredWindow
)
6370 win_skip( "layered windows not supported\n" );
6374 hdc
= CreateCompatibleDC( 0 );
6375 hbm
= CreateCompatibleBitmap( hdc
, 200, 200 );
6376 SelectObject( hdc
, hbm
);
6378 hwnd
= CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION
,
6379 100, 100, 200, 200, 0, 0, 0, NULL
);
6381 SetLastError( 0xdeadbeef );
6382 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6383 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
6384 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6385 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6386 ok( !ret
, "GetLayeredWindowAttributes should fail on non-layered window\n" );
6387 ret
= pSetLayeredWindowAttributes( hwnd
, 0, 0, LWA_ALPHA
);
6388 ok( !ret
, "SetLayeredWindowAttributes should fail on non-layered window\n" );
6389 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6390 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6391 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6392 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6393 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
6394 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6395 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6396 ret
= pSetLayeredWindowAttributes( hwnd
, 0x123456, 44, LWA_ALPHA
);
6397 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6398 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6399 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6400 ok( key
== 0x123456 || key
== 0, "wrong color key %x\n", key
);
6401 ok( alpha
== 44, "wrong alpha %u\n", alpha
);
6402 ok( flags
== LWA_ALPHA
, "wrong flags %x\n", flags
);
6403 SetLastError( 0xdeadbeef );
6404 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6405 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
6406 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6408 /* clearing WS_EX_LAYERED resets attributes */
6409 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
6410 SetLastError( 0xdeadbeef );
6411 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6412 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
6413 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6414 ok( !ret
, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
6415 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6416 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6417 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6418 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6419 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
6420 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
| ULW_EX_NORESIZE
);
6421 ok( !ret
, "UpdateLayeredWindow should fail with ex flag\n" );
6422 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6423 if (pUpdateLayeredWindowIndirect
)
6425 UPDATELAYEREDWINDOWINFO info
;
6426 info
.cbSize
= sizeof(info
);
6434 info
.dwFlags
= ULW_OPAQUE
| ULW_EX_NORESIZE
;
6435 info
.prcDirty
= NULL
;
6436 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6437 ok( ret
, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
6439 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6440 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6441 ok( GetLastError() == ERROR_INCORRECT_SIZE
|| broken(GetLastError() == ERROR_MR_MID_NOT_FOUND
),
6442 "wrong error %u\n", GetLastError() );
6443 info
.dwFlags
= ULW_OPAQUE
;
6444 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6445 ok( ret
, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
6447 info
.dwFlags
= ULW_OPAQUE
| 0xf00;
6448 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6449 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6450 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6452 info
.dwFlags
= ULW_OPAQUE
;
6453 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6454 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6455 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6456 ret
= pUpdateLayeredWindowIndirect( hwnd
, NULL
);
6457 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6458 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6461 ret
= pSetLayeredWindowAttributes( hwnd
, 0x654321, 22, LWA_COLORKEY
| LWA_ALPHA
);
6462 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6463 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6464 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6465 ok( key
== 0x654321, "wrong color key %x\n", key
);
6466 ok( alpha
== 22, "wrong alpha %u\n", alpha
);
6467 ok( flags
== (LWA_COLORKEY
| LWA_ALPHA
), "wrong flags %x\n", flags
);
6468 SetLastError( 0xdeadbeef );
6469 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6470 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
6471 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6473 ret
= pSetLayeredWindowAttributes( hwnd
, 0x888888, 33, LWA_COLORKEY
);
6474 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6476 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6477 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6478 ok( key
== 0x888888, "wrong color key %x\n", key
);
6479 /* alpha not changed on vista if LWA_ALPHA is not set */
6480 ok( alpha
== 22 || alpha
== 33, "wrong alpha %u\n", alpha
);
6481 ok( flags
== LWA_COLORKEY
, "wrong flags %x\n", flags
);
6483 /* color key may or may not be changed without LWA_COLORKEY */
6484 ret
= pSetLayeredWindowAttributes( hwnd
, 0x999999, 44, 0 );
6485 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6487 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6488 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6489 ok( key
== 0x888888 || key
== 0x999999, "wrong color key %x\n", key
);
6490 ok( alpha
== 22 || alpha
== 44, "wrong alpha %u\n", alpha
);
6491 ok( flags
== 0, "wrong flags %x\n", flags
);
6493 /* default alpha and color key is 0 */
6494 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
6495 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6496 ret
= pSetLayeredWindowAttributes( hwnd
, 0x222222, 55, 0 );
6497 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6498 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6499 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6500 ok( key
== 0 || key
== 0x222222, "wrong color key %x\n", key
);
6501 ok( alpha
== 0 || alpha
== 55, "wrong alpha %u\n", alpha
);
6502 ok( flags
== 0, "wrong flags %x\n", flags
);
6504 DestroyWindow( hwnd
);
6506 DeleteObject( hbm
);
6509 static MONITORINFO mi
;
6511 static LRESULT CALLBACK
fullscreen_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
6517 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
6518 ok(cs
->x
== mi
.rcMonitor
.left
&& cs
->y
== mi
.rcMonitor
.top
&&
6519 cs
->cx
== mi
.rcMonitor
.right
&& cs
->cy
== mi
.rcMonitor
.bottom
,
6520 "expected %d,%d-%d,%d, got %d,%d-%d,%d\n",
6521 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6522 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
6525 case WM_GETMINMAXINFO
:
6527 MINMAXINFO
*minmax
= (MINMAXINFO
*)lp
;
6528 ok(minmax
->ptMaxPosition
.x
<= mi
.rcMonitor
.left
, "%d <= %d\n", minmax
->ptMaxPosition
.x
, mi
.rcMonitor
.left
);
6529 ok(minmax
->ptMaxPosition
.y
<= mi
.rcMonitor
.top
, "%d <= %d\n", minmax
->ptMaxPosition
.y
, mi
.rcMonitor
.top
);
6530 ok(minmax
->ptMaxSize
.x
>= mi
.rcMonitor
.right
, "%d >= %d\n", minmax
->ptMaxSize
.x
, mi
.rcMonitor
.right
);
6531 ok(minmax
->ptMaxSize
.y
>= mi
.rcMonitor
.bottom
, "%d >= %d\n", minmax
->ptMaxSize
.y
, mi
.rcMonitor
.bottom
);
6535 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
6538 static void test_fullscreen(void)
6540 static const DWORD t_style
[] = {
6541 WS_OVERLAPPED
, WS_POPUP
, WS_CHILD
, WS_THICKFRAME
, WS_DLGFRAME
6543 static const DWORD t_ex_style
[] = {
6544 0, WS_EX_APPWINDOW
, WS_EX_TOOLWINDOW
6554 if (!pGetMonitorInfoA
|| !pMonitorFromPoint
)
6556 win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
6561 SetLastError(0xdeadbeef);
6562 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
6563 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
6565 mi
.cbSize
= sizeof(mi
);
6566 SetLastError(0xdeadbeef);
6567 ret
= pGetMonitorInfoA(hmon
, &mi
);
6568 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
6569 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
6570 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6571 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
6574 cls
.lpfnWndProc
= fullscreen_wnd_proc
;
6577 cls
.hInstance
= GetModuleHandleA(NULL
);
6579 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6580 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6581 cls
.lpszMenuName
= NULL
;
6582 cls
.lpszClassName
= "fullscreen_class";
6583 RegisterClassA(&cls
);
6585 for (i
= 0; i
< sizeof(t_style
)/sizeof(t_style
[0]); i
++)
6587 DWORD style
, ex_style
;
6589 /* avoid a WM interaction */
6590 assert(!(t_style
[i
] & WS_VISIBLE
));
6592 for (j
= 0; j
< sizeof(t_ex_style
)/sizeof(t_ex_style
[0]); j
++)
6597 ex_style
= t_ex_style
[j
];
6599 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6600 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6601 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6602 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6603 GetWindowRect(hwnd
, &rc
);
6604 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6605 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6606 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6607 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6608 DestroyWindow(hwnd
);
6610 style
= t_style
[i
] | WS_MAXIMIZE
;
6611 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6612 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6613 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6614 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6615 GetWindowRect(hwnd
, &rc
);
6616 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6617 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6618 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6619 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6620 DestroyWindow(hwnd
);
6622 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
;
6623 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6624 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6625 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6626 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6627 GetWindowRect(hwnd
, &rc
);
6628 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6629 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6630 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6631 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6632 DestroyWindow(hwnd
);
6634 style
= t_style
[i
] | WS_CAPTION
| WS_MAXIMIZEBOX
;
6635 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6636 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6637 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6638 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6639 GetWindowRect(hwnd
, &rc
);
6640 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6641 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6642 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6643 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6644 DestroyWindow(hwnd
);
6646 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
| WS_MAXIMIZEBOX
;
6647 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6648 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6649 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6650 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6651 GetWindowRect(hwnd
, &rc
);
6652 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6653 /* Windows makes a maximized window slightly larger (to hide the borders?) */
6654 fixup
= min(abs(rc
.left
), abs(rc
.top
));
6655 InflateRect(&rc
, -fixup
, -fixup
);
6656 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
6657 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
6658 "%#x/%#x: window rect %d,%d-%d,%d must be in %d,%d-%d,%d\n",
6659 ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
6660 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
6661 DestroyWindow(hwnd
);
6663 style
= t_style
[i
] | WS_MAXIMIZE
| WS_MAXIMIZEBOX
;
6664 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6665 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6666 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6667 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6668 GetWindowRect(hwnd
, &rc
);
6669 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6670 /* Windows makes a maximized window slightly larger (to hide the borders?) */
6671 fixup
= min(abs(rc
.left
), abs(rc
.top
));
6672 InflateRect(&rc
, -fixup
, -fixup
);
6673 if (style
& (WS_CHILD
| WS_POPUP
))
6674 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6675 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6676 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6678 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
6679 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
6680 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6681 DestroyWindow(hwnd
);
6685 UnregisterClassA("fullscreen_class", GetModuleHandleA(NULL
));
6688 static BOOL test_thick_child_got_minmax
;
6689 static const char * test_thick_child_name
;
6690 static LONG test_thick_child_style
;
6691 static LONG test_thick_child_exStyle
;
6693 static LRESULT WINAPI
test_thick_child_size_winproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
6696 int expectedMinTrackX
;
6697 int expectedMinTrackY
;
6698 int actualMinTrackX
;
6699 int actualMinTrackY
;
6700 int expectedMaxTrackX
;
6701 int expectedMaxTrackY
;
6702 int actualMaxTrackX
;
6703 int actualMaxTrackY
;
6704 int expectedMaxSizeX
;
6705 int expectedMaxSizeY
;
6716 case WM_GETMINMAXINFO
:
6718 minmax
= (MINMAXINFO
*)lparam
;
6719 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
6720 dump_minmax_info( minmax
);
6722 test_thick_child_got_minmax
= TRUE
;
6725 adjustedStyle
= test_thick_child_style
;
6726 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
6727 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
6728 GetClientRect(GetParent(hwnd
), &rect
);
6729 AdjustWindowRectEx(&rect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
6731 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
6733 expectedMinTrackX
= GetSystemMetrics(SM_CXMINTRACK
);
6734 expectedMinTrackY
= GetSystemMetrics(SM_CYMINTRACK
);
6738 expectedMinTrackX
= -2 * rect
.left
;
6739 expectedMinTrackY
= -2 * rect
.top
;
6741 actualMinTrackX
= minmax
->ptMinTrackSize
.x
;
6742 actualMinTrackY
= minmax
->ptMinTrackSize
.y
;
6744 ok(actualMinTrackX
== expectedMinTrackX
&& actualMinTrackY
== expectedMinTrackY
,
6745 "expected minTrack %dx%d, actual minTrack %dx%d for %s\n",
6746 expectedMinTrackX
, expectedMinTrackY
, actualMinTrackX
, actualMinTrackY
,
6747 test_thick_child_name
);
6749 actualMaxTrackX
= minmax
->ptMaxTrackSize
.x
;
6750 actualMaxTrackY
= minmax
->ptMaxTrackSize
.y
;
6751 expectedMaxTrackX
= GetSystemMetrics(SM_CXMAXTRACK
);
6752 expectedMaxTrackY
= GetSystemMetrics(SM_CYMAXTRACK
);
6753 ok(actualMaxTrackX
== expectedMaxTrackX
&& actualMaxTrackY
== expectedMaxTrackY
,
6754 "expected maxTrack %dx%d, actual maxTrack %dx%d for %s\n",
6755 expectedMaxTrackX
, expectedMaxTrackY
, actualMaxTrackX
, actualMaxTrackY
,
6756 test_thick_child_name
);
6758 expectedMaxSizeX
= rect
.right
- rect
.left
;
6759 expectedMaxSizeY
= rect
.bottom
- rect
.top
;
6760 actualMaxSizeX
= minmax
->ptMaxSize
.x
;
6761 actualMaxSizeY
= minmax
->ptMaxSize
.y
;
6763 ok(actualMaxSizeX
== expectedMaxSizeX
&& actualMaxSizeY
== expectedMaxSizeY
,
6764 "expected maxSize %dx%d, actual maxSize %dx%d for %s\n",
6765 expectedMaxSizeX
, expectedMaxSizeY
, actualMaxSizeX
, actualMaxSizeY
,
6766 test_thick_child_name
);
6769 expectedPosX
= rect
.left
;
6770 expectedPosY
= rect
.top
;
6771 actualPosX
= minmax
->ptMaxPosition
.x
;
6772 actualPosY
= minmax
->ptMaxPosition
.y
;
6773 ok(actualPosX
== expectedPosX
&& actualPosY
== expectedPosY
,
6774 "expected maxPosition (%d/%d), actual maxPosition (%d/%d) for %s\n",
6775 expectedPosX
, expectedPosY
, actualPosX
, actualPosY
, test_thick_child_name
);
6781 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
6784 #define NUMBER_OF_THICK_CHILD_TESTS 16
6785 static void test_thick_child_size(HWND parentWindow
)
6789 RECT adjustedParentRect
;
6794 LONG expectedHeight
;
6796 static const char className
[] = "THICK_CHILD_CLASS";
6799 static const LONG styles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6800 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6801 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6802 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6803 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6804 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6805 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6806 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6807 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6808 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6809 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6810 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6811 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6812 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6813 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6814 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6815 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6818 static const LONG exStyles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6823 WS_EX_DLGMODALFRAME
,
6824 WS_EX_DLGMODALFRAME
,
6825 WS_EX_DLGMODALFRAME
,
6826 WS_EX_DLGMODALFRAME
,
6831 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6832 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6833 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6834 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6836 static const char *styleName
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6837 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME",
6838 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME",
6839 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER",
6840 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER",
6841 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_DLGMODALFRAME",
6842 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_DLGMODALFRAME",
6843 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
6844 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
6845 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME exstyle= WS_EX_STATICEDGE",
6846 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE",
6847 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
6848 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
6849 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6850 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6851 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6852 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6856 cls
.lpfnWndProc
= test_thick_child_size_winproc
;
6859 cls
.hInstance
= GetModuleHandleA(0);
6861 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6862 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6863 cls
.lpszMenuName
= NULL
;
6864 cls
.lpszClassName
= className
;
6865 SetLastError(0xdeadbeef);
6866 success
= RegisterClassA(&cls
);
6867 ok(success
,"RegisterClassA failed, error: %u\n", GetLastError());
6869 for(i
= 0; i
< NUMBER_OF_THICK_CHILD_TESTS
; i
++)
6871 test_thick_child_name
= styleName
[i
];
6872 test_thick_child_style
= styles
[i
];
6873 test_thick_child_exStyle
= exStyles
[i
];
6874 test_thick_child_got_minmax
= FALSE
;
6876 SetLastError(0xdeadbeef);
6877 childWindow
= CreateWindowExA( exStyles
[i
], className
, "", styles
[i
], 0, 0, 0, 0, parentWindow
, 0, GetModuleHandleA(0), NULL
);
6878 ok(childWindow
!= NULL
, "Failed to create child window, error: %u\n", GetLastError());
6880 ok(test_thick_child_got_minmax
, "Got no WM_GETMINMAXINFO\n");
6882 SetLastError(0xdeadbeef);
6883 success
= GetWindowRect(childWindow
, &childRect
);
6884 ok(success
,"GetWindowRect call failed, error: %u\n", GetLastError());
6885 childWidth
= childRect
.right
- childRect
.left
;
6886 childHeight
= childRect
.bottom
- childRect
.top
;
6888 adjustedStyle
= styles
[i
];
6889 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
6890 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
6891 GetClientRect(GetParent(childWindow
), &adjustedParentRect
);
6892 AdjustWindowRectEx(&adjustedParentRect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
6895 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
6897 expectedWidth
= GetSystemMetrics(SM_CXMINTRACK
);
6898 expectedHeight
= GetSystemMetrics(SM_CYMINTRACK
);
6902 expectedWidth
= -2 * adjustedParentRect
.left
;
6903 expectedHeight
= -2 * adjustedParentRect
.top
;
6906 ok((childWidth
== expectedWidth
) && (childHeight
== expectedHeight
),
6907 "size of window (%s) is wrong: expected size %dx%d != actual size %dx%d\n",
6908 test_thick_child_name
, expectedWidth
, expectedHeight
, childWidth
, childHeight
);
6910 SetLastError(0xdeadbeef);
6911 success
= DestroyWindow(childWindow
);
6912 ok(success
,"DestroyWindow call failed, error: %u\n", GetLastError());
6914 ok(UnregisterClassA(className
, GetModuleHandleA(NULL
)),"UnregisterClass call failed\n");
6917 static void test_handles( HWND full_hwnd
)
6919 HWND hwnd
= full_hwnd
;
6923 SetLastError( 0xdeadbeef );
6924 ret
= GetWindowRect( hwnd
, &rect
);
6925 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6928 if ((ULONG_PTR
)full_hwnd
>> 32)
6929 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
& ~0u);
6931 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
| ((ULONG_PTR
)~0u << 32));
6932 SetLastError( 0xdeadbeef );
6933 ret
= GetWindowRect( hwnd
, &rect
);
6934 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6936 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& ~0u) | ((ULONG_PTR
)0x1234 << 32));
6937 SetLastError( 0xdeadbeef );
6938 ret
= GetWindowRect( hwnd
, &rect
);
6939 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6941 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x9876 << 16));
6942 SetLastError( 0xdeadbeef );
6943 ret
= GetWindowRect( hwnd
, &rect
);
6944 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
6945 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
6947 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x12345678 << 16));
6948 SetLastError( 0xdeadbeef );
6949 ret
= GetWindowRect( hwnd
, &rect
);
6950 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
6951 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
6955 static void test_winregion(void)
6962 if (!pGetWindowRgnBox
)
6964 win_skip("GetWindowRgnBox not supported\n");
6968 hwnd
= CreateWindowExA(0, "static", NULL
, WS_VISIBLE
, 10, 10, 10, 10, NULL
, 0, 0, NULL
);
6970 SetLastError(0xdeadbeef);
6971 ret
= pGetWindowRgnBox(hwnd
, NULL
);
6972 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
6973 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
6975 hrgn
= CreateRectRgn(2, 3, 10, 15);
6976 ok( hrgn
!= NULL
, "Region creation failed\n");
6979 SetWindowRgn(hwnd
, hrgn
, FALSE
);
6981 SetLastError(0xdeadbeef);
6982 ret
= pGetWindowRgnBox(hwnd
, NULL
);
6983 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
6984 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
6986 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6987 ret
= pGetWindowRgnBox(hwnd
, &r
);
6988 ok( ret
== SIMPLEREGION
, "Expected SIMPLEREGION, got %d\n", ret
);
6989 ok( r
.left
== 2 && r
.top
== 3 && r
.right
== 10 && r
.bottom
== 15,
6990 "Expected (2,3,10,15), got (%d,%d,%d,%d)\n", r
.left
, r
.top
,
6994 hrgn
= CreateRectRgn(2, 3, 10, 15);
6995 ret
= pMirrorRgn( hwnd
, hrgn
);
6996 ok( ret
== TRUE
, "MirrorRgn failed %u\n", ret
);
6997 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6998 GetWindowRect( hwnd
, &r
);
6999 width
= r
.right
- r
.left
;
7000 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
7001 ret
= GetRgnBox( hrgn
, &r
);
7002 ok( ret
== SIMPLEREGION
, "GetRgnBox failed %u\n", ret
);
7003 ok( r
.left
== width
- 10 && r
.top
== 3 && r
.right
== width
- 2 && r
.bottom
== 15,
7004 "Wrong rectangle (%d,%d,%d,%d) for width %d\n", r
.left
, r
.top
, r
.right
, r
.bottom
, width
);
7006 else win_skip( "MirrorRgn not supported\n" );
7008 DestroyWindow(hwnd
);
7011 static void test_rtl_layout(void)
7017 if (!pSetProcessDefaultLayout
)
7019 win_skip( "SetProcessDefaultLayout not supported\n" );
7023 parent
= CreateWindowExA(WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
, 100, 100, 300, 300, NULL
, 0, 0, NULL
);
7024 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 10, 10, 20, 20, parent
, 0, 0, NULL
);
7026 GetWindowRect( parent
, &r
);
7027 ok( r
.left
== 100 && r
.right
== 400, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7028 GetClientRect( parent
, &r
);
7029 ok( r
.left
== 0 && r
.right
== 300, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7030 GetClientRect( child
, &r
);
7031 ok( r
.left
== 0 && r
.right
== 20, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7032 MapWindowPoints( child
, parent
, (POINT
*)&r
, 2 );
7033 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7034 GetWindowRect( child
, &r
);
7035 ok( r
.left
== 370 && r
.right
== 390, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7036 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
7037 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7038 GetWindowRect( child
, &r
);
7039 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 1 );
7040 MapWindowPoints( NULL
, parent
, (POINT
*)&r
+ 1, 1 );
7041 ok( r
.left
== 30 && r
.right
== 10, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7043 MapWindowPoints( child
, parent
, &pt
, 1 );
7044 ok( pt
.x
== 22 && pt
.y
== 22, "wrong point %d,%d\n", pt
.x
, pt
.y
);
7045 SetWindowPos( parent
, 0, 0, 0, 250, 250, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
7046 GetWindowRect( parent
, &r
);
7047 ok( r
.left
== 100 && r
.right
== 350, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7048 GetWindowRect( child
, &r
);
7049 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7050 SetWindowLongW( parent
, GWL_EXSTYLE
, 0 );
7051 GetWindowRect( child
, &r
);
7052 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7053 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
7054 ok( r
.left
== 220 && r
.right
== 240, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7055 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_LAYOUTRTL
);
7056 GetWindowRect( child
, &r
);
7057 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7058 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
7059 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7060 SetWindowPos( child
, 0, 0, 0, 30, 30, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
7061 GetWindowRect( child
, &r
);
7062 ok( r
.left
== 310 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7063 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
7064 ok( r
.left
== 10 && r
.right
== 40, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
7065 DestroyWindow( child
);
7066 DestroyWindow( parent
);
7069 static void test_FlashWindowEx(void)
7075 if (!pFlashWindowEx
)
7077 win_skip( "FlashWindowEx not supported\n" );
7081 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP
,
7082 0, 0, 0, 0, 0, 0, 0, NULL
);
7083 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
7085 finfo
.cbSize
= sizeof(FLASHWINFO
);
7086 finfo
.dwFlags
= FLASHW_TIMER
;
7088 finfo
.dwTimeout
= 200;
7090 SetLastError(0xdeadbeef);
7091 ret
= pFlashWindowEx(&finfo
);
7092 todo_wine
ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
7093 "FlashWindowEx returned with %d\n", GetLastError());
7096 SetLastError(0xdeadbeef);
7097 ret
= pFlashWindowEx(NULL
);
7098 todo_wine
ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
7099 "FlashWindowEx returned with %d\n", GetLastError());
7101 SetLastError(0xdeadbeef);
7102 ret
= pFlashWindowEx(&finfo
);
7103 todo_wine
ok(!ret
, "previous window state should not be active\n");
7105 finfo
.cbSize
= sizeof(FLASHWINFO
) - 1;
7106 SetLastError(0xdeadbeef);
7107 ret
= pFlashWindowEx(&finfo
);
7108 todo_wine
ok(!ret
&& GetLastError()==ERROR_INVALID_PARAMETER
,
7109 "FlashWindowEx succeeded\n");
7111 finfo
.cbSize
= sizeof(FLASHWINFO
) + 1;
7112 SetLastError(0xdeadbeef);
7113 ret
= pFlashWindowEx(&finfo
);
7114 todo_wine
ok(!ret
&& GetLastError()==ERROR_INVALID_PARAMETER
,
7115 "FlashWindowEx succeeded\n");
7116 finfo
.cbSize
= sizeof(FLASHWINFO
);
7118 DestroyWindow( hwnd
);
7120 SetLastError(0xdeadbeef);
7121 ret
= pFlashWindowEx(&finfo
);
7122 todo_wine
ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
7123 "FlashWindowEx returned with %d\n", GetLastError());
7125 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
7126 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
7127 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
7128 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
7129 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
7131 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_VISIBLE
| WS_POPUPWINDOW
,
7132 0, 0, 0, 0, 0, 0, 0, NULL
);
7133 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
7136 SetLastError(0xdeadbeef);
7137 ret
= pFlashWindowEx(NULL
);
7138 todo_wine
ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
7139 "FlashWindowEx returned with %d\n", GetLastError());
7141 SetLastError(0xdeadbeef);
7142 prev
= pFlashWindowEx(&finfo
);
7144 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
7145 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
7146 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
7147 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
7148 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
7150 finfo
.dwFlags
= FLASHW_STOP
;
7151 SetLastError(0xdeadbeef);
7152 ret
= pFlashWindowEx(&finfo
);
7154 ok(prev
!= ret
, "previous window state should be different\n");
7156 DestroyWindow( hwnd
);
7159 static void test_FindWindowEx(void)
7163 hwnd
= CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
7164 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
7166 num_gettext_msgs
= 0;
7167 found
= FindWindowExA( 0, 0, "MainWindowClass", "" );
7168 ok( found
== NULL
, "expected a NULL hwnd\n" );
7169 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
7171 num_gettext_msgs
= 0;
7172 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
7173 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
7174 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
7176 num_gettext_msgs
= 0;
7177 found
= FindWindowExA( 0, 0, "MainWindowClass", "caption" );
7178 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
7179 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
7181 DestroyWindow( hwnd
);
7183 hwnd
= CreateWindowExA( 0, "MainWindowClass", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
7184 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
7186 num_gettext_msgs
= 0;
7187 found
= FindWindowExA( 0, 0, "MainWindowClass", "" );
7188 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
7189 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
7191 num_gettext_msgs
= 0;
7192 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
7193 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
7194 ok( num_gettext_msgs
== 0, "got %u WM_GETTEXT messages\n", num_gettext_msgs
);
7196 DestroyWindow( hwnd
);
7198 /* test behaviour with a window title that is an empty character */
7199 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", "" );
7200 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
7201 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", NULL
);
7202 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
7205 static void test_GetLastActivePopup(void)
7207 HWND hwndOwner
, hwndPopup1
, hwndPopup2
;
7209 hwndOwner
= CreateWindowExA(0, "MainWindowClass", NULL
,
7210 WS_VISIBLE
| WS_POPUPWINDOW
,
7212 NULL
, 0, GetModuleHandleA(NULL
), NULL
);
7213 hwndPopup1
= CreateWindowExA(0, "MainWindowClass", NULL
,
7214 WS_VISIBLE
| WS_POPUPWINDOW
,
7216 hwndOwner
, 0, GetModuleHandleA(NULL
), NULL
);
7217 hwndPopup2
= CreateWindowExA(0, "MainWindowClass", NULL
,
7218 WS_VISIBLE
| WS_POPUPWINDOW
,
7220 hwndPopup1
, 0, GetModuleHandleA(NULL
), NULL
);
7221 ok( GetLastActivePopup(hwndOwner
) == hwndPopup2
, "wrong last active popup\n" );
7222 DestroyWindow( hwndPopup2
);
7223 DestroyWindow( hwndPopup1
);
7224 DestroyWindow( hwndOwner
);
7227 static LRESULT WINAPI
my_httrasparent_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7229 if (msg
== WM_NCHITTEST
) return HTTRANSPARENT
;
7230 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
7233 static LRESULT WINAPI
my_window_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7235 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
7238 static void create_window_tree(HWND parent
, HWND
*window
, int size
)
7240 static const DWORD style
[] = { 0, WS_VISIBLE
, WS_DISABLED
, WS_VISIBLE
| WS_DISABLED
};
7243 memset(window
, 0, size
* sizeof(window
[0]));
7246 for (i
= 0; i
< sizeof(style
)/sizeof(style
[0]); i
++)
7249 window
[pos
] = CreateWindowExA(0, "my_window", NULL
, style
[i
] | WS_CHILD
,
7250 0, 0, 100, 100, parent
, 0, 0, NULL
);
7251 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7254 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_window", NULL
, style
[i
] | WS_CHILD
,
7255 0, 0, 100, 100, parent
, 0, 0, NULL
);
7256 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7260 window
[pos
] = CreateWindowExA(0, "my_httrasparent", NULL
, style
[i
] | WS_CHILD
,
7261 0, 0, 100, 100, parent
, 0, 0, NULL
);
7262 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7265 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_httrasparent", NULL
, style
[i
] | WS_CHILD
,
7266 0, 0, 100, 100, parent
, 0, 0, NULL
);
7267 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7271 window
[pos
] = CreateWindowExA(0, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7272 0, 0, 100, 100, parent
, 0, 0, NULL
);
7273 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7276 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7277 0, 0, 100, 100, parent
, 0, 0, NULL
);
7278 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7281 window
[pos
] = CreateWindowExA(0, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7282 0, 0, 100, 100, parent
, 0, 0, NULL
);
7283 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7286 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7287 0, 0, 100, 100, parent
, 0, 0, NULL
);
7288 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7292 window
[pos
] = CreateWindowExA(0, "Button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7293 0, 0, 100, 100, parent
, 0, 0, NULL
);
7294 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7297 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7298 0, 0, 100, 100, parent
, 0, 0, NULL
);
7299 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7302 window
[pos
] = CreateWindowExA(0, "Button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7303 0, 0, 100, 100, parent
, 0, 0, NULL
);
7304 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7307 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7308 0, 0, 100, 100, parent
, 0, 0, NULL
);
7309 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7313 window
[pos
] = CreateWindowExA(0, "Static", NULL
, style
[i
] | WS_CHILD
,
7314 0, 0, 100, 100, parent
, 0, 0, NULL
);
7315 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7318 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Static", NULL
, style
[i
] | WS_CHILD
,
7319 0, 0, 100, 100, parent
, 0, 0, NULL
);
7320 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7325 struct window_attributes
7327 char class_name
[128];
7328 BOOL is_visible
, is_enabled
, is_groupbox
, is_httransparent
, is_extransparent
;
7331 static void get_window_attributes(HWND hwnd
, struct window_attributes
*attrs
)
7333 DWORD style
, ex_style
, hittest
;
7335 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7336 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
7337 attrs
->class_name
[0] = 0;
7338 GetClassNameA(hwnd
, attrs
->class_name
, sizeof(attrs
->class_name
));
7339 hittest
= SendMessageA(hwnd
, WM_NCHITTEST
, 0, 0);
7341 attrs
->is_visible
= (style
& WS_VISIBLE
) != 0;
7342 attrs
->is_enabled
= (style
& WS_DISABLED
) == 0;
7343 attrs
->is_groupbox
= !lstrcmpiA(attrs
->class_name
, "Button") && (style
& BS_TYPEMASK
) == BS_GROUPBOX
;
7344 attrs
->is_httransparent
= hittest
== HTTRANSPARENT
;
7345 attrs
->is_extransparent
= (ex_style
& WS_EX_TRANSPARENT
) != 0;
7348 static int window_to_index(HWND hwnd
, HWND
*window
, int size
)
7352 for (i
= 0; i
< size
; i
++)
7354 if (!window
[i
]) break;
7355 if (window
[i
] == hwnd
) return i
;
7360 static void test_child_window_from_point(void)
7362 static const int real_child_pos
[] = { 14,15,16,17,18,19,20,21,24,25,26,27,42,43,
7363 44,45,46,47,48,49,52,53,54,55,51,50,23,22,-1 };
7364 static const int real_child_pos_nt4
[] = { 14,15,16,17,20,21,24,25,26,27,42,43,44,45,
7365 48,49,52,53,54,55,51,50,47,46,23,22,19,18,-1 };
7367 HWND hwnd
, parent
, window
[100];
7369 int found_invisible
, found_disabled
, found_groupbox
, found_httransparent
, found_extransparent
;
7372 ret
= GetClassInfoA(0, "Button", &cls
);
7373 ok(ret
, "GetClassInfo(Button) failed\n");
7374 cls
.lpszClassName
= "my_button";
7375 ret
= RegisterClassA(&cls
);
7376 ok(ret
, "RegisterClass(my_button) failed\n");
7378 cls
.lpszClassName
= "my_httrasparent";
7379 cls
.lpfnWndProc
= my_httrasparent_proc
;
7380 ret
= RegisterClassA(&cls
);
7381 ok(ret
, "RegisterClass(my_httrasparent) failed\n");
7383 cls
.lpszClassName
= "my_window";
7384 cls
.lpfnWndProc
= my_window_proc
;
7385 ret
= RegisterClassA(&cls
);
7386 ok(ret
, "RegisterClass(my_window) failed\n");
7388 parent
= CreateWindowExA(0, "MainWindowClass", NULL
,
7389 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
,
7391 0, 0, GetModuleHandleA(NULL
), NULL
);
7392 ok(parent
!= 0, "CreateWindowEx failed\n");
7393 trace("parent %p\n", parent
);
7395 create_window_tree(parent
, window
, sizeof(window
)/sizeof(window
[0]));
7397 found_invisible
= 0;
7400 found_httransparent
= 0;
7401 found_extransparent
= 0;
7403 /* FIXME: also test WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx */
7404 for (i
= 0; i
< sizeof(real_child_pos
)/sizeof(real_child_pos
[0]); i
++)
7406 struct window_attributes attrs
;
7409 hwnd
= RealChildWindowFromPoint(parent
, pt
);
7410 ok(hwnd
!= 0, "RealChildWindowFromPoint failed\n");
7411 ret
= window_to_index(hwnd
, window
, sizeof(window
)/sizeof(window
[0]));
7412 /* FIXME: remove once Wine is fixed */
7413 if (ret
!= real_child_pos
[i
])
7414 todo_wine
ok(ret
== real_child_pos
[i
] || broken(ret
== real_child_pos_nt4
[i
]), "expected %d, got %d\n", real_child_pos
[i
], ret
);
7416 ok(ret
== real_child_pos
[i
] || broken(ret
== real_child_pos_nt4
[i
]), "expected %d, got %d\n", real_child_pos
[i
], ret
);
7418 get_window_attributes(hwnd
, &attrs
);
7419 if (!attrs
.is_visible
) found_invisible
++;
7420 if (!attrs
.is_enabled
) found_disabled
++;
7421 if (attrs
.is_groupbox
) found_groupbox
++;
7422 if (attrs
.is_httransparent
) found_httransparent
++;
7423 if (attrs
.is_extransparent
) found_extransparent
++;
7425 if (ret
!= real_child_pos
[i
] && ret
!= -1)
7427 trace("found hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
7428 hwnd
, attrs
.class_name
, attrs
.is_visible
, attrs
.is_enabled
, attrs
.is_groupbox
, attrs
.is_httransparent
, attrs
.is_extransparent
);
7429 get_window_attributes(window
[real_child_pos
[i
]], &attrs
);
7430 trace("expected hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
7431 window
[real_child_pos
[i
]], attrs
.class_name
, attrs
.is_visible
, attrs
.is_enabled
, attrs
.is_groupbox
, attrs
.is_httransparent
, attrs
.is_extransparent
);
7435 ok(hwnd
== parent
, "expected %p, got %p\n", parent
, hwnd
);
7438 DestroyWindow(hwnd
);
7441 DestroyWindow(parent
);
7443 ok(!found_invisible
, "found %d invisible windows\n", found_invisible
);
7444 ok(found_disabled
, "found %d disabled windows\n", found_disabled
);
7446 ok(found_groupbox
== 4, "found %d groupbox windows\n", found_groupbox
);
7447 ok(found_httransparent
, "found %d httransparent windows\n", found_httransparent
);
7449 ok(found_extransparent
, "found %d extransparent windows\n", found_extransparent
);
7451 ret
= UnregisterClassA("my_button", cls
.hInstance
);
7452 ok(ret
, "UnregisterClass(my_button) failed\n");
7453 ret
= UnregisterClassA("my_httrasparent", cls
.hInstance
);
7454 ok(ret
, "UnregisterClass(my_httrasparent) failed\n");
7455 ret
= UnregisterClassA("my_window", cls
.hInstance
);
7456 ok(ret
, "UnregisterClass(my_window) failed\n");
7459 static void simulate_click(int x
, int y
)
7465 memset(input
, 0, sizeof(input
));
7466 input
[0].type
= INPUT_MOUSE
;
7467 U(input
[0]).mi
.dx
= x
;
7468 U(input
[0]).mi
.dy
= y
;
7469 U(input
[0]).mi
.dwFlags
= MOUSEEVENTF_LEFTDOWN
;
7470 input
[1].type
= INPUT_MOUSE
;
7471 U(input
[1]).mi
.dx
= x
;
7472 U(input
[1]).mi
.dy
= y
;
7473 U(input
[1]).mi
.dwFlags
= MOUSEEVENTF_LEFTUP
;
7474 events_no
= SendInput(2, input
, sizeof(input
[0]));
7475 ok(events_no
== 2, "SendInput returned %d\n", events_no
);
7478 static WNDPROC def_static_proc
;
7479 static BOOL got_hittest
;
7480 static LRESULT WINAPI
static_hook_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7482 if(msg
== WM_NCHITTEST
)
7484 if(msg
== WM_LBUTTONDOWN
)
7485 ok(0, "unexpected call\n");
7487 return def_static_proc(hwnd
, msg
, wp
, lp
);
7490 static void window_from_point_proc(HWND parent
)
7492 HANDLE start_event
, end_event
;
7493 HANDLE win
, child_static
, child_button
;
7499 start_event
= OpenEventA(EVENT_ALL_ACCESS
, FALSE
, "test_wfp_start");
7500 ok(start_event
!= 0, "OpenEvent failed\n");
7501 end_event
= OpenEventA(EVENT_ALL_ACCESS
, FALSE
, "test_wfp_end");
7502 ok(end_event
!= 0, "OpenEvent failed\n");
7504 child_static
= CreateWindowExA(0, "static", "static", WS_CHILD
| WS_VISIBLE
,
7505 0, 0, 100, 100, parent
, 0, NULL
, NULL
);
7506 ok(child_static
!= 0, "CreateWindowEx failed\n");
7508 win
= WindowFromPoint(pt
);
7509 ok(win
== parent
, "WindowFromPoint returned %p, expected %p\n", win
, parent
);
7511 child_button
= CreateWindowExA(0, "button", "button", WS_CHILD
| WS_VISIBLE
,
7512 100, 0, 100, 100, parent
, 0, NULL
, NULL
);
7513 ok(child_button
!= 0, "CreateWindowEx failed\n");
7515 win
= WindowFromPoint(pt
);
7516 ok(win
== child_button
, "WindowFromPoint returned %p, expected %p\n", win
, child_button
);
7518 /* without this window simulate click test keeps sending WM_NCHITTEST
7519 * message to child_static in an infinite loop */
7520 win
= CreateWindowExA(0, "button", "button", WS_CHILD
| WS_VISIBLE
,
7521 0, 0, 100, 100, parent
, 0, NULL
, NULL
);
7522 ok(win
!= 0, "CreateWindowEx failed\n");
7523 def_static_proc
= (void*)SetWindowLongPtrA(child_static
,
7524 GWLP_WNDPROC
, (LONG_PTR
)static_hook_proc
);
7526 SetEvent(start_event
);
7528 got_hittest
= FALSE
;
7530 while(!got_click
&& wait_for_message(&msg
)) {
7531 if(msg
.message
== WM_LBUTTONUP
) {
7532 ok(msg
.hwnd
== win
, "msg.hwnd = %p, expected %p\n", msg
.hwnd
, win
);
7535 DispatchMessageA(&msg
);
7537 ok(got_hittest
, "transparent window didn't get WM_NCHITTEST message\n");
7538 ok(got_click
, "button under static window didn't get WM_LBUTTONUP\n");
7540 ret
= WaitForSingleObject(end_event
, 5000);
7541 ok(ret
== WAIT_OBJECT_0
, "WaitForSingleObject returned %x\n", ret
);
7543 CloseHandle(start_event
);
7544 CloseHandle(end_event
);
7547 static void test_window_from_point(const char *argv0
)
7549 HWND hwnd
, child
, win
;
7551 PROCESS_INFORMATION info
;
7552 STARTUPINFOA startup
;
7554 HANDLE start_event
, end_event
;
7556 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
| WS_VISIBLE
,
7557 100, 100, 200, 100, 0, 0, NULL
, NULL
);
7558 ok(hwnd
!= 0, "CreateWindowEx failed\n");
7561 win
= WindowFromPoint(pt
);
7564 win
= WindowFromPoint(pt
);
7566 skip("there's another window covering test window\n");
7567 DestroyWindow(hwnd
);
7571 child
= CreateWindowExA(0, "static", "static", WS_CHILD
| WS_VISIBLE
,
7572 0, 0, 100, 100, hwnd
, 0, NULL
, NULL
);
7573 ok(child
!= 0, "CreateWindowEx failed\n");
7575 win
= WindowFromPoint(pt
);
7576 ok(win
== hwnd
, "WindowFromPoint returned %p, expected %p\n", win
, hwnd
);
7577 DestroyWindow(child
);
7579 child
= CreateWindowExA(0, "button", "button", WS_CHILD
| WS_VISIBLE
,
7580 0, 0, 100, 100, hwnd
, 0, NULL
, NULL
);
7581 ok(child
!= 0, "CreateWindowEx failed\n");
7582 win
= WindowFromPoint(pt
);
7583 ok(win
== child
, "WindowFromPoint returned %p, expected %p\n", win
, child
);
7584 DestroyWindow(child
);
7586 start_event
= CreateEventA(NULL
, FALSE
, FALSE
, "test_wfp_start");
7587 ok(start_event
!= 0, "CreateEvent failed\n");
7588 end_event
= CreateEventA(NULL
, FALSE
, FALSE
, "test_wfp_end");
7589 ok(start_event
!= 0, "CreateEvent failed\n");
7591 sprintf(cmd
, "%s win create_children %p\n", argv0
, hwnd
);
7592 memset(&startup
, 0, sizeof(startup
));
7593 startup
.cb
= sizeof(startup
);
7594 ok(CreateProcessA(NULL
, cmd
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
,
7595 &startup
, &info
), "CreateProcess failed.\n");
7596 ok(wait_for_event(start_event
, 1000), "didn't get start_event\n");
7598 child
= GetWindow(hwnd
, GW_CHILD
);
7599 win
= WindowFromPoint(pt
);
7600 ok(win
== child
, "WindowFromPoint returned %p, expected %p\n", win
, child
);
7602 simulate_click(150, 150);
7605 child
= GetWindow(child
, GW_HWNDNEXT
);
7607 win
= WindowFromPoint(pt
);
7608 ok(win
== child
, "WindowFromPoint returned %p, expected %p\n", win
, child
);
7610 SetEvent(end_event
);
7611 winetest_wait_child_process(info
.hProcess
);
7612 CloseHandle(start_event
);
7613 CloseHandle(end_event
);
7614 CloseHandle(info
.hProcess
);
7615 CloseHandle(info
.hThread
);
7617 DestroyWindow(hwnd
);
7620 static void test_map_points(void)
7624 HWND wnd
, wnd0
, dwnd
;
7627 POINT pos
= { 100, 200 };
7633 /* Create test windows */
7634 wnd
= CreateWindowA("static", "test1", WS_POPUP
, pos
.x
, pos
.y
, width
, height
, NULL
, NULL
, NULL
, NULL
);
7635 ok(wnd
!= NULL
, "Failed %p\n", wnd
);
7636 wnd0
= CreateWindowA("static", "test2", WS_POPUP
, 0, 0, width
, height
, NULL
, NULL
, NULL
, NULL
);
7637 ok(wnd0
!= NULL
, "Failed %p\n", wnd
);
7638 dwnd
= CreateWindowA("static", "test3", 0, 200, 300, 150, 150, NULL
, NULL
, NULL
, NULL
);
7639 DestroyWindow(dwnd
);
7640 ok(dwnd
!= NULL
, "Failed %p\n", dwnd
);
7642 /* Verify window rect and client rect (they should have the same width and height) */
7643 GetWindowRect(wnd
, &window_rect
);
7644 ok(window_rect
.left
== pos
.x
, "left is %d instead of %d\n", window_rect
.left
, pos
.x
);
7645 ok(window_rect
.top
== pos
.y
, "top is %d instead of %d\n", window_rect
.top
, pos
.y
);
7646 ok(window_rect
.right
== pos
.x
+ width
, "right is %d instead of %d\n", window_rect
.right
, pos
.x
+ width
);
7647 ok(window_rect
.bottom
== pos
.y
+ height
, "bottom is %d instead of %d\n", window_rect
.bottom
, pos
.y
+ height
);
7648 GetClientRect(wnd
, &client_rect
);
7649 ok(client_rect
.left
== 0, "left is %d instead of 0\n", client_rect
.left
);
7650 ok(client_rect
.top
== 0, "top is %d instead of 0\n", client_rect
.top
);
7651 ok(client_rect
.right
== width
, "right is %d instead of %d\n", client_rect
.right
, width
);
7652 ok(client_rect
.bottom
== height
, "bottom is %d instead of %d\n", client_rect
.bottom
, height
);
7654 /* Test MapWindowPoints */
7656 /* MapWindowPoints(NULL or wnd, NULL or wnd, NULL, 1); crashes on Windows */
7658 SetLastError(0xdeadbeef);
7659 n
= MapWindowPoints(NULL
, NULL
, NULL
, 0);
7660 err
= GetLastError();
7661 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7662 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7664 SetLastError(0xdeadbeef);
7665 n
= MapWindowPoints(wnd
, wnd
, NULL
, 0);
7666 err
= GetLastError();
7667 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7668 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7670 n
= MapWindowPoints(wnd
, NULL
, NULL
, 0);
7671 ok(n
== MAKELONG(window_rect
.left
, window_rect
.top
), "Got %x, expected %x\n",
7672 n
, MAKELONG(window_rect
.left
, window_rect
.top
));
7674 n
= MapWindowPoints(NULL
, wnd
, NULL
, 0);
7675 ok(n
== MAKELONG(-window_rect
.left
, -window_rect
.top
), "Got %x, expected %x\n",
7676 n
, MAKELONG(-window_rect
.left
, -window_rect
.top
));
7678 SetLastError(0xdeadbeef);
7680 n
= MapWindowPoints(dwnd
, NULL
, &p
, 1);
7681 err
= GetLastError();
7682 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7683 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7684 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7686 SetLastError(0xdeadbeef);
7688 n
= MapWindowPoints(dwnd
, wnd
, &p
, 1);
7689 err
= GetLastError();
7690 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7691 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7692 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7694 SetLastError(0xdeadbeef);
7696 n
= MapWindowPoints(NULL
, dwnd
, &p
, 1);
7697 err
= GetLastError();
7698 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7699 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7700 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7702 SetLastError(0xdeadbeef);
7704 n
= MapWindowPoints(wnd
, dwnd
, &p
, 1);
7705 err
= GetLastError();
7706 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7707 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7708 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7710 SetLastError(0xdeadbeef);
7712 n
= MapWindowPoints(dwnd
, dwnd
, &p
, 1);
7713 err
= GetLastError();
7714 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7715 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7716 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7718 SetLastError(0xdeadbeef);
7720 n
= MapWindowPoints(NULL
, NULL
, &p
, 1);
7721 err
= GetLastError();
7722 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7723 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7724 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7726 SetLastError(0xdeadbeef);
7728 n
= MapWindowPoints(wnd
, wnd
, &p
, 1);
7729 err
= GetLastError();
7730 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7731 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7732 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7735 n
= MapWindowPoints(wnd
, NULL
, &p
, 1);
7736 ok(n
== MAKELONG(window_rect
.left
, window_rect
.top
), "Got %x, expected %x\n",
7737 n
, MAKELONG(window_rect
.left
, window_rect
.top
));
7738 ok((p
.x
== (window_rect
.left
+ 100)) && (p
.y
== (window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
7739 p
.x
, p
.y
, window_rect
.left
+ 100, window_rect
.top
+ 100);
7742 n
= MapWindowPoints(NULL
, wnd
, &p
, 1);
7743 ok(n
== MAKELONG(-window_rect
.left
, -window_rect
.top
), "Got %x, expected %x\n",
7744 n
, MAKELONG(-window_rect
.left
, -window_rect
.top
));
7745 ok((p
.x
== (-window_rect
.left
+ 100)) && (p
.y
== (-window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
7746 p
.x
, p
.y
, -window_rect
.left
+ 100, -window_rect
.top
+ 100);
7748 SetLastError(0xdeadbeef);
7750 n
= MapWindowPoints(wnd0
, NULL
, &p
, 1);
7751 err
= GetLastError();
7752 ok(n
== 0, "Got %x, expected 0\n", n
);
7753 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7754 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7756 SetLastError(0xdeadbeef);
7758 n
= MapWindowPoints(NULL
, wnd0
, &p
, 1);
7759 err
= GetLastError();
7760 ok(n
== 0, "Got %x, expected 0\n", n
);
7761 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7762 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7764 /* Test ClientToScreen */
7766 /* ClientToScreen(wnd, NULL); crashes on Windows */
7768 SetLastError(0xdeadbeef);
7769 ret
= ClientToScreen(NULL
, NULL
);
7770 err
= GetLastError();
7771 ok(!ret
, "Should fail\n");
7772 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7774 SetLastError(0xdeadbeef);
7776 ret
= ClientToScreen(NULL
, &p
);
7777 err
= GetLastError();
7778 ok(!ret
, "Should fail\n");
7779 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7780 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7782 SetLastError(0xdeadbeef);
7784 ret
= ClientToScreen(dwnd
, &p
);
7785 err
= GetLastError();
7786 ok(!ret
, "Should fail\n");
7787 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7788 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7791 ret
= ClientToScreen(wnd
, &p
);
7792 ok(ret
, "Failed with error %u\n", GetLastError());
7793 ok((p
.x
== (window_rect
.left
+ 100)) && (p
.y
== (window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
7794 p
.x
, p
.y
, window_rect
.left
+ 100, window_rect
.top
+ 100);
7797 ret
= ClientToScreen(wnd0
, &p
);
7798 ok(ret
, "Failed with error %u\n", GetLastError());
7799 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7801 /* Test ScreenToClient */
7803 /* ScreenToClient(wnd, NULL); crashes on Windows */
7805 SetLastError(0xdeadbeef);
7806 ret
= ScreenToClient(NULL
, NULL
);
7807 err
= GetLastError();
7808 ok(!ret
, "Should fail\n");
7809 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7811 SetLastError(0xdeadbeef);
7813 ret
= ScreenToClient(NULL
, &p
);
7814 err
= GetLastError();
7815 ok(!ret
, "Should fail\n");
7816 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7817 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7819 SetLastError(0xdeadbeef);
7821 ret
= ScreenToClient(dwnd
, &p
);
7822 err
= GetLastError();
7823 ok(!ret
, "Should fail\n");
7824 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7825 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7828 ret
= ScreenToClient(wnd
, &p
);
7829 ok(ret
, "Failed with error %u\n", GetLastError());
7830 ok((p
.x
== (-window_rect
.left
+ 100)) && (p
.y
== (-window_rect
.top
+ 100)), "Failed got(%d, %d), expected (%d, %d)\n",
7831 p
.x
, p
.y
, -window_rect
.left
+ 100, -window_rect
.top
+ 100);
7834 ret
= ScreenToClient(wnd0
, &p
);
7835 ok(ret
, "Failed with error %u\n", GetLastError());
7836 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7839 DestroyWindow(wnd0
);
7842 static void test_update_region(void)
7844 HWND hwnd
, parent
, child
;
7846 const RECT rc
= {15, 15, 40, 40};
7847 const POINT wnd_orig
= {30, 20};
7848 const POINT child_orig
= {10, 5};
7850 parent
= CreateWindowExA(0, "MainWindowClass", NULL
,
7851 WS_VISIBLE
| WS_CLIPCHILDREN
,
7852 0, 0, 300, 150, NULL
, NULL
, GetModuleHandleA(0), 0);
7853 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
7854 WS_VISIBLE
| WS_CLIPCHILDREN
| WS_CHILD
,
7855 0, 0, 200, 100, parent
, NULL
, GetModuleHandleA(0), 0);
7856 child
= CreateWindowExA(0, "MainWindowClass", NULL
,
7857 WS_VISIBLE
| WS_CHILD
,
7858 child_orig
.x
, child_orig
.y
, 100, 50,
7859 hwnd
, NULL
, GetModuleHandleA(0), 0);
7860 assert(parent
&& hwnd
&& child
);
7862 ValidateRgn(parent
, NULL
);
7863 ValidateRgn(hwnd
, NULL
);
7864 InvalidateRect(hwnd
, &rc
, FALSE
);
7865 ValidateRgn(child
, NULL
);
7867 rgn1
= CreateRectRgn(0, 0, 0, 0);
7868 ok(GetUpdateRgn(parent
, rgn1
, FALSE
) == NULLREGION
,
7869 "has invalid area after ValidateRgn(NULL)\n");
7870 GetUpdateRgn(hwnd
, rgn1
, FALSE
);
7871 rgn2
= CreateRectRgnIndirect(&rc
);
7872 ok(EqualRgn(rgn1
, rgn2
), "assigned and retrieved update regions are different\n");
7873 ok(GetUpdateRgn(child
, rgn2
, FALSE
) == NULLREGION
,
7874 "has invalid area after ValidateRgn(NULL)\n");
7876 SetWindowPos(hwnd
, 0, wnd_orig
.x
, wnd_orig
.y
, 0, 0,
7877 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOSIZE
);
7879 /* parent now has non-simple update region, it consist of
7880 * two rects, that was exposed after hwnd moving ... */
7881 SetRectRgn(rgn1
, 0, 0, 200, wnd_orig
.y
);
7882 SetRectRgn(rgn2
, 0, 0, wnd_orig
.x
, 100);
7883 CombineRgn(rgn1
, rgn1
, rgn2
, RGN_OR
);
7884 /* ... and mapped hwnd's invalid area, that hwnd has before moving */
7885 SetRectRgn(rgn2
, rc
.left
+ wnd_orig
.x
, rc
.top
+ wnd_orig
.y
,
7886 rc
.right
+ wnd_orig
.x
, rc
.bottom
+ wnd_orig
.y
);
7887 CombineRgn(rgn1
, rgn1
, rgn2
, RGN_OR
);
7888 GetUpdateRgn(parent
, rgn2
, FALSE
);
7890 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
7892 /* hwnd has the same invalid region as before moving */
7893 SetRectRgn(rgn1
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
7894 GetUpdateRgn(hwnd
, rgn2
, FALSE
);
7895 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
7897 /* hwnd's invalid area maps to child during moving */
7898 SetRectRgn(rgn1
, rc
.left
- child_orig
.x
, rc
.top
- child_orig
.y
,
7899 rc
.right
- child_orig
.x
, rc
.bottom
- child_orig
.y
);
7900 GetUpdateRgn(child
, rgn2
, FALSE
);
7902 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
7906 DestroyWindow(parent
);
7909 static void test_window_without_child_style(void)
7913 hwnd
= CreateWindowExA(0, "edit", NULL
, WS_VISIBLE
|WS_CHILD
,
7914 0, 0, 50, 50, hwndMain
, NULL
, 0, NULL
);
7915 ok(hwnd
!= NULL
, "CreateWindow failed\n");
7917 ok(SetWindowLongA(hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) & (~WS_CHILD
)),
7918 "can't remove WS_CHILD style\n");
7920 SetActiveWindow(hwndMain
);
7921 PostMessageW(hwnd
, WM_LBUTTONUP
, 0, 0);
7922 SendMessageW(hwnd
, WM_NCLBUTTONDOWN
, HTCAPTION
, 0);
7923 check_active_state(hwnd
, hwnd
, hwnd
);
7926 DestroyWindow(hwnd
);
7930 struct smresult_thread_data
7934 HANDLE thread_started
;
7935 HANDLE thread_got_wm_app
;
7936 HANDLE main_in_wm_app_1
;
7937 HANDLE thread_replied
;
7941 static LRESULT WINAPI
smresult_wndproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
7947 struct smresult_thread_data
*data
= (struct smresult_thread_data
*)lparam
;
7949 ok(hwnd
== data
->thread_hwnd
, "unexpected hwnd %p\n", hwnd
);
7951 SendNotifyMessageA(data
->main_hwnd
, WM_APP
+1, 0, lparam
);
7953 /* Don't return until the main thread is processing our sent message. */
7954 ok(WaitForSingleObject(data
->main_in_wm_app_1
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7956 /* Break the PeekMessage loop so we can notify the main thread after we return. */
7957 SetEvent(data
->thread_got_wm_app
);
7963 struct smresult_thread_data
*data
= (struct smresult_thread_data
*)lparam
;
7966 ok(hwnd
== data
->main_hwnd
, "unexpected hwnd %p\n", hwnd
);
7968 /* Ask the thread to reply to our WM_APP message. */
7969 SetEvent(data
->main_in_wm_app_1
);
7971 /* Wait until the thread has sent a reply. */
7972 ok(WaitForSingleObject(data
->thread_replied
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
7974 /* Send another message while we have a reply queued for the current one. */
7975 res
= SendMessageA(data
->thread_hwnd
, WM_APP
+2, 0, lparam
);
7976 ok(res
== 0x449b0190, "unexpected result %lx\n", res
);
7982 struct smresult_thread_data
*data
= (struct smresult_thread_data
*)lparam
;
7984 ok(hwnd
== data
->thread_hwnd
, "unexpected hwnd %p\n", hwnd
);
7986 /* Don't return until we know the main thread is processing sent messages. */
7987 SendMessageA(data
->main_hwnd
, WM_NULL
, 0, 0);
7995 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
7998 static DWORD WINAPI
smresult_thread_proc(void *param
)
8001 struct smresult_thread_data
*data
= param
;
8003 data
->thread_hwnd
= CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW
,
8004 100, 100, 200, 200, 0, 0, 0, NULL
);
8005 ok(data
->thread_hwnd
!= 0, "Failed to create overlapped window\n");
8007 SetEvent(data
->thread_started
);
8009 /* Loop until we've processed WM_APP. */
8010 while (WaitForSingleObject(data
->thread_got_wm_app
, 0) != WAIT_OBJECT_0
)
8012 if (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
8014 TranslateMessage(&msg
);
8015 DispatchMessageA(&msg
);
8019 MsgWaitForMultipleObjects(1, &data
->thread_got_wm_app
, FALSE
, INFINITE
, QS_SENDMESSAGE
);
8023 /* Notify the main thread that we replied to its WM_APP message. */
8024 SetEvent(data
->thread_replied
);
8026 while (GetMessageA(&msg
, 0, 0, 0))
8028 TranslateMessage(&msg
);
8029 DispatchMessageA(&msg
);
8035 static void test_smresult(void)
8040 struct smresult_thread_data data
;
8044 cls
.style
= CS_DBLCLKS
;
8045 cls
.lpfnWndProc
= smresult_wndproc
;
8048 cls
.hInstance
= GetModuleHandleA(0);
8050 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
8051 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
8052 cls
.lpszMenuName
= NULL
;
8053 cls
.lpszClassName
= "SmresultClass";
8055 ret
= RegisterClassA(&cls
);
8056 ok(ret
, "RegisterClassA failed\n");
8058 data
.thread_started
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
8059 ok(data
.thread_started
!= NULL
, "CreateEventA failed\n");
8061 data
.thread_got_wm_app
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
8062 ok(data
.thread_got_wm_app
!= NULL
, "CreateEventA failed\n");
8064 data
.main_in_wm_app_1
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
8065 ok(data
.main_in_wm_app_1
!= NULL
, "CreateEventA failed\n");
8067 data
.thread_replied
= CreateEventA(NULL
, TRUE
, FALSE
, NULL
);
8068 ok(data
.thread_replied
!= NULL
, "CreateEventA failed\n");
8070 data
.main_hwnd
= CreateWindowExA(0, "SmresultClass", "window caption text", WS_OVERLAPPEDWINDOW
,
8071 100, 100, 200, 200, 0, 0, 0, NULL
);
8073 hThread
= CreateThread(NULL
, 0, smresult_thread_proc
, &data
, 0, &tid
);
8074 ok(hThread
!= NULL
, "CreateThread failed, error %d\n", GetLastError());
8076 ok(WaitForSingleObject(data
.thread_started
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8078 res
= SendMessageA(data
.thread_hwnd
, WM_APP
, 0, (LPARAM
)&data
);
8079 ok(res
== 0x240408ea, "unexpected result %lx\n", res
);
8081 SendMessageA(data
.thread_hwnd
, WM_CLOSE
, 0, 0);
8083 DestroyWindow(data
.main_hwnd
);
8085 ok(WaitForSingleObject(hThread
, INFINITE
) == WAIT_OBJECT_0
, "WaitForSingleObject failed\n");
8087 CloseHandle(data
.thread_started
);
8088 CloseHandle(data
.thread_got_wm_app
);
8089 CloseHandle(data
.main_in_wm_app_1
);
8090 CloseHandle(data
.thread_replied
);
8093 static void test_GetMessagePos(void)
8099 button
= CreateWindowExA(0, "button", "button", WS_VISIBLE
,
8100 100, 100, 100, 100, 0, 0, 0, NULL
);
8101 ok(button
!= 0, "CreateWindowExA failed\n");
8103 SetCursorPos(120, 140);
8105 pos
= GetMessagePos();
8106 ok(pos
== MAKELONG(120, 140), "pos = %08x\n", pos
);
8108 SetCursorPos(340, 320);
8109 pos
= GetMessagePos();
8110 ok(pos
== MAKELONG(120, 140), "pos = %08x\n", pos
);
8112 SendMessageW(button
, WM_APP
, 0, 0);
8113 pos
= GetMessagePos();
8114 ok(pos
== MAKELONG(120, 140), "pos = %08x\n", pos
);
8116 PostMessageA(button
, WM_APP
, 0, 0);
8117 GetMessageA(&msg
, button
, 0, 0);
8118 ok(msg
.message
== WM_APP
, "msg.message = %x\n", msg
.message
);
8119 pos
= GetMessagePos();
8120 ok(pos
== MAKELONG(340, 320), "pos = %08x\n", pos
);
8122 PostMessageA(button
, WM_APP
, 0, 0);
8123 SetCursorPos(350, 330);
8124 GetMessageA(&msg
, button
, 0, 0);
8125 ok(msg
.message
== WM_APP
, "msg.message = %x\n", msg
.message
);
8126 pos
= GetMessagePos();
8127 ok(pos
== MAKELONG(340, 320), "pos = %08x\n", pos
);
8129 PostMessageA(button
, WM_APP
, 0, 0);
8130 SetCursorPos(320, 340);
8131 PostMessageA(button
, WM_APP
+1, 0, 0);
8132 pos
= GetMessagePos();
8133 ok(pos
== MAKELONG(340, 320), "pos = %08x\n", pos
);
8134 GetMessageA(&msg
, button
, 0, 0);
8135 ok(msg
.message
== WM_APP
, "msg.message = %x\n", msg
.message
);
8136 pos
= GetMessagePos();
8137 ok(pos
== MAKELONG(350, 330), "pos = %08x\n", pos
);
8138 GetMessageA(&msg
, button
, 0, 0);
8139 ok(msg
.message
== WM_APP
+1, "msg.message = %x\n", msg
.message
);
8140 pos
= GetMessagePos();
8141 ok(pos
== MAKELONG(320, 340), "pos = %08x\n", pos
);
8143 SetTimer(button
, 1, 250, NULL
);
8144 SetCursorPos(330, 350);
8145 GetMessageA(&msg
, button
, 0, 0);
8146 while (msg
.message
== WM_PAINT
)
8148 UpdateWindow( button
);
8149 GetMessageA(&msg
, button
, 0, 0);
8151 ok(msg
.message
== WM_TIMER
, "msg.message = %x\n", msg
.message
);
8152 pos
= GetMessagePos();
8153 ok(pos
== MAKELONG(330, 350), "pos = %08x\n", pos
);
8154 KillTimer(button
, 1);
8156 DestroyWindow(button
);
8162 int argc
= winetest_get_mainargs( &argv
);
8163 HMODULE user32
= GetModuleHandleA( "user32.dll" );
8164 HMODULE gdi32
= GetModuleHandleA("gdi32.dll");
8165 pGetAncestor
= (void *)GetProcAddress( user32
, "GetAncestor" );
8166 pGetWindowInfo
= (void *)GetProcAddress( user32
, "GetWindowInfo" );
8167 pGetWindowModuleFileNameA
= (void *)GetProcAddress( user32
, "GetWindowModuleFileNameA" );
8168 pGetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "GetLayeredWindowAttributes" );
8169 pSetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "SetLayeredWindowAttributes" );
8170 pUpdateLayeredWindow
= (void *)GetProcAddress( user32
, "UpdateLayeredWindow" );
8171 pUpdateLayeredWindowIndirect
= (void *)GetProcAddress( user32
, "UpdateLayeredWindowIndirect" );
8172 pGetMonitorInfoA
= (void *)GetProcAddress( user32
, "GetMonitorInfoA" );
8173 pMonitorFromPoint
= (void *)GetProcAddress( user32
, "MonitorFromPoint" );
8174 pGetWindowRgnBox
= (void *)GetProcAddress( user32
, "GetWindowRgnBox" );
8175 pGetGUIThreadInfo
= (void *)GetProcAddress( user32
, "GetGUIThreadInfo" );
8176 pGetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "GetProcessDefaultLayout" );
8177 pSetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "SetProcessDefaultLayout" );
8178 pFlashWindowEx
= (void *)GetProcAddress( user32
, "FlashWindowEx" );
8179 pGetLayout
= (void *)GetProcAddress( gdi32
, "GetLayout" );
8180 pSetLayout
= (void *)GetProcAddress( gdi32
, "SetLayout" );
8181 pMirrorRgn
= (void *)GetProcAddress( gdi32
, "MirrorRgn" );
8183 if (argc
==4 && !strcmp(argv
[2], "create_children"))
8187 sscanf(argv
[3], "%p", &hwnd
);
8188 window_from_point_proc(hwnd
);
8192 if (!RegisterWindowClasses()) assert(0);
8194 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
8195 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
8196 WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
,
8198 0, 0, GetModuleHandleA(NULL
), NULL
);
8201 if(!SetForegroundWindow(hwndMain
)) {
8202 /* workaround for foreground lock timeout */
8203 simulate_click(101, 101);
8204 ok(SetForegroundWindow(hwndMain
), "SetForegroundWindow failed\n");
8207 SetLastError(0xdeafbeef);
8208 GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC
);
8209 is_win9x
= (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
);
8211 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
8212 if (!hhook
) win_skip( "Cannot set CBT hook, skipping some tests\n" );
8214 /* make sure that these tests are executed first */
8215 test_FindWindowEx();
8218 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
8219 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
8220 WS_MAXIMIZEBOX
| WS_POPUP
,
8222 0, 0, GetModuleHandleA(NULL
), NULL
);
8223 assert( hwndMain2
);
8225 our_pid
= GetWindowThreadProcessId(hwndMain
, NULL
);
8227 /* Add the tests below this line */
8228 test_child_window_from_point();
8229 test_window_from_point(argv
[0]);
8230 test_thick_child_size(hwndMain
);
8232 test_hwnd_message();
8233 test_nonclient_area(hwndMain
);
8235 test_GetWindowModuleFileName();
8238 test_capture_3(hwndMain
, hwndMain2
);
8241 test_FlashWindowEx();
8243 test_CreateWindow();
8244 test_parent_owner();
8245 test_enum_thread_windows();
8249 test_SetWindowPos(hwndMain
, hwndMain2
);
8250 test_SetMenu(hwndMain
);
8251 test_SetFocus(hwndMain
);
8252 test_SetActiveWindow(hwndMain
);
8255 test_children_zorder(hwndMain
);
8256 test_popup_zorder(hwndMain2
, hwndMain
, WS_POPUP
);
8257 test_popup_zorder(hwndMain2
, hwndMain
, 0);
8258 test_GetLastActivePopup();
8259 test_keyboard_input(hwndMain
);
8260 test_mouse_input(hwndMain
);
8261 test_validatergn(hwndMain
);
8262 test_nccalcscroll( hwndMain
);
8263 test_scrollwindow( hwndMain
);
8264 test_scrollvalidate( hwndMain
);
8265 test_scrolldc( hwndMain
);
8267 test_IsWindowUnicode();
8268 test_vis_rgn(hwndMain
);
8270 test_AdjustWindowRect();
8271 test_window_styles();
8272 test_dialog_styles();
8275 test_SetWindowLong();
8278 test_GetUpdateRect();
8280 test_layered_window();
8282 test_SetForegroundWindow(hwndMain
);
8283 test_shell_window();
8284 test_handles( hwndMain
);
8287 test_update_region();
8288 test_window_without_child_style();
8290 test_GetMessagePos();
8292 /* add the tests above this line */
8293 if (hhook
) UnhookWindowsHookEx(hhook
);
8295 DestroyWindow(hwndMain2
);
8296 DestroyWindow(hwndMain
);