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 HWND hwndMessage
;
67 static HWND hwndMain
, hwndMain2
;
70 static const char* szAWRClass
= "Winsize";
74 static BOOL is_win9x
= FALSE
;
76 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
78 static void dump_minmax_info( const MINMAXINFO
*minmax
)
80 trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
81 minmax
->ptReserved
.x
, minmax
->ptReserved
.y
,
82 minmax
->ptMaxSize
.x
, minmax
->ptMaxSize
.y
,
83 minmax
->ptMaxPosition
.x
, minmax
->ptMaxPosition
.y
,
84 minmax
->ptMinTrackSize
.x
, minmax
->ptMinTrackSize
.y
,
85 minmax
->ptMaxTrackSize
.x
, minmax
->ptMaxTrackSize
.y
);
88 /* try to make sure pending X events have been processed before continuing */
89 static void flush_events( BOOL remove_messages
)
93 int min_timeout
= 100;
94 DWORD time
= GetTickCount() + diff
;
98 if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, min_timeout
, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
100 while (PeekMessageA( &msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA( &msg
);
101 diff
= time
- GetTickCount();
106 /* check the values returned by the various parent/owner functions on a given window */
107 static void check_parents( HWND hwnd
, HWND ga_parent
, HWND gwl_parent
, HWND get_parent
,
108 HWND gw_owner
, HWND ga_root
, HWND ga_root_owner
)
114 res
= pGetAncestor( hwnd
, GA_PARENT
);
115 ok( res
== ga_parent
, "Wrong result for GA_PARENT %p expected %p\n", res
, ga_parent
);
117 res
= (HWND
)GetWindowLongPtrA( hwnd
, GWLP_HWNDPARENT
);
118 ok( res
== gwl_parent
, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res
, gwl_parent
);
119 res
= GetParent( hwnd
);
120 ok( res
== get_parent
, "Wrong result for GetParent %p expected %p\n", res
, get_parent
);
121 res
= GetWindow( hwnd
, GW_OWNER
);
122 ok( res
== gw_owner
, "Wrong result for GW_OWNER %p expected %p\n", res
, gw_owner
);
125 res
= pGetAncestor( hwnd
, GA_ROOT
);
126 ok( res
== ga_root
, "Wrong result for GA_ROOT %p expected %p\n", res
, ga_root
);
127 res
= pGetAncestor( hwnd
, GA_ROOTOWNER
);
128 ok( res
== ga_root_owner
, "Wrong result for GA_ROOTOWNER %p expected %p\n", res
, ga_root_owner
);
132 #define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
133 static void check_wnd_state_(const char *file
, int line
,
134 HWND active
, HWND foreground
, HWND focus
, HWND capture
)
136 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
137 /* only check foreground if it belongs to the current thread */
138 /* foreground can be moved to a different app pretty much at any time */
139 if (foreground
&& GetForegroundWindow() &&
140 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
141 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
142 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
143 ok_(file
, line
)(capture
== GetCapture(), "GetCapture() = %p\n", GetCapture());
146 /* same as above but without capture test */
147 #define check_active_state(a,b,c) check_active_state_(__FILE__,__LINE__,a,b,c)
148 static void check_active_state_(const char *file
, int line
,
149 HWND active
, HWND foreground
, HWND focus
)
151 ok_(file
, line
)(active
== GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
152 /* only check foreground if it belongs to the current thread */
153 /* foreground can be moved to a different app pretty much at any time */
154 if (foreground
&& GetForegroundWindow() &&
155 GetWindowThreadProcessId(GetForegroundWindow(), NULL
) == GetCurrentThreadId())
156 ok_(file
, line
)(foreground
== GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
157 ok_(file
, line
)(focus
== GetFocus(), "GetFocus() = %p\n", GetFocus());
160 static BOOL
ignore_message( UINT message
)
162 /* these are always ignored */
163 return (message
>= 0xc000 ||
164 message
== WM_GETICON
||
165 message
== WM_GETOBJECT
||
166 message
== WM_TIMECHANGE
||
167 message
== WM_DEVICECHANGE
);
170 static BOOL CALLBACK
EnumChildProc( HWND hwndChild
, LPARAM lParam
)
173 trace("EnumChildProc on %p\n", hwndChild
);
174 if (*(LPINT
)lParam
> 1) return FALSE
;
178 /* will search for the given window */
179 static BOOL CALLBACK
EnumChildProc1( HWND hwndChild
, LPARAM lParam
)
181 trace("EnumChildProc1 on %p\n", hwndChild
);
182 if ((HWND
)lParam
== hwndChild
) return FALSE
;
186 static HWND
create_tool_window( LONG style
, HWND parent
)
188 HWND ret
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style
,
189 0, 0, 100, 100, parent
, 0, 0, NULL
);
190 ok( ret
!= 0, "Creation failed\n" );
194 /* test parent and owner values for various combinations */
195 static void test_parent_owner(void)
198 HWND test
, owner
, ret
;
199 HWND desktop
= GetDesktopWindow();
200 HWND child
= create_tool_window( WS_CHILD
, hwndMain
);
203 trace( "main window %p main2 %p desktop %p child %p\n", hwndMain
, hwndMain2
, desktop
, child
);
205 /* child without parent, should fail */
206 SetLastError(0xdeadbeef);
207 test
= CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
208 WS_CHILD
, 0, 0, 100, 100, 0, 0, 0, NULL
);
209 ok( !test
, "WS_CHILD without parent created\n" );
210 ok( GetLastError() == ERROR_TLW_WITH_WSCHILD
||
211 broken(GetLastError() == 0xdeadbeef), /* win9x */
212 "CreateWindowExA error %u\n", GetLastError() );
215 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
216 style
= GetWindowLongA( desktop
, GWL_STYLE
);
217 ok( !SetWindowLongA( desktop
, GWL_STYLE
, WS_POPUP
), "Set GWL_STYLE on desktop succeeded\n" );
218 ok( !SetWindowLongA( desktop
, GWL_STYLE
, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
219 ok( GetWindowLongA( desktop
, GWL_STYLE
) == style
, "Desktop style changed\n" );
221 /* normal child window */
222 test
= create_tool_window( WS_CHILD
, hwndMain
);
223 trace( "created child %p\n", test
);
224 check_parents( test
, hwndMain
, hwndMain
, hwndMain
, 0, hwndMain
, hwndMain
);
225 SetWindowLongA( test
, GWL_STYLE
, 0 );
226 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
227 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
228 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
229 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
230 check_parents( test
, hwndMain
, hwndMain
, 0, 0, hwndMain
, test
);
231 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
232 DestroyWindow( test
);
234 /* normal child window with WS_MAXIMIZE */
235 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
236 DestroyWindow( test
);
238 /* normal child window with WS_THICKFRAME */
239 test
= create_tool_window( WS_CHILD
| WS_THICKFRAME
, hwndMain
);
240 DestroyWindow( test
);
242 /* popup window with WS_THICKFRAME */
243 test
= create_tool_window( WS_POPUP
| WS_THICKFRAME
, hwndMain
);
244 DestroyWindow( test
);
246 /* child of desktop */
247 test
= create_tool_window( WS_CHILD
, desktop
);
248 trace( "created child of desktop %p\n", test
);
249 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
250 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
251 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
252 SetWindowLongA( test
, GWL_STYLE
, 0 );
253 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
254 DestroyWindow( test
);
256 /* child of desktop with WS_MAXIMIZE */
257 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, desktop
);
258 DestroyWindow( test
);
260 /* child of desktop with WS_MINIMIZE */
261 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, desktop
);
262 DestroyWindow( test
);
265 test
= create_tool_window( WS_CHILD
, child
);
266 trace( "created child of child %p\n", test
);
267 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
268 SetWindowLongA( test
, GWL_STYLE
, 0 );
269 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
270 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
271 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
272 DestroyWindow( test
);
274 /* child of child with WS_MAXIMIZE */
275 test
= create_tool_window( WS_CHILD
| WS_MAXIMIZE
, child
);
276 DestroyWindow( test
);
278 /* child of child with WS_MINIMIZE */
279 test
= create_tool_window( WS_CHILD
| WS_MINIMIZE
, child
);
280 DestroyWindow( test
);
282 /* not owned top-level window */
283 test
= create_tool_window( 0, 0 );
284 trace( "created top-level %p\n", test
);
285 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
286 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
287 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
288 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
289 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
290 DestroyWindow( test
);
292 /* not owned top-level window with WS_MAXIMIZE */
293 test
= create_tool_window( WS_MAXIMIZE
, 0 );
294 DestroyWindow( test
);
296 /* owned top-level window */
297 test
= create_tool_window( 0, hwndMain
);
298 trace( "created owned top-level %p\n", test
);
299 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
300 SetWindowLongA( test
, GWL_STYLE
, WS_POPUP
);
301 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
302 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
303 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
304 DestroyWindow( test
);
306 /* owned top-level window with WS_MAXIMIZE */
307 test
= create_tool_window( WS_MAXIMIZE
, hwndMain
);
308 DestroyWindow( test
);
310 /* not owned popup */
311 test
= create_tool_window( WS_POPUP
, 0 );
312 trace( "created popup %p\n", test
);
313 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
314 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
315 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
316 SetWindowLongA( test
, GWL_STYLE
, 0 );
317 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
318 DestroyWindow( test
);
320 /* not owned popup with WS_MAXIMIZE */
321 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, 0 );
322 DestroyWindow( test
);
325 test
= create_tool_window( WS_POPUP
, hwndMain
);
326 trace( "created owned popup %p\n", test
);
327 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
328 SetWindowLongA( test
, GWL_STYLE
, WS_CHILD
);
329 check_parents( test
, desktop
, hwndMain
, desktop
, hwndMain
, test
, desktop
);
330 SetWindowLongA( test
, GWL_STYLE
, 0 );
331 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
332 DestroyWindow( test
);
334 /* owned popup with WS_MAXIMIZE */
335 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, hwndMain
);
336 DestroyWindow( test
);
338 /* top-level window owned by child (same as owned by top-level) */
339 test
= create_tool_window( 0, child
);
340 trace( "created top-level owned by child %p\n", test
);
341 check_parents( test
, desktop
, hwndMain
, 0, hwndMain
, test
, test
);
342 DestroyWindow( test
);
344 /* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
345 test
= create_tool_window( WS_MAXIMIZE
, child
);
346 DestroyWindow( test
);
348 /* popup owned by desktop (same as not owned) */
349 test
= create_tool_window( WS_POPUP
, desktop
);
350 trace( "created popup owned by desktop %p\n", test
);
351 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
352 DestroyWindow( test
);
354 /* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
355 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, desktop
);
356 DestroyWindow( test
);
358 /* popup owned by child (same as owned by top-level) */
359 test
= create_tool_window( WS_POPUP
, child
);
360 trace( "created popup owned by child %p\n", test
);
361 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
362 DestroyWindow( test
);
364 /* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
365 test
= create_tool_window( WS_POPUP
| WS_MAXIMIZE
, child
);
366 DestroyWindow( test
);
368 /* not owned popup with WS_CHILD (same as WS_POPUP only) */
369 test
= create_tool_window( WS_POPUP
| WS_CHILD
, 0 );
370 trace( "created WS_CHILD popup %p\n", test
);
371 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
372 DestroyWindow( test
);
374 /* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
375 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, 0 );
376 DestroyWindow( test
);
378 /* owned popup with WS_CHILD (same as WS_POPUP only) */
379 test
= create_tool_window( WS_POPUP
| WS_CHILD
, hwndMain
);
380 trace( "created owned WS_CHILD popup %p\n", test
);
381 check_parents( test
, desktop
, hwndMain
, hwndMain
, hwndMain
, test
, hwndMain
);
382 DestroyWindow( test
);
384 /* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
385 test
= create_tool_window( WS_POPUP
| WS_CHILD
| WS_MAXIMIZE
, hwndMain
);
386 DestroyWindow( test
);
388 /******************** parent changes *************************/
389 trace( "testing parent changes\n" );
392 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
395 /* this test succeeds on NT but crashes on win9x systems */
396 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
397 ok( !ret
, "Set GWL_HWNDPARENT succeeded on desktop\n" );
398 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
399 ok( !SetParent( desktop
, hwndMain
), "SetParent succeeded on desktop\n" );
400 check_parents( desktop
, 0, 0, 0, 0, 0, 0 );
402 /* normal child window */
403 test
= create_tool_window( WS_CHILD
, hwndMain
);
404 trace( "created child %p\n", test
);
406 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
407 ok( ret
== hwndMain
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain
);
408 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
410 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
411 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
412 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
414 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)desktop
);
415 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
416 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
418 /* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
421 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)test
);
422 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
423 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
426 win_skip("Test creates circular window tree under Win9x/WinMe\n" );
428 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
429 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
430 check_parents( test
, desktop
, child
, desktop
, child
, test
, desktop
);
432 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
433 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
434 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
435 DestroyWindow( test
);
437 /* not owned top-level window */
438 test
= create_tool_window( 0, 0 );
439 trace( "created top-level %p\n", test
);
441 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
442 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
443 check_parents( test
, desktop
, hwndMain2
, 0, hwndMain2
, test
, test
);
445 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
446 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
447 check_parents( test
, desktop
, child
, 0, child
, test
, test
);
449 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
450 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
451 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
452 DestroyWindow( test
);
454 /* not owned popup */
455 test
= create_tool_window( WS_POPUP
, 0 );
456 trace( "created popup %p\n", test
);
458 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)hwndMain2
);
459 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
460 check_parents( test
, desktop
, hwndMain2
, hwndMain2
, hwndMain2
, test
, hwndMain2
);
462 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (LONG_PTR
)child
);
463 ok( ret
== hwndMain2
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, hwndMain2
);
464 check_parents( test
, desktop
, child
, child
, child
, test
, hwndMain
);
466 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, 0 );
467 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
468 check_parents( test
, desktop
, 0, 0, 0, test
, test
);
469 DestroyWindow( test
);
471 /* normal child window */
472 test
= create_tool_window( WS_CHILD
, hwndMain
);
473 trace( "created child %p\n", test
);
475 ret
= SetParent( test
, desktop
);
476 ok( ret
== hwndMain
, "SetParent return value %p expected %p\n", ret
, hwndMain
);
477 check_parents( test
, desktop
, 0, desktop
, 0, test
, desktop
);
479 ret
= SetParent( test
, child
);
480 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
481 check_parents( test
, child
, child
, child
, 0, hwndMain
, hwndMain
);
483 ret
= SetParent( test
, hwndMain2
);
484 ok( ret
== child
, "SetParent return value %p expected %p\n", ret
, child
);
485 check_parents( test
, hwndMain2
, hwndMain2
, hwndMain2
, 0, hwndMain2
, hwndMain2
);
486 DestroyWindow( test
);
488 /* not owned top-level window */
489 test
= create_tool_window( 0, 0 );
490 trace( "created top-level %p\n", test
);
492 ret
= SetParent( test
, child
);
493 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
494 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
498 ShowWindow( test
, SW_SHOW
);
499 ret
= SetParent( test
, test
);
500 ok( ret
== NULL
, "SetParent return value %p expected %p\n", ret
, NULL
);
501 ok( GetWindowLongA( test
, GWL_STYLE
) & WS_VISIBLE
, "window is not visible after SetParent\n" );
502 check_parents( test
, child
, child
, 0, 0, hwndMain
, test
);
505 win_skip( "Test crashes on Win9x/WinMe\n" );
506 DestroyWindow( test
);
509 test
= create_tool_window( WS_POPUP
, hwndMain2
);
510 trace( "created owned popup %p\n", test
);
512 ret
= SetParent( test
, child
);
513 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
514 check_parents( test
, child
, child
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
516 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)hwndMain
);
517 ok( ret
== child
, "GWL_HWNDPARENT return value %p expected %p\n", ret
, child
);
518 check_parents( test
, hwndMain
, hwndMain
, hwndMain2
, hwndMain2
, hwndMain
, hwndMain2
);
519 DestroyWindow( test
);
521 /**************** test owner destruction *******************/
523 /* owned child popup */
524 owner
= create_tool_window( 0, 0 );
525 test
= create_tool_window( WS_POPUP
, owner
);
526 trace( "created owner %p and popup %p\n", owner
, test
);
527 ret
= SetParent( test
, child
);
528 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
529 check_parents( test
, child
, child
, owner
, owner
, hwndMain
, owner
);
530 /* window is now child of 'child' but owned by 'owner' */
531 DestroyWindow( owner
);
532 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
533 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
534 * while Win95, Win2k, WinXP do.
536 /*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
537 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
540 /* owned top-level popup */
541 owner
= create_tool_window( 0, 0 );
542 test
= create_tool_window( WS_POPUP
, owner
);
543 trace( "created owner %p and popup %p\n", owner
, test
);
544 check_parents( test
, desktop
, owner
, owner
, owner
, test
, owner
);
545 DestroyWindow( owner
);
546 ok( !IsWindow(test
), "Window %p not destroyed by owner destruction\n", test
);
548 /* top-level popup owned by child */
549 owner
= create_tool_window( WS_CHILD
, hwndMain2
);
550 test
= create_tool_window( WS_POPUP
, 0 );
551 trace( "created owner %p and popup %p\n", owner
, test
);
552 ret
= (HWND
)SetWindowLongPtrA( test
, GWLP_HWNDPARENT
, (ULONG_PTR
)owner
);
553 ok( ret
== 0, "GWL_HWNDPARENT return value %p expected 0\n", ret
);
554 check_parents( test
, desktop
, owner
, owner
, owner
, test
, hwndMain2
);
555 DestroyWindow( owner
);
556 ok( IsWindow(test
), "Window %p destroyed by owner destruction\n", test
);
557 ok( !IsWindow(owner
), "Owner %p not destroyed\n", owner
);
558 /* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
559 * while Win95, Win2k, WinXP do.
561 /*check_parents( test, desktop, owner, owner, owner, test, owner );*/
565 DestroyWindow(child
);
568 owner
= create_tool_window( WS_OVERLAPPED
, 0 );
569 test
= create_tool_window( WS_POPUP
, desktop
);
571 ok( !GetWindow( test
, GW_OWNER
), "Wrong owner window\n" );
573 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
574 "EnumChildWindows should have returned FALSE\n" );
575 ok( numChildren
== 0, "numChildren should be 0 got %d\n", numChildren
);
577 SetWindowLongA( test
, GWL_STYLE
, (GetWindowLongA( test
, GWL_STYLE
) & ~WS_POPUP
) | WS_CHILD
);
578 ret
= SetParent( test
, owner
);
579 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
582 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
583 "EnumChildWindows should have returned TRUE\n" );
584 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
586 child
= create_tool_window( WS_CHILD
, owner
);
588 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
589 "EnumChildWindows should have returned FALSE\n" );
590 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
591 DestroyWindow( child
);
593 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, owner
);
594 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
596 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
597 "EnumChildWindows should have returned TRUE\n" );
598 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
600 ret
= SetParent( child
, owner
);
601 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
602 ok( ret
== desktop
, "SetParent return value %p expected %p\n", ret
, desktop
);
604 ok( !EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
605 "EnumChildWindows should have returned FALSE\n" );
606 ok( numChildren
== 2, "numChildren should be 2 got %d\n", numChildren
);
608 ret
= SetParent( child
, NULL
);
609 ok( GetWindow( child
, GW_OWNER
) == owner
, "Wrong owner window\n" );
610 ok( ret
== owner
, "SetParent return value %p expected %p\n", ret
, owner
);
612 ok( EnumChildWindows( owner
, EnumChildProc
, (LPARAM
)&numChildren
),
613 "EnumChildWindows should have returned TRUE\n" );
614 ok( numChildren
== 1, "numChildren should be 1 got %d\n", numChildren
);
616 /* even GW_OWNER == owner it's still a desktop's child */
617 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
618 "EnumChildWindows should have found %p and returned FALSE\n", child
);
620 DestroyWindow( child
);
621 child
= create_tool_window( WS_VISIBLE
| WS_OVERLAPPEDWINDOW
, NULL
);
623 ok( !EnumChildWindows( desktop
, EnumChildProc1
, (LPARAM
)child
),
624 "EnumChildWindows should have found %p and returned FALSE\n", child
);
626 DestroyWindow( child
);
627 DestroyWindow( test
);
628 DestroyWindow( owner
);
631 static BOOL CALLBACK
enum_proc( HWND hwnd
, LPARAM lParam
)
634 if (*(LPINT
)lParam
> 2) return FALSE
;
637 static DWORD CALLBACK
enum_thread( void *arg
)
644 if (pGetGUIThreadInfo
)
647 info
.cbSize
= sizeof(info
);
648 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
649 ok( ret
|| broken(!ret
), /* win9x */
650 "GetGUIThreadInfo failed without message queue\n" );
651 SetLastError( 0xdeadbeef );
652 info
.cbSize
= sizeof(info
) + 1;
653 ret
= pGetGUIThreadInfo( GetCurrentThreadId(), &info
);
654 ok( !ret
, "GetGUIThreadInfo succeeded with wrong size\n" );
655 ok( GetLastError() == ERROR_INVALID_PARAMETER
||
656 broken(GetLastError() == 0xdeadbeef), /* win9x */
657 "wrong error %u\n", GetLastError() );
660 PeekMessageA( &msg
, 0, 0, 0, PM_NOREMOVE
); /* make sure we have a message queue */
663 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
664 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
665 ok( count
== 0, "count should be 0 got %d\n", count
);
667 hwnd
[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP
,
668 0, 0, 100, 100, 0, 0, 0, NULL
);
670 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
671 ok( ret
, "EnumThreadWindows should have returned TRUE\n" );
672 if (count
!= 2) /* Vista gives us two windows for the price of one */
674 ok( count
== 1, "count should be 1 got %d\n", count
);
675 hwnd
[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP
,
676 0, 0, 100, 100, 0, 0, 0, NULL
);
680 hwnd
[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP
,
681 0, 0, 100, 100, 0, 0, 0, NULL
);
683 ret
= EnumThreadWindows( GetCurrentThreadId(), enum_proc
, (LPARAM
)&count
);
684 ok( !ret
, "EnumThreadWindows should have returned FALSE\n" );
685 ok( count
== 3, "count should be 3 got %d\n", count
);
687 if (hwnd
[2]) DestroyWindow(hwnd
[2]);
688 DestroyWindow(hwnd
[1]);
689 DestroyWindow(hwnd
[0]);
693 /* test EnumThreadWindows in a separate thread */
694 static void test_enum_thread_windows(void)
697 HANDLE handle
= CreateThread( NULL
, 0, enum_thread
, 0, 0, &id
);
698 ok( !WaitForSingleObject( handle
, 10000 ), "wait failed\n" );
699 CloseHandle( handle
);
702 static LRESULT WINAPI
main_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
706 case WM_GETMINMAXINFO
:
708 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
710 trace("WM_GETMINMAXINFO: hwnd %p, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
711 dump_minmax_info( minmax
);
712 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
715 case WM_WINDOWPOSCHANGING
:
717 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
718 trace("main: WM_WINDOWPOSCHANGING %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
719 winpos
->hwnd
, winpos
->hwndInsertAfter
,
720 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
721 if (!(winpos
->flags
& SWP_NOMOVE
))
723 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
724 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
726 /* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
727 if (!(winpos
->flags
& SWP_NOSIZE
) && !is_win9x
)
729 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
730 winpos
->cx
== 32768, /* win7 doesn't truncate */
731 "bad winpos->cx %d\n", winpos
->cx
);
732 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
733 winpos
->cy
== 40000, /* win7 doesn't truncate */
734 "bad winpos->cy %d\n", winpos
->cy
);
738 case WM_WINDOWPOSCHANGED
:
741 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
742 trace("main: WM_WINDOWPOSCHANGED %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
743 winpos
->hwnd
, winpos
->hwndInsertAfter
,
744 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
745 ok(winpos
->x
>= -32768 && winpos
->x
<= 32767, "bad winpos->x %d\n", winpos
->x
);
746 ok(winpos
->y
>= -32768 && winpos
->y
<= 32767, "bad winpos->y %d\n", winpos
->y
);
748 ok((winpos
->cx
>= 0 && winpos
->cx
<= 32767) ||
749 winpos
->cx
== 32768, /* win7 doesn't truncate */
750 "bad winpos->cx %d\n", winpos
->cx
);
751 ok((winpos
->cy
>= 0 && winpos
->cy
<= 32767) ||
752 winpos
->cy
== 40000, /* win7 doesn't truncate */
753 "bad winpos->cy %d\n", winpos
->cy
);
755 GetWindowRect(hwnd
, &rc1
);
756 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
757 /* note: winpos coordinates are relative to parent */
758 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
761 /* Uncomment this once the test succeeds in all cases */
762 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
763 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
765 GetClientRect(hwnd
, &rc2
);
766 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
767 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
768 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
769 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
775 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
776 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
778 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
779 if (got_getminmaxinfo
)
780 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
782 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
783 ok(got_getminmaxinfo
, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
785 ok(!got_getminmaxinfo
, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
789 if (test_lbuttondown_flag
)
791 ShowWindow((HWND
)wparam
, SW_SHOW
);
792 flush_events( FALSE
);
797 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
800 static LRESULT WINAPI
tool_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
804 case WM_GETMINMAXINFO
:
806 MINMAXINFO
* minmax
= (MINMAXINFO
*)lparam
;
808 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
809 dump_minmax_info( minmax
);
810 SetWindowLongPtrA(hwnd
, GWLP_USERDATA
, 0x20031021);
815 BOOL got_getminmaxinfo
= GetWindowLongPtrA(hwnd
, GWLP_USERDATA
) == 0x20031021;
816 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
818 trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd
, cs
->hwndParent
, cs
->style
);
819 if (got_getminmaxinfo
)
820 trace("%p got WM_GETMINMAXINFO\n", hwnd
);
822 if ((cs
->style
& WS_THICKFRAME
) || !(cs
->style
& (WS_POPUP
| WS_CHILD
)))
823 ok(got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
825 ok(!got_getminmaxinfo
, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
830 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
833 static BOOL
RegisterWindowClasses(void)
837 cls
.style
= CS_DBLCLKS
;
838 cls
.lpfnWndProc
= main_window_procA
;
841 cls
.hInstance
= GetModuleHandleA(0);
843 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
844 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
845 cls
.lpszMenuName
= NULL
;
846 cls
.lpszClassName
= "MainWindowClass";
848 if(!RegisterClassA(&cls
)) return FALSE
;
851 cls
.lpfnWndProc
= tool_window_procA
;
854 cls
.hInstance
= GetModuleHandleA(0);
856 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
857 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
858 cls
.lpszMenuName
= NULL
;
859 cls
.lpszClassName
= "ToolWindowClass";
861 if(!RegisterClassA(&cls
)) return FALSE
;
866 static void verify_window_info(const char *hook
, HWND hwnd
, const WINDOWINFO
*info
)
868 RECT rcWindow
, rcClient
;
871 ok(IsWindow(hwnd
), "bad window handle %p in hook %s\n", hwnd
, hook
);
873 GetWindowRect(hwnd
, &rcWindow
);
874 ok(EqualRect(&rcWindow
, &info
->rcWindow
), "wrong rcWindow for %p in hook %s\n", hwnd
, hook
);
876 GetClientRect(hwnd
, &rcClient
);
877 /* translate to screen coordinates */
878 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rcClient
, 2);
879 ok(EqualRect(&rcClient
, &info
->rcClient
), "wrong rcClient for %p in hook %s\n", hwnd
, hook
);
881 ok(info
->dwStyle
== (DWORD
)GetWindowLongA(hwnd
, GWL_STYLE
),
882 "wrong dwStyle: %08x != %08x for %p in hook %s\n",
883 info
->dwStyle
, GetWindowLongA(hwnd
, GWL_STYLE
), hwnd
, hook
);
884 /* Windows reports some undocumented exstyles in WINDOWINFO, but
885 * doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
887 ok((info
->dwExStyle
& ~0xe0000800) == (DWORD
)GetWindowLongA(hwnd
, GWL_EXSTYLE
),
888 "wrong dwExStyle: %08x != %08x for %p in hook %s\n",
889 info
->dwExStyle
, GetWindowLongA(hwnd
, GWL_EXSTYLE
), hwnd
, hook
);
890 status
= (GetActiveWindow() == hwnd
) ? WS_ACTIVECAPTION
: 0;
891 if (GetForegroundWindow())
892 ok(info
->dwWindowStatus
== status
, "wrong dwWindowStatus: %04x != %04x active %p fg %p in hook %s\n",
893 info
->dwWindowStatus
, status
, GetActiveWindow(), GetForegroundWindow(), hook
);
895 /* win2k and XP return broken border info in GetWindowInfo most of
896 * the time, so there is no point in testing it.
901 ok(info
->cxWindowBorders
== (unsigned)(rcClient
.left
- rcWindow
.left
),
902 "wrong cxWindowBorders %d != %d\n", info
->cxWindowBorders
, rcClient
.left
- rcWindow
.left
);
903 border
= min(rcWindow
.bottom
- rcClient
.bottom
, rcClient
.top
- rcWindow
.top
);
904 ok(info
->cyWindowBorders
== border
,
905 "wrong cyWindowBorders %d != %d\n", info
->cyWindowBorders
, border
);
907 ok(info
->atomWindowType
== GetClassLongA(hwnd
, GCW_ATOM
), "wrong atomWindowType for %p in hook %s\n",
909 ok(info
->wCreatorVersion
== 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
910 info
->wCreatorVersion
== 0x0500 /* Vista */,
911 "wrong wCreatorVersion %04x for %p in hook %s\n", info
->wCreatorVersion
, hwnd
, hook
);
914 static void FixedAdjustWindowRectEx(RECT
* rc
, LONG style
, BOOL menu
, LONG exstyle
)
916 AdjustWindowRectEx(rc
, style
, menu
, exstyle
);
917 /* AdjustWindowRectEx does not include scroll bars */
918 if (style
& WS_VSCROLL
)
920 if(exstyle
& WS_EX_LEFTSCROLLBAR
)
921 rc
->left
-= GetSystemMetrics(SM_CXVSCROLL
);
923 rc
->right
+= GetSystemMetrics(SM_CXVSCROLL
);
925 if (style
& WS_HSCROLL
)
926 rc
->bottom
+= GetSystemMetrics(SM_CYHSCROLL
);
929 static void test_nonclient_area(HWND hwnd
)
931 DWORD style
, exstyle
;
932 RECT rc_window
, rc_client
, rc
;
936 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
937 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
938 menu
= !(style
& WS_CHILD
) && GetMenu(hwnd
) != 0;
940 GetWindowRect(hwnd
, &rc_window
);
941 GetClientRect(hwnd
, &rc_client
);
943 /* avoid some cases when things go wrong */
944 if (IsRectEmpty(&rc_window
) || IsRectEmpty(&rc_client
) ||
945 rc_window
.right
> 32768 || rc_window
.bottom
> 32768) return;
947 CopyRect(&rc
, &rc_client
);
948 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc
, 2);
949 FixedAdjustWindowRectEx(&rc
, style
, menu
, exstyle
);
951 ok(EqualRect(&rc
, &rc_window
),
952 "window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
953 style
, exstyle
, menu
, rc_window
.left
, rc_window
.top
, rc_window
.right
, rc_window
.bottom
,
954 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
957 CopyRect(&rc
, &rc_window
);
958 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
959 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
960 ok(EqualRect(&rc
, &rc_client
),
961 "client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
962 style
, exstyle
, menu
, rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
,
963 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
965 /* NULL rectangle shouldn't crash */
966 ret
= DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, 0);
967 ok(ret
== 0, "NULL rectangle returned %ld instead of 0\n", ret
);
969 /* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
973 /* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
974 SetRect(&rc_client
, 0, 0, 250, 150);
975 CopyRect(&rc_window
, &rc_client
);
976 MapWindowPoints(hwnd
, 0, (LPPOINT
)&rc_window
, 2);
977 FixedAdjustWindowRectEx(&rc_window
, style
, menu
, exstyle
);
979 CopyRect(&rc
, &rc_window
);
980 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc
);
981 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc
, 2);
982 ok(EqualRect(&rc
, &rc_client
),
983 "synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
984 style
, exstyle
, menu
, rc_client
.left
, rc_client
.top
, rc_client
.right
, rc_client
.bottom
,
985 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
988 static LRESULT CALLBACK
cbt_hook_proc(int nCode
, WPARAM wParam
, LPARAM lParam
)
990 static const char *CBT_code_name
[10] = {
1001 const char *code_name
= (nCode
>= 0 && nCode
<= HCBT_SETFOCUS
) ? CBT_code_name
[nCode
] : "Unknown";
1002 HWND hwnd
= (HWND
)wParam
;
1006 case HCBT_CREATEWND
:
1008 static const RECT rc_null
;
1011 CBT_CREATEWNDA
*createwnd
= (CBT_CREATEWNDA
*)lParam
;
1012 ok(createwnd
->hwndInsertAfter
== HWND_TOP
, "hwndInsertAfter should be always HWND_TOP\n");
1017 info
.cbSize
= sizeof(WINDOWINFO
);
1018 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1019 verify_window_info(code_name
, hwnd
, &info
);
1022 /* WS_VISIBLE should be turned off yet */
1023 style
= createwnd
->lpcs
->style
& ~WS_VISIBLE
;
1024 ok(style
== GetWindowLongA(hwnd
, GWL_STYLE
),
1025 "style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
1026 GetWindowLongA(hwnd
, GWL_STYLE
), style
);
1030 /* Uncomment this once the test succeeds in all cases */
1031 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1033 ok(GetParent(hwnd
) == hwndMessage
,
1034 "wrong result from GetParent %p: message window %p\n",
1035 GetParent(hwnd
), hwndMessage
);
1038 ok(!GetParent(hwnd
), "GetParent should return 0 at this point\n");
1040 ok(!GetWindow(hwnd
, GW_OWNER
), "GW_OWNER should be set to 0 at this point\n");
1044 /* while NT assigns GW_HWNDFIRST/LAST some values at this point,
1045 * Win9x still has them set to 0.
1047 ok(GetWindow(hwnd
, GW_HWNDFIRST
) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
1048 ok(GetWindow(hwnd
, GW_HWNDLAST
) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
1050 ok(!GetWindow(hwnd
, GW_HWNDPREV
), "GW_HWNDPREV should be set to 0 at this point\n");
1051 ok(!GetWindow(hwnd
, GW_HWNDNEXT
), "GW_HWNDNEXT should be set to 0 at this point\n");
1055 /* Uncomment this once the test succeeds in all cases */
1058 ok(pGetAncestor(hwnd
, GA_PARENT
) == hwndMessage
, "GA_PARENT should be set to hwndMessage at this point\n");
1059 ok(pGetAncestor(hwnd
, GA_ROOT
) == hwnd
,
1060 "GA_ROOT is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOT
), hwnd
);
1062 if ((style
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
)
1063 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwndMessage
,
1064 "GA_ROOTOWNER should be set to hwndMessage at this point\n");
1066 ok(pGetAncestor(hwnd
, GA_ROOTOWNER
) == hwnd
,
1067 "GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor(hwnd
, GA_ROOTOWNER
), hwnd
);
1070 ok(GetWindowRect(hwnd
, &rc
), "GetWindowRect failed\n");
1071 ok(EqualRect(&rc
, &rc_null
), "window rect should be set to 0 HCBT_CREATEWND\n");
1072 ok(GetClientRect(hwnd
, &rc
), "GetClientRect failed\n");
1073 ok(EqualRect(&rc
, &rc_null
), "client rect should be set to 0 on HCBT_CREATEWND\n");
1080 if (pGetWindowInfo
&& IsWindow(hwnd
))
1084 /* Win98 actually does check the info.cbSize and doesn't allow
1085 * it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
1086 * WinXP do not check it at all.
1088 info
.cbSize
= sizeof(WINDOWINFO
);
1089 ok(pGetWindowInfo(hwnd
, &info
), "GetWindowInfo should not fail\n");
1090 verify_window_info(code_name
, hwnd
, &info
);
1093 /* window state is undefined */
1095 case HCBT_DESTROYWND
:
1101 return CallNextHookEx(hhook
, nCode
, wParam
, lParam
);
1104 static void test_shell_window(void)
1108 HMODULE hinst
, hUser32
;
1109 BOOL (WINAPI
*SetShellWindow
)(HWND
);
1110 HWND hwnd1
, hwnd2
, hwnd3
, hwnd4
, hwnd5
;
1111 HWND shellWindow
, nextWnd
;
1115 win_skip("Skipping shell window test on Win9x\n");
1119 shellWindow
= GetShellWindow();
1120 hinst
= GetModuleHandleA(NULL
);
1121 hUser32
= GetModuleHandleA("user32");
1123 SetShellWindow
= (void *)GetProcAddress(hUser32
, "SetShellWindow");
1125 trace("previous shell window: %p\n", shellWindow
);
1131 GetWindowThreadProcessId(shellWindow
, &pid
);
1132 hProcess
= OpenProcess(PROCESS_ALL_ACCESS
, FALSE
, pid
);
1135 skip( "cannot get access to shell process\n" );
1139 SetLastError(0xdeadbeef);
1140 ret
= DestroyWindow(shellWindow
);
1141 error
= GetLastError();
1143 ok(!ret
, "DestroyWindow(shellWindow)\n");
1144 /* passes on Win XP, but not on Win98 */
1145 ok(error
==ERROR_ACCESS_DENIED
|| error
== 0xdeadbeef,
1146 "got %u after DestroyWindow(shellWindow)\n", error
);
1148 /* close old shell instance */
1149 ret
= TerminateProcess(hProcess
, 0);
1150 ok(ret
, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
1151 WaitForSingleObject(hProcess
, INFINITE
); /* wait for termination */
1152 CloseHandle(hProcess
);
1155 hwnd1
= CreateWindowExA(0, "#32770", "TEST1", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst
, 0);
1156 trace("created window 1: %p\n", hwnd1
);
1158 ret
= SetShellWindow(hwnd1
);
1159 ok(ret
, "first call to SetShellWindow(hwnd1)\n");
1160 shellWindow
= GetShellWindow();
1161 ok(shellWindow
==hwnd1
, "wrong shell window: %p\n", shellWindow
);
1163 ret
= SetShellWindow(hwnd1
);
1164 ok(!ret
, "second call to SetShellWindow(hwnd1)\n");
1166 ret
= SetShellWindow(0);
1167 error
= GetLastError();
1168 /* passes on Win XP, but not on Win98
1169 ok(!ret, "reset shell window by SetShellWindow(0)\n");
1170 ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
1172 ret
= SetShellWindow(hwnd1
);
1173 /* passes on Win XP, but not on Win98
1174 ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
1176 SetWindowLongA(hwnd1
, GWL_EXSTYLE
, GetWindowLongA(hwnd1
,GWL_EXSTYLE
)|WS_EX_TOPMOST
);
1177 ret
= (GetWindowLongA(hwnd1
,GWL_EXSTYLE
) & WS_EX_TOPMOST
) != 0;
1178 ok(!ret
, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
1180 ret
= DestroyWindow(hwnd1
);
1181 ok(ret
, "DestroyWindow(hwnd1)\n");
1183 hwnd2
= CreateWindowExA(WS_EX_TOPMOST
, "#32770", "TEST2", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst
, 0);
1184 trace("created window 2: %p\n", hwnd2
);
1185 ret
= SetShellWindow(hwnd2
);
1186 ok(!ret
, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
1188 hwnd3
= CreateWindowExA(0, "#32770", "TEST3", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst
, 0);
1189 trace("created window 3: %p\n", hwnd3
);
1191 hwnd4
= CreateWindowExA(0, "#32770", "TEST4", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst
, 0);
1192 trace("created window 4: %p\n", hwnd4
);
1194 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1195 ok(nextWnd
==hwnd3
, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd
);
1197 ret
= SetShellWindow(hwnd4
);
1198 ok(ret
, "SetShellWindow(hwnd4)\n");
1199 shellWindow
= GetShellWindow();
1200 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1202 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1203 ok(nextWnd
==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd
);
1205 ret
= SetWindowPos(hwnd4
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1206 ok(ret
, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
1208 ret
= SetWindowPos(hwnd4
, hwnd3
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1209 ok(ret
, "SetWindowPos(hwnd4, hwnd3\n");
1211 ret
= SetShellWindow(hwnd3
);
1212 ok(!ret
, "SetShellWindow(hwnd3)\n");
1213 shellWindow
= GetShellWindow();
1214 ok(shellWindow
==hwnd4
, "wrong shell window: %p - expected hwnd4\n", shellWindow
);
1216 hwnd5
= CreateWindowExA(0, "#32770", "TEST5", WS_OVERLAPPEDWINDOW
/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst
, 0);
1217 trace("created window 5: %p\n", hwnd5
);
1218 ret
= SetWindowPos(hwnd4
, hwnd5
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
1219 ok(ret
, "SetWindowPos(hwnd4, hwnd5)\n");
1223 nextWnd
= GetWindow(hwnd4
, GW_HWNDNEXT
);
1224 ok(nextWnd
==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd
);
1227 /* destroy test windows */
1228 DestroyWindow(hwnd2
);
1229 DestroyWindow(hwnd3
);
1230 DestroyWindow(hwnd4
);
1231 DestroyWindow(hwnd5
);
1234 /************** MDI test ****************/
1236 static char mdi_lParam_test_message
[] = "just a test string";
1238 static void test_MDI_create(HWND parent
, HWND mdi_client
, INT_PTR first_id
)
1240 MDICREATESTRUCTA mdi_cs
;
1243 static const WCHAR classW
[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
1244 static const WCHAR titleW
[] = {'M','D','I',' ','c','h','i','l','d',0};
1245 BOOL isWin9x
= FALSE
;
1247 mdi_cs
.szClass
= "MDI_child_Class_1";
1248 mdi_cs
.szTitle
= "MDI child";
1249 mdi_cs
.hOwner
= GetModuleHandleA(NULL
);
1250 mdi_cs
.x
= CW_USEDEFAULT
;
1251 mdi_cs
.y
= CW_USEDEFAULT
;
1252 mdi_cs
.cx
= CW_USEDEFAULT
;
1253 mdi_cs
.cy
= CW_USEDEFAULT
;
1255 mdi_cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1256 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1257 ok(mdi_child
!= 0, "MDI child creation failed\n");
1258 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1259 ok(id
== first_id
, "wrong child id %ld\n", id
);
1260 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1261 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1263 mdi_cs
.style
= 0x7fffffff; /* without WS_POPUP */
1264 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1265 ok(mdi_child
!= 0, "MDI child creation failed\n");
1266 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1267 ok(id
== first_id
, "wrong child id %ld\n", id
);
1268 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1269 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1271 mdi_cs
.style
= 0xffffffff; /* with WS_POPUP */
1272 mdi_child
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1273 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1275 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1279 ok(mdi_child
!= 0, "MDI child creation failed\n");
1280 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1281 ok(id
== first_id
, "wrong child id %ld\n", id
);
1282 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1283 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1286 /* test MDICREATESTRUCT A<->W mapping */
1287 /* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
1289 mdi_cs
.szClass
= (LPCSTR
)classW
;
1290 mdi_cs
.szTitle
= (LPCSTR
)titleW
;
1291 SetLastError(0xdeadbeef);
1292 mdi_child
= (HWND
)SendMessageW(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&mdi_cs
);
1295 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1298 ok(mdi_child
!= 0, "MDI child creation failed\n");
1302 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1303 ok(id
== first_id
, "wrong child id %ld\n", id
);
1304 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1305 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1308 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1310 CW_USEDEFAULT
, CW_USEDEFAULT
,
1311 CW_USEDEFAULT
, CW_USEDEFAULT
,
1312 mdi_client
, GetModuleHandleA(NULL
),
1313 (LPARAM
)mdi_lParam_test_message
);
1314 ok(mdi_child
!= 0, "MDI child creation failed\n");
1315 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1316 ok(id
== first_id
, "wrong child id %ld\n", id
);
1317 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1318 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1320 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1321 0x7fffffff, /* without WS_POPUP */
1322 CW_USEDEFAULT
, CW_USEDEFAULT
,
1323 CW_USEDEFAULT
, CW_USEDEFAULT
,
1324 mdi_client
, GetModuleHandleA(NULL
),
1325 (LPARAM
)mdi_lParam_test_message
);
1326 ok(mdi_child
!= 0, "MDI child creation failed\n");
1327 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1328 ok(id
== first_id
, "wrong child id %ld\n", id
);
1329 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1330 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1332 mdi_child
= CreateMDIWindowA("MDI_child_Class_1", "MDI child",
1333 0xffffffff, /* with WS_POPUP */
1334 CW_USEDEFAULT
, CW_USEDEFAULT
,
1335 CW_USEDEFAULT
, CW_USEDEFAULT
,
1336 mdi_client
, GetModuleHandleA(NULL
),
1337 (LPARAM
)mdi_lParam_test_message
);
1338 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1340 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1344 ok(mdi_child
!= 0, "MDI child creation failed\n");
1345 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1346 ok(id
== first_id
, "wrong child id %ld\n", id
);
1347 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1348 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1351 /* test MDICREATESTRUCT A<->W mapping */
1352 SetLastError(0xdeadbeef);
1353 mdi_child
= CreateMDIWindowW(classW
, titleW
,
1355 CW_USEDEFAULT
, CW_USEDEFAULT
,
1356 CW_USEDEFAULT
, CW_USEDEFAULT
,
1357 mdi_client
, GetModuleHandleA(NULL
),
1358 (LPARAM
)mdi_lParam_test_message
);
1361 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1364 ok(mdi_child
!= 0, "MDI child creation failed\n");
1368 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1369 ok(id
== first_id
, "wrong child id %ld\n", id
);
1370 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1371 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1374 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1376 CW_USEDEFAULT
, CW_USEDEFAULT
,
1377 CW_USEDEFAULT
, CW_USEDEFAULT
,
1378 mdi_client
, 0, GetModuleHandleA(NULL
),
1379 mdi_lParam_test_message
);
1380 ok(mdi_child
!= 0, "MDI child creation failed\n");
1381 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1382 ok(id
== first_id
, "wrong child id %ld\n", id
);
1383 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1384 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1386 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1387 0x7fffffff, /* without WS_POPUP */
1388 CW_USEDEFAULT
, CW_USEDEFAULT
,
1389 CW_USEDEFAULT
, CW_USEDEFAULT
,
1390 mdi_client
, 0, GetModuleHandleA(NULL
),
1391 mdi_lParam_test_message
);
1392 ok(mdi_child
!= 0, "MDI child creation failed\n");
1393 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1394 ok(id
== first_id
, "wrong child id %ld\n", id
);
1395 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1396 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1398 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_1", "MDI child",
1399 0xffffffff, /* with WS_POPUP */
1400 CW_USEDEFAULT
, CW_USEDEFAULT
,
1401 CW_USEDEFAULT
, CW_USEDEFAULT
,
1402 mdi_client
, 0, GetModuleHandleA(NULL
),
1403 mdi_lParam_test_message
);
1404 if (GetWindowLongA(mdi_client
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1406 ok(!mdi_child
, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
1410 ok(mdi_child
!= 0, "MDI child creation failed\n");
1411 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1412 ok(id
== first_id
, "wrong child id %ld\n", id
);
1413 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1414 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1417 /* test MDICREATESTRUCT A<->W mapping */
1418 SetLastError(0xdeadbeef);
1419 mdi_child
= CreateWindowExW(WS_EX_MDICHILD
, classW
, titleW
,
1421 CW_USEDEFAULT
, CW_USEDEFAULT
,
1422 CW_USEDEFAULT
, CW_USEDEFAULT
,
1423 mdi_client
, 0, GetModuleHandleA(NULL
),
1424 mdi_lParam_test_message
);
1427 if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
)
1430 ok(mdi_child
!= 0, "MDI child creation failed\n");
1434 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1435 ok(id
== first_id
, "wrong child id %ld\n", id
);
1436 SendMessageA(mdi_client
, WM_MDIDESTROY
, (WPARAM
)mdi_child
, 0);
1437 ok(!IsWindow(mdi_child
), "WM_MDIDESTROY failed\n");
1440 /* This test fails on Win9x */
1443 mdi_child
= CreateWindowExA(WS_EX_MDICHILD
, "MDI_child_Class_2", "MDI child",
1445 CW_USEDEFAULT
, CW_USEDEFAULT
,
1446 CW_USEDEFAULT
, CW_USEDEFAULT
,
1447 parent
, 0, GetModuleHandleA(NULL
),
1448 mdi_lParam_test_message
);
1449 ok(!mdi_child
, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
1452 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1453 WS_CHILD
, /* without WS_POPUP */
1454 CW_USEDEFAULT
, CW_USEDEFAULT
,
1455 CW_USEDEFAULT
, CW_USEDEFAULT
,
1456 mdi_client
, 0, GetModuleHandleA(NULL
),
1457 mdi_lParam_test_message
);
1458 ok(mdi_child
!= 0, "MDI child creation failed\n");
1459 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1460 ok(id
== 0, "wrong child id %ld\n", id
);
1461 DestroyWindow(mdi_child
);
1463 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1464 WS_CHILD
| WS_POPUP
, /* with WS_POPUP */
1465 CW_USEDEFAULT
, CW_USEDEFAULT
,
1466 CW_USEDEFAULT
, CW_USEDEFAULT
,
1467 mdi_client
, 0, GetModuleHandleA(NULL
),
1468 mdi_lParam_test_message
);
1469 ok(mdi_child
!= 0, "MDI child creation failed\n");
1470 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1471 ok(id
== 0, "wrong child id %ld\n", id
);
1472 DestroyWindow(mdi_child
);
1474 /* maximized child */
1475 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1476 WS_CHILD
| WS_MAXIMIZE
,
1477 CW_USEDEFAULT
, CW_USEDEFAULT
,
1478 CW_USEDEFAULT
, CW_USEDEFAULT
,
1479 mdi_client
, 0, GetModuleHandleA(NULL
),
1480 mdi_lParam_test_message
);
1481 ok(mdi_child
!= 0, "MDI child creation failed\n");
1482 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1483 ok(id
== 0, "wrong child id %ld\n", id
);
1484 DestroyWindow(mdi_child
);
1486 trace("Creating maximized child with a caption\n");
1487 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1488 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
,
1489 CW_USEDEFAULT
, CW_USEDEFAULT
,
1490 CW_USEDEFAULT
, CW_USEDEFAULT
,
1491 mdi_client
, 0, GetModuleHandleA(NULL
),
1492 mdi_lParam_test_message
);
1493 ok(mdi_child
!= 0, "MDI child creation failed\n");
1494 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1495 ok(id
== 0, "wrong child id %ld\n", id
);
1496 DestroyWindow(mdi_child
);
1498 trace("Creating maximized child with a caption and a thick frame\n");
1499 mdi_child
= CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
1500 WS_CHILD
| WS_MAXIMIZE
| WS_CAPTION
| WS_THICKFRAME
,
1501 CW_USEDEFAULT
, CW_USEDEFAULT
,
1502 CW_USEDEFAULT
, CW_USEDEFAULT
,
1503 mdi_client
, 0, GetModuleHandleA(NULL
),
1504 mdi_lParam_test_message
);
1505 ok(mdi_child
!= 0, "MDI child creation failed\n");
1506 id
= GetWindowLongPtrA(mdi_child
, GWLP_ID
);
1507 ok(id
== 0, "wrong child id %ld\n", id
);
1508 DestroyWindow(mdi_child
);
1511 static void test_MDI_child_stack(HWND mdi_client
)
1513 HWND child_1
, child_2
, child_3
, child_4
;
1515 MDICREATESTRUCTA cs
;
1517 cs
.szClass
= "MDI_child_Class_1";
1518 cs
.szTitle
= "MDI child";
1519 cs
.hOwner
= GetModuleHandleA(0);
1520 cs
.x
= CW_USEDEFAULT
;
1521 cs
.y
= CW_USEDEFAULT
;
1522 cs
.cx
= CW_USEDEFAULT
;
1523 cs
.cy
= CW_USEDEFAULT
;
1525 cs
.lParam
= (LPARAM
)mdi_lParam_test_message
;
1527 child_1
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1528 ok(child_1
!= 0, "expected child_1 to be non NULL\n");
1529 child_2
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1530 ok(child_2
!= 0, "expected child_2 to be non NULL\n");
1531 child_3
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1532 ok(child_3
!= 0, "expected child_3 to be non NULL\n");
1533 child_4
= (HWND
)SendMessageA(mdi_client
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
1534 ok(child_4
!= 0, "expected child_4 to be non NULL\n");
1536 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1537 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1538 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1539 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1540 trace("Initial MDI child stack: %p->%p->%p->%p\n", stack
[0], stack
[1], stack
[2], stack
[3]);
1541 ok(stack
[0] == child_4
&& stack
[1] == child_3
&&
1542 stack
[2] == child_2
&& stack
[3] == child_1
,
1543 "Unexpected initial order, should be: %p->%p->%p->%p\n",
1544 child_4
, child_3
, child_2
, child_1
);
1546 trace("Activate child next to %p\n", child_3
);
1547 SendMessageA(mdi_client
, WM_MDINEXT
, (WPARAM
)child_3
, 0);
1549 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1550 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1551 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1552 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1553 ok(stack
[0] == child_2
&& stack
[1] == child_4
&&
1554 stack
[2] == child_1
&& stack
[3] == child_3
,
1555 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1556 child_2
, child_4
, child_1
, child_3
, stack
[0], stack
[1], stack
[2], stack
[3]);
1558 trace("Activate child previous to %p\n", child_1
);
1559 SendMessageA(mdi_client
, WM_MDINEXT
, (WPARAM
)child_1
, 1);
1561 stack
[0] = (HWND
)SendMessageA(mdi_client
, WM_MDIGETACTIVE
, 0, 0);
1562 stack
[1] = GetWindow(stack
[0], GW_HWNDNEXT
);
1563 stack
[2] = GetWindow(stack
[1], GW_HWNDNEXT
);
1564 stack
[3] = GetWindow(stack
[2], GW_HWNDNEXT
);
1565 ok(stack
[0] == child_4
&& stack
[1] == child_2
&&
1566 stack
[2] == child_1
&& stack
[3] == child_3
,
1567 "Broken MDI child stack:\nexpected: %p->%p->%p->%p, but got: %p->%p->%p->%p\n",
1568 child_4
, child_2
, child_1
, child_3
, stack
[0], stack
[1], stack
[2], stack
[3]);
1570 DestroyWindow(child_1
);
1571 DestroyWindow(child_2
);
1572 DestroyWindow(child_3
);
1573 DestroyWindow(child_4
);
1576 /**********************************************************************
1577 * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
1579 * Note: The rule here is that client rect of the maximized MDI child
1580 * is equal to the client rect of the MDI client window.
1582 static void MDI_ChildGetMinMaxInfo( HWND client
, HWND hwnd
, MINMAXINFO
* lpMinMax
)
1586 GetClientRect( client
, &rect
);
1587 AdjustWindowRectEx( &rect
, GetWindowLongA( hwnd
, GWL_STYLE
),
1588 0, GetWindowLongA( hwnd
, GWL_EXSTYLE
));
1590 rect
.right
-= rect
.left
;
1591 rect
.bottom
-= rect
.top
;
1592 lpMinMax
->ptMaxSize
.x
= rect
.right
;
1593 lpMinMax
->ptMaxSize
.y
= rect
.bottom
;
1595 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
1596 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
1598 trace("max rect (%d,%d - %d, %d)\n",
1599 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
1602 static LRESULT WINAPI
mdi_child_wnd_proc_1(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1609 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1610 MDICREATESTRUCTA
*mdi_cs
= cs
->lpCreateParams
;
1612 ok(cs
->dwExStyle
& WS_EX_MDICHILD
, "WS_EX_MDICHILD should be set\n");
1613 ok(mdi_cs
->lParam
== (LPARAM
)mdi_lParam_test_message
, "wrong mdi_cs->lParam\n");
1615 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_1"), "wrong class name\n");
1616 ok(!lstrcmpA(cs
->lpszClass
, mdi_cs
->szClass
), "class name does not match\n");
1617 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1618 ok(!lstrcmpA(cs
->lpszName
, mdi_cs
->szTitle
), "title does not match\n");
1619 ok(cs
->hInstance
== mdi_cs
->hOwner
, "%p != %p\n", cs
->hInstance
, mdi_cs
->hOwner
);
1621 /* MDICREATESTRUCT should have original values */
1622 ok(mdi_cs
->style
== 0 || mdi_cs
->style
== 0x7fffffff || mdi_cs
->style
== 0xffffffff,
1623 "mdi_cs->style does not match (%08x)\n", mdi_cs
->style
);
1624 ok(mdi_cs
->x
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->x
);
1625 ok(mdi_cs
->y
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->y
);
1626 ok(mdi_cs
->cx
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cx
);
1627 ok(mdi_cs
->cy
== CW_USEDEFAULT
, "%d != CW_USEDEFAULT\n", mdi_cs
->cy
);
1629 /* CREATESTRUCT should have fixed values */
1630 ok(cs
->x
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->x
);
1631 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1633 /* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
1634 ok(cs
->cx
!= CW_USEDEFAULT
&& cs
->cx
!= 0, "%d == CW_USEDEFAULT\n", cs
->cx
);
1635 ok(cs
->cy
!= CW_USEDEFAULT
&& cs
->cy
!= 0, "%d == CW_USEDEFAULT\n", cs
->cy
);
1637 ok(!(cs
->style
& WS_POPUP
), "WS_POPUP is not allowed\n");
1639 if (GetWindowLongA(cs
->hwndParent
, GWL_STYLE
) & MDIS_ALLCHILDSTYLES
)
1641 LONG style
= mdi_cs
->style
| WS_CHILD
| WS_CLIPSIBLINGS
;
1642 ok(cs
->style
== style
,
1643 "cs->style does not match (%08x)\n", cs
->style
);
1647 LONG style
= mdi_cs
->style
;
1649 style
|= WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_CAPTION
|
1650 WS_SYSMENU
| WS_THICKFRAME
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
;
1651 ok(cs
->style
== style
,
1652 "cs->style does not match (%08x)\n", cs
->style
);
1657 case WM_GETMINMAXINFO
:
1659 HWND client
= GetParent(hwnd
);
1661 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1662 MINMAXINFO my_minmax
;
1663 LONG style
, exstyle
;
1665 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1666 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1668 GetWindowRect(client
, &rc
);
1669 trace("MDI client %p window size = (%d x %d)\n", client
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1670 GetClientRect(client
, &rc
);
1671 trace("MDI client %p client size = (%d x %d)\n", client
, rc
.right
, rc
.bottom
);
1672 trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN
),
1673 GetSystemMetrics(SM_CYSCREEN
));
1675 GetClientRect(client
, &rc
);
1676 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1677 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1678 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1679 trace("MDI child: calculated max window size = (%d x %d)\n", rc
.right
-rc
.left
, rc
.bottom
-rc
.top
);
1680 dump_minmax_info( minmax
);
1682 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1683 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1684 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1685 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1687 DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1689 trace("DefMDIChildProc returned:\n");
1690 dump_minmax_info( minmax
);
1692 MDI_ChildGetMinMaxInfo(client
, hwnd
, &my_minmax
);
1693 ok(minmax
->ptMaxSize
.x
== my_minmax
.ptMaxSize
.x
, "default width of maximized child %d != %d\n",
1694 minmax
->ptMaxSize
.x
, my_minmax
.ptMaxSize
.x
);
1695 ok(minmax
->ptMaxSize
.y
== my_minmax
.ptMaxSize
.y
, "default height of maximized child %d != %d\n",
1696 minmax
->ptMaxSize
.y
, my_minmax
.ptMaxSize
.y
);
1701 case WM_MDIACTIVATE
:
1703 HWND active
, client
= GetParent(hwnd
);
1704 /*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
1705 active
= (HWND
)SendMessageA(client
, WM_MDIGETACTIVE
, 0, 0);
1706 if (hwnd
== (HWND
)lparam
) /* if we are being activated */
1707 ok (active
== (HWND
)lparam
, "new active %p != active %p\n", (HWND
)lparam
, active
);
1709 ok (active
== (HWND
)wparam
, "old active %p != active %p\n", (HWND
)wparam
, active
);
1713 return DefMDIChildProcA(hwnd
, msg
, wparam
, lparam
);
1716 static LRESULT WINAPI
mdi_child_wnd_proc_2(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1723 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lparam
;
1725 trace("%s: x %d, y %d, cx %d, cy %d\n", (msg
== WM_NCCREATE
) ? "WM_NCCREATE" : "WM_CREATE",
1726 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
1728 ok(!(cs
->dwExStyle
& WS_EX_MDICHILD
), "WS_EX_MDICHILD should not be set\n");
1729 ok(cs
->lpCreateParams
== mdi_lParam_test_message
, "wrong cs->lpCreateParams\n");
1731 ok(!lstrcmpA(cs
->lpszClass
, "MDI_child_Class_2"), "wrong class name\n");
1732 ok(!lstrcmpA(cs
->lpszName
, "MDI child"), "wrong title\n");
1734 /* CREATESTRUCT should have fixed values */
1735 /* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
1737 /*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
1738 ok(cs
->y
!= CW_USEDEFAULT
, "%d == CW_USEDEFAULT\n", cs
->y
);
1740 /* cx/cy == CW_USEDEFAULT are translated to 0 */
1741 /* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
1742 while Win95, Win2k, WinXP do. */
1743 /*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
1744 ok(cs
->cy
== 0, "%d != 0\n", cs
->cy
);
1748 case WM_GETMINMAXINFO
:
1750 HWND parent
= GetParent(hwnd
);
1752 MINMAXINFO
*minmax
= (MINMAXINFO
*)lparam
;
1753 LONG style
, exstyle
;
1755 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
1756 exstyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
1758 GetClientRect(parent
, &rc
);
1759 trace("WM_GETMINMAXINFO: parent %p client size = (%d x %d)\n", parent
, rc
.right
, rc
.bottom
);
1761 GetClientRect(parent
, &rc
);
1762 if ((style
& WS_CAPTION
) == WS_CAPTION
)
1763 style
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
1764 AdjustWindowRectEx(&rc
, style
, 0, exstyle
);
1765 dump_minmax_info( minmax
);
1767 ok(minmax
->ptMaxSize
.x
== rc
.right
- rc
.left
, "default width of maximized child %d != %d\n",
1768 minmax
->ptMaxSize
.x
, rc
.right
- rc
.left
);
1769 ok(minmax
->ptMaxSize
.y
== rc
.bottom
- rc
.top
, "default height of maximized child %d != %d\n",
1770 minmax
->ptMaxSize
.y
, rc
.bottom
- rc
.top
);
1774 case WM_WINDOWPOSCHANGED
:
1776 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1779 GetWindowRect(hwnd
, &rc1
);
1780 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1781 /* note: winpos coordinates are relative to parent */
1782 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1783 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=(%d,%d)-(%d,%d) pos=(%d,%d)-(%d,%d)\n",
1784 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
1785 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1786 GetWindowRect(hwnd
, &rc1
);
1787 GetClientRect(hwnd
, &rc2
);
1788 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1789 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1790 ok(EqualRect(&rc1
, &rc2
), "rects do not match, window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
1791 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
1792 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1795 case WM_WINDOWPOSCHANGING
:
1797 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1798 WINDOWPOS my_winpos
= *winpos
;
1800 trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1801 (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
1802 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1803 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1805 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1807 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1808 "DefWindowProc should not change WINDOWPOS: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1809 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1810 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1815 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1818 static LRESULT WINAPI
mdi_main_wnd_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
1820 static HWND mdi_client
;
1826 CLIENTCREATESTRUCT client_cs
;
1829 GetClientRect(hwnd
, &rc
);
1831 client_cs
.hWindowMenu
= 0;
1832 client_cs
.idFirstChild
= 1;
1834 /* MDIClient without MDIS_ALLCHILDSTYLES */
1835 mdi_client
= CreateWindowExA(0, "mdiclient",
1837 WS_CHILD
/*| WS_VISIBLE*/,
1838 /* tests depend on a not zero MDIClient size */
1839 0, 0, rc
.right
, rc
.bottom
,
1840 hwnd
, 0, GetModuleHandleA(NULL
),
1843 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1844 DestroyWindow(mdi_client
);
1846 /* MDIClient with MDIS_ALLCHILDSTYLES */
1847 mdi_client
= CreateWindowExA(0, "mdiclient",
1849 WS_CHILD
| MDIS_ALLCHILDSTYLES
/*| WS_VISIBLE*/,
1850 /* tests depend on a not zero MDIClient size */
1851 0, 0, rc
.right
, rc
.bottom
,
1852 hwnd
, 0, GetModuleHandleA(NULL
),
1855 test_MDI_create(hwnd
, mdi_client
, client_cs
.idFirstChild
);
1856 DestroyWindow(mdi_client
);
1858 /* Test child window stack management */
1859 mdi_client
= CreateWindowExA(0, "mdiclient",
1862 0, 0, rc
.right
, rc
.bottom
,
1863 hwnd
, 0, GetModuleHandleA(NULL
),
1866 test_MDI_child_stack(mdi_client
);
1867 DestroyWindow(mdi_client
);
1871 case WM_WINDOWPOSCHANGED
:
1873 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1876 GetWindowRect(hwnd
, &rc1
);
1877 trace("window: (%d,%d)-(%d,%d)\n", rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
1878 SetRect(&rc2
, winpos
->x
, winpos
->y
, winpos
->x
+ winpos
->cx
, winpos
->y
+ winpos
->cy
);
1879 /* note: winpos coordinates are relative to parent */
1880 MapWindowPoints(GetParent(hwnd
), 0, (LPPOINT
)&rc2
, 2);
1881 trace("pos: (%d,%d)-(%d,%d)\n", rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
1882 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1884 GetWindowRect(hwnd
, &rc1
);
1885 GetClientRect(hwnd
, &rc2
);
1886 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)&rc1
);
1887 MapWindowPoints(0, hwnd
, (LPPOINT
)&rc1
, 2);
1888 ok(EqualRect(&rc1
, &rc2
), "rects do not match\n");
1891 case WM_WINDOWPOSCHANGING
:
1893 WINDOWPOS
*winpos
= (WINDOWPOS
*)lparam
;
1894 WINDOWPOS my_winpos
= *winpos
;
1896 trace("%s\n", (msg
== WM_WINDOWPOSCHANGING
) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
1897 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1898 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1899 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1901 DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
1903 trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
1904 winpos
->hwnd
, winpos
->hwndInsertAfter
,
1905 winpos
->x
, winpos
->y
, winpos
->cx
, winpos
->cy
, winpos
->flags
);
1907 ok(!memcmp(&my_winpos
, winpos
, sizeof(WINDOWPOS
)),
1908 "DefWindowProc should not change WINDOWPOS values\n");
1917 return DefFrameProcA(hwnd
, mdi_client
, msg
, wparam
, lparam
);
1920 static BOOL
mdi_RegisterWindowClasses(void)
1925 cls
.lpfnWndProc
= mdi_main_wnd_procA
;
1928 cls
.hInstance
= GetModuleHandleA(0);
1930 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
1931 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1932 cls
.lpszMenuName
= NULL
;
1933 cls
.lpszClassName
= "MDI_parent_Class";
1934 if(!RegisterClassA(&cls
)) return FALSE
;
1936 cls
.lpfnWndProc
= mdi_child_wnd_proc_1
;
1937 cls
.lpszClassName
= "MDI_child_Class_1";
1938 if(!RegisterClassA(&cls
)) return FALSE
;
1940 cls
.lpfnWndProc
= mdi_child_wnd_proc_2
;
1941 cls
.lpszClassName
= "MDI_child_Class_2";
1942 if(!RegisterClassA(&cls
)) return FALSE
;
1947 static void test_mdi(void)
1952 if (!mdi_RegisterWindowClasses()) assert(0);
1954 mdi_hwndMain
= CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
1955 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
1956 WS_MAXIMIZEBOX
/*| WS_VISIBLE*/,
1957 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
,
1958 GetDesktopWindow(), 0,
1959 GetModuleHandleA(NULL
), NULL
);
1960 assert(mdi_hwndMain
);
1962 while(GetMessage(&msg, 0, 0, 0))
1964 TranslateMessage(&msg);
1965 DispatchMessage(&msg);
1968 DestroyWindow(mdi_hwndMain
);
1971 static void test_icons(void)
1975 HICON icon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
1976 HICON icon2
= LoadIconA(0, (LPCSTR
)IDI_QUESTION
);
1977 HICON small_icon
= LoadImageA(0, (LPCSTR
)IDI_APPLICATION
, IMAGE_ICON
,
1978 GetSystemMetrics(SM_CXSMICON
), GetSystemMetrics(SM_CYSMICON
), LR_SHARED
);
1981 cls
.cbSize
= sizeof(cls
);
1983 cls
.lpfnWndProc
= DefWindowProcA
;
1987 cls
.hIcon
= LoadIconA(0, (LPCSTR
)IDI_HAND
);
1988 cls
.hIconSm
= small_icon
;
1989 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
1990 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
1991 cls
.lpszMenuName
= NULL
;
1992 cls
.lpszClassName
= "IconWindowClass";
1994 RegisterClassExA(&cls
);
1996 hwnd
= CreateWindowExA(0, "IconWindowClass", "icon test", 0,
1997 100, 100, CW_USEDEFAULT
, CW_USEDEFAULT
, 0, 0, NULL
, NULL
);
2000 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2001 ok( res
== 0, "wrong big icon %p/0\n", res
);
2002 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon
);
2003 ok( res
== 0, "wrong previous big icon %p/0\n", res
);
2004 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2005 ok( res
== icon
, "wrong big icon after set %p/%p\n", res
, icon
);
2006 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_BIG
, (LPARAM
)icon2
);
2007 ok( res
== icon
, "wrong previous big icon %p/%p\n", res
, icon
);
2008 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2009 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
2011 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2012 ok( res
== 0, "wrong small icon %p/0\n", res
);
2013 /* this test is XP specific */
2014 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
2015 ok( res != 0, "wrong small icon %p\n", res );*/
2016 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)icon
);
2017 ok( res
== 0, "wrong previous small icon %p/0\n", res
);
2018 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2019 ok( res
== icon
, "wrong small icon after set %p/%p\n", res
, icon
);
2020 /* this test is XP specific */
2021 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
2022 ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
2023 res
= (HICON
)SendMessageA( hwnd
, WM_SETICON
, ICON_SMALL
, (LPARAM
)small_icon
);
2024 ok( res
== icon
, "wrong previous small icon %p/%p\n", res
, icon
);
2025 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_SMALL
, 0 );
2026 ok( res
== small_icon
, "wrong small icon after set %p/%p\n", res
, small_icon
);
2027 /* this test is XP specific */
2028 /*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
2029 ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
2031 /* make sure the big icon hasn't changed */
2032 res
= (HICON
)SendMessageA( hwnd
, WM_GETICON
, ICON_BIG
, 0 );
2033 ok( res
== icon2
, "wrong big icon after set %p/%p\n", res
, icon2
);
2035 DestroyWindow( hwnd
);
2038 static LRESULT WINAPI
nccalcsize_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2040 if (msg
== WM_NCCALCSIZE
)
2042 RECT
*rect
= (RECT
*)lparam
;
2043 /* first time around increase the rectangle, next time decrease it */
2044 if (rect
->left
== 100) InflateRect( rect
, 10, 10 );
2045 else InflateRect( rect
, -10, -10 );
2048 return DefWindowProcA( hwnd
, msg
, wparam
, lparam
);
2051 static void test_SetWindowPos(HWND hwnd
, HWND hwnd2
)
2053 RECT orig_win_rc
, rect
;
2055 HWND hwnd_grandchild
, hwnd_child
, hwnd_child2
;
2060 SetRect(&rect
, 111, 222, 333, 444);
2061 ok(!GetWindowRect(0, &rect
), "GetWindowRect succeeded\n");
2062 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
2063 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2065 SetRect(&rect
, 111, 222, 333, 444);
2066 ok(!GetClientRect(0, &rect
), "GetClientRect succeeded\n");
2067 ok(rect
.left
== 111 && rect
.top
== 222 && rect
.right
== 333 && rect
.bottom
== 444,
2068 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2070 GetWindowRect(hwnd
, &orig_win_rc
);
2072 old_proc
= SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)nccalcsize_proc
);
2073 ret
= SetWindowPos(hwnd
, 0, 100, 100, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
2074 ok(ret
, "Got %d\n", ret
);
2075 GetWindowRect( hwnd
, &rect
);
2076 ok( rect
.left
== 100 && rect
.top
== 100 && rect
.right
== 100 && rect
.bottom
== 100,
2077 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2078 GetClientRect( hwnd
, &rect
);
2079 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2080 ok( rect
.left
== 90 && rect
.top
== 90 && rect
.right
== 110 && rect
.bottom
== 110,
2081 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2083 ret
= SetWindowPos(hwnd
, 0, 200, 200, 0, 0, SWP_NOZORDER
|SWP_FRAMECHANGED
);
2084 ok(ret
, "Got %d\n", ret
);
2085 GetWindowRect( hwnd
, &rect
);
2086 ok( rect
.left
== 200 && rect
.top
== 200 && rect
.right
== 200 && rect
.bottom
== 200,
2087 "invalid window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2088 GetClientRect( hwnd
, &rect
);
2089 MapWindowPoints( hwnd
, 0, (POINT
*)&rect
, 2 );
2090 ok( rect
.left
== 210 && rect
.top
== 210 && rect
.right
== 190 && rect
.bottom
== 190,
2091 "invalid client rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
2093 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2094 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2095 ok(ret
, "Got %d\n", ret
);
2096 SetWindowLongPtrA( hwnd
, GWLP_WNDPROC
, old_proc
);
2098 /* Win9x truncates coordinates to 16-bit irrespectively */
2101 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE
);
2102 ok(ret
, "Got %d\n", ret
);
2103 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE
);
2104 ok(ret
, "Got %d\n", ret
);
2106 ret
= SetWindowPos(hwnd
, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE
);
2107 ok(ret
, "Got %d\n", ret
);
2108 ret
= SetWindowPos(hwnd
, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE
);
2109 ok(ret
, "Got %d\n", ret
);
2112 ret
= SetWindowPos(hwnd
, 0, orig_win_rc
.left
, orig_win_rc
.top
,
2113 orig_win_rc
.right
, orig_win_rc
.bottom
, 0);
2114 ok(ret
, "Got %d\n", ret
);
2116 ok(!(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
2117 ret
= SetWindowPos(hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2118 ok(ret
, "Got %d\n", ret
);
2119 ok(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
2120 ret
= SetWindowPos(hwnd
, HWND_TOP
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2121 ok(ret
, "Got %d\n", ret
);
2122 ok(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
, "WS_EX_TOPMOST should be set\n");
2123 ret
= SetWindowPos(hwnd
, HWND_NOTOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
2124 ok(ret
, "Got %d\n", ret
);
2125 ok(!(GetWindowLongA(hwnd
, GWL_EXSTYLE
) & WS_EX_TOPMOST
), "WS_EX_TOPMOST should not be set\n");
2127 hwnd_desktop
= GetDesktopWindow();
2128 ok(!!hwnd_desktop
, "Failed to get hwnd_desktop window (%d).\n", GetLastError());
2129 hwnd_child
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2130 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2131 hwnd_grandchild
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd_child
);
2132 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2133 hwnd_child2
= create_tool_window(WS_VISIBLE
|WS_CHILD
, hwnd
);
2134 ok(!!hwnd_child2
, "Failed to create second child window (%d)\n", GetLastError());
2136 ret
= SetWindowPos(hwnd
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2137 ok(ret
, "Got %d\n", ret
);
2138 check_active_state(hwnd
, hwnd
, hwnd
);
2140 ret
= SetWindowPos(hwnd2
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2141 ok(ret
, "Got %d\n", ret
);
2142 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2144 /* Returns TRUE also for windows that are not siblings */
2145 ret
= SetWindowPos(hwnd_child
, hwnd2
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2146 ok(ret
, "Got %d\n", ret
);
2147 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2149 ret
= SetWindowPos(hwnd2
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2150 ok(ret
, "Got %d\n", ret
);
2151 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2153 /* Does not seem to do anything even without passing flags, still returns TRUE */
2154 GetWindowRect(hwnd_child
, &rc1
);
2155 ret
= SetWindowPos(hwnd_child
, hwnd2
, 1, 2, 3, 4, 0);
2156 ok(ret
, "Got %d\n", ret
);
2157 GetWindowRect(hwnd_child
, &rc2
);
2158 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2159 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2160 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2161 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2162 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2164 /* Same thing the other way around. */
2165 GetWindowRect(hwnd2
, &rc1
);
2166 ret
= SetWindowPos(hwnd2
, hwnd_child
, 1, 2, 3, 4, 0);
2167 ok(ret
, "Got %d\n", ret
);
2168 GetWindowRect(hwnd2
, &rc2
);
2169 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2170 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2171 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2172 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2173 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2175 /* .. and with these windows. */
2176 GetWindowRect(hwnd_grandchild
, &rc1
);
2177 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, 0);
2178 ok(ret
, "Got %d\n", ret
);
2179 GetWindowRect(hwnd_grandchild
, &rc2
);
2180 ok(rc1
.left
== rc2
.left
&& rc1
.top
== rc2
.top
&&
2181 rc1
.right
== rc2
.right
&& rc1
.bottom
== rc2
.bottom
,
2182 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2183 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2184 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2186 /* Add SWP_NOZORDER and it will be properly resized. */
2187 GetWindowRect(hwnd_grandchild
, &rc1
);
2188 ret
= SetWindowPos(hwnd_grandchild
, hwnd_child2
, 1, 2, 3, 4, SWP_NOZORDER
);
2189 ok(ret
, "Got %d\n", ret
);
2190 GetWindowRect(hwnd_grandchild
, &rc2
);
2191 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2192 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2193 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2194 rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2195 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2197 /* Given a sibling window, the window is properly resized. */
2198 GetWindowRect(hwnd_child
, &rc1
);
2199 ret
= SetWindowPos(hwnd_child
, hwnd_child2
, 1, 2, 3, 4, 0);
2200 ok(ret
, "Got %d\n", ret
);
2201 GetWindowRect(hwnd_child
, &rc2
);
2202 ok((rc1
.left
+1) == rc2
.left
&& (rc1
.top
+2) == rc2
.top
&&
2203 (rc1
.left
+4) == rc2
.right
&& (rc1
.top
+6) == rc2
.bottom
,
2204 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2205 rc1
.left
+1, rc1
.top
+2, rc1
.left
+4, rc1
.top
+6, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
2206 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2208 /* Involving the desktop window changes things. */
2209 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2210 ok(!ret
, "Got %d\n", ret
);
2211 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2213 GetWindowRect(hwnd_child
, &rc1
);
2214 ret
= SetWindowPos(hwnd_child
, hwnd_desktop
, 0, 0, 0, 0, 0);
2215 ok(!ret
, "Got %d\n", ret
);
2216 GetWindowRect(hwnd_child
, &rc2
);
2217 ok(rc1
.top
== rc2
.top
&& rc1
.left
== rc2
.left
&&
2218 rc1
.bottom
== rc2
.bottom
&& rc1
.right
== rc2
.right
,
2219 "(%d, %d, %d, %d) != (%d, %d, %d, %d)\n",
2220 rc1
.top
, rc1
.left
, rc1
.bottom
, rc1
.right
, rc2
.top
, rc2
.left
, rc2
.bottom
, rc2
.right
);
2221 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2223 ret
= SetWindowPos(hwnd_desktop
, hwnd_child
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2224 ok(!ret
, "Got %d\n", ret
);
2225 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2227 ret
= SetWindowPos(hwnd_desktop
, hwnd
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2228 ok(!ret
, "Got %d\n", ret
);
2229 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2231 ret
= SetWindowPos(hwnd
, hwnd_desktop
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
2232 ok(!ret
, "Got %d\n", ret
);
2233 check_active_state(hwnd2
, hwnd2
, hwnd2
);
2235 DestroyWindow(hwnd_grandchild
);
2236 DestroyWindow(hwnd_child
);
2237 DestroyWindow(hwnd_child2
);
2239 hwnd_child
= create_tool_window(WS_CHILD
|WS_POPUP
|WS_SYSMENU
, hwnd2
);
2240 ok(!!hwnd_child
, "Failed to create child window (%d)\n", GetLastError());
2241 ret
= SetWindowPos(hwnd_child
, NULL
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2242 ok(ret
, "Got %d\n", ret
);
2243 flush_events( TRUE
);
2244 todo_wine
check_active_state(hwnd2
, hwnd2
, hwnd2
);
2245 DestroyWindow(hwnd_child
);
2248 static void test_SetMenu(HWND parent
)
2255 hMenu
= CreateMenu();
2258 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2261 /* fails on (at least) Wine, NT4, XP SP2 */
2262 test_nonclient_area(parent
);
2264 ret
= GetMenu(parent
);
2265 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2266 /* test whether we can destroy a menu assigned to a window */
2267 retok
= DestroyMenu(hMenu
);
2268 ok( retok
, "DestroyMenu error %d\n", GetLastError());
2269 retok
= IsMenu(hMenu
);
2270 ok(!retok
|| broken(retok
) /* nt4 */, "menu handle should be not valid after DestroyMenu\n");
2271 ret
= GetMenu(parent
);
2272 /* This test fails on Win9x */
2274 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2275 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2276 test_nonclient_area(parent
);
2278 hMenu
= CreateMenu();
2282 ret
= GetMenu(parent
);
2283 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2285 ok(!SetMenu(parent
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2286 test_nonclient_area(parent
);
2287 ret
= GetMenu(parent
);
2288 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2290 ok(SetMenu(parent
, hMenu
), "SetMenu on a top level window should not fail\n");
2293 /* fails on (at least) Wine, NT4, XP SP2 */
2294 test_nonclient_area(parent
);
2296 ret
= GetMenu(parent
);
2297 ok(ret
== hMenu
, "unexpected menu id %p\n", ret
);
2299 ok(SetMenu(parent
, 0), "SetMenu(0) on a top level window should not fail\n");
2300 test_nonclient_area(parent
);
2301 ret
= GetMenu(parent
);
2302 ok(ret
== 0, "unexpected menu id %p\n", ret
);
2305 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, parent
, (HMENU
)10, 0, NULL
);
2308 ret
= GetMenu(child
);
2309 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2311 ok(!SetMenu(child
, (HMENU
)20), "SetMenu with invalid menu handle should fail\n");
2312 test_nonclient_area(child
);
2313 ret
= GetMenu(child
);
2314 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2316 ok(!SetMenu(child
, hMenu
), "SetMenu on a child window should fail\n");
2317 test_nonclient_area(child
);
2318 ret
= GetMenu(child
);
2319 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2321 ok(!SetMenu(child
, 0), "SetMenu(0) on a child window should fail\n");
2322 test_nonclient_area(child
);
2323 ret
= GetMenu(child
);
2324 ok(ret
== (HMENU
)10, "unexpected menu id %p\n", ret
);
2326 style
= GetWindowLongA(child
, GWL_STYLE
);
2327 SetWindowLongA(child
, GWL_STYLE
, style
| WS_POPUP
);
2328 ok(SetMenu(child
, hMenu
), "SetMenu on a popup child window should not fail\n");
2329 ok(SetMenu(child
, 0), "SetMenu on a popup child window should not fail\n");
2330 SetWindowLongA(child
, GWL_STYLE
, style
);
2332 SetWindowLongA(child
, GWL_STYLE
, style
| WS_OVERLAPPED
);
2333 ok(!SetMenu(child
, hMenu
), "SetMenu on an overlapped child window should fail\n");
2334 SetWindowLongA(child
, GWL_STYLE
, style
);
2336 DestroyWindow(child
);
2340 static void test_window_tree(HWND parent
, const DWORD
*style
, const int *order
, int total
)
2342 HWND child
[5], hwnd
;
2347 hwnd
= GetWindow(parent
, GW_CHILD
);
2348 ok(!hwnd
, "have to start without children to perform the test\n");
2350 for (i
= 0; i
< total
; i
++)
2352 if (style
[i
] & DS_CONTROL
)
2354 child
[i
] = CreateWindowExA(0, (LPCSTR
)MAKEINTATOM(32770), "", style
[i
] & ~WS_VISIBLE
,
2355 0,0,0,0, parent
, (HMENU
)i
, 0, NULL
);
2356 if (style
[i
] & WS_VISIBLE
)
2357 ShowWindow(child
[i
], SW_SHOW
);
2359 SetWindowPos(child
[i
], HWND_BOTTOM
, 0,0,10,10, SWP_NOACTIVATE
);
2362 child
[i
] = CreateWindowExA(0, "static", "", style
[i
], 0,0,10,10,
2363 parent
, (HMENU
)i
, 0, NULL
);
2364 trace("child[%ld] = %p\n", i
, child
[i
]);
2365 ok(child
[i
] != 0, "CreateWindowEx failed to create child window\n");
2368 hwnd
= GetWindow(parent
, GW_CHILD
);
2369 ok(hwnd
!= 0, "GetWindow(GW_CHILD) failed\n");
2370 ok(hwnd
== GetWindow(child
[total
- 1], GW_HWNDFIRST
), "GW_HWNDFIRST is wrong\n");
2371 ok(child
[order
[total
- 1]] == GetWindow(child
[0], GW_HWNDLAST
), "GW_HWNDLAST is wrong\n");
2373 for (i
= 0; i
< total
; i
++)
2375 trace("hwnd[%ld] = %p\n", i
, hwnd
);
2376 ok(child
[order
[i
]] == hwnd
, "Z order of child #%ld is wrong\n", i
);
2378 hwnd
= GetWindow(hwnd
, GW_HWNDNEXT
);
2381 for (i
= 0; i
< total
; i
++)
2382 ok(DestroyWindow(child
[i
]), "DestroyWindow failed\n");
2385 static void test_children_zorder(HWND parent
)
2387 const DWORD simple_style
[5] = { WS_CHILD
, WS_CHILD
, WS_CHILD
, WS_CHILD
,
2389 const int simple_order
[5] = { 0, 1, 2, 3, 4 };
2391 const DWORD complex_style
[5] = { WS_CHILD
, WS_CHILD
| WS_MAXIMIZE
,
2392 WS_CHILD
| WS_VISIBLE
, WS_CHILD
,
2393 WS_CHILD
| WS_MAXIMIZE
| WS_VISIBLE
};
2394 const int complex_order_1
[1] = { 0 };
2395 const int complex_order_2
[2] = { 1, 0 };
2396 const int complex_order_3
[3] = { 1, 0, 2 };
2397 const int complex_order_4
[4] = { 1, 0, 2, 3 };
2398 const int complex_order_5
[5] = { 4, 1, 0, 2, 3 };
2399 const DWORD complex_style_6
[3] = { WS_CHILD
| WS_VISIBLE
,
2400 WS_CHILD
| WS_CLIPSIBLINGS
| DS_CONTROL
| WS_VISIBLE
,
2401 WS_CHILD
| WS_VISIBLE
};
2402 const int complex_order_6
[3] = { 0, 1, 2 };
2404 /* simple WS_CHILD */
2405 test_window_tree(parent
, simple_style
, simple_order
, 5);
2407 /* complex children styles */
2408 test_window_tree(parent
, complex_style
, complex_order_1
, 1);
2409 test_window_tree(parent
, complex_style
, complex_order_2
, 2);
2410 test_window_tree(parent
, complex_style
, complex_order_3
, 3);
2411 test_window_tree(parent
, complex_style
, complex_order_4
, 4);
2412 test_window_tree(parent
, complex_style
, complex_order_5
, 5);
2414 /* another set of complex children styles */
2415 test_window_tree(parent
, complex_style_6
, complex_order_6
, 3);
2418 #define check_z_order(hwnd, next, prev, owner, topmost) \
2419 check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
2422 static void check_z_order_debug(HWND hwnd
, HWND next
, HWND prev
, HWND owner
,
2423 BOOL topmost
, const char *file
, int line
)
2428 test
= GetWindow(hwnd
, GW_HWNDNEXT
);
2429 /* skip foreign windows */
2430 while (test
&& test
!= next
&&
2431 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2432 UlongToHandle(GetWindowLongPtrA(test
, GWLP_HINSTANCE
)) != GetModuleHandleA(NULL
) ||
2433 GetWindow(test
, GW_OWNER
) == next
))
2435 /*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2436 test
= GetWindow(test
, GW_HWNDNEXT
);
2438 ok_(file
, line
)(next
== test
, "%p: expected next %p, got %p\n", hwnd
, next
, test
);
2440 test
= GetWindow(hwnd
, GW_HWNDPREV
);
2441 /* skip foreign windows */
2442 while (test
&& test
!= prev
&&
2443 (GetWindowThreadProcessId(test
, NULL
) != our_pid
||
2444 UlongToHandle(GetWindowLongPtrA(test
, GWLP_HINSTANCE
)) != GetModuleHandleA(NULL
) ||
2445 GetWindow(test
, GW_OWNER
) == hwnd
))
2447 /*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
2448 test
= GetWindow(test
, GW_HWNDPREV
);
2450 ok_(file
, line
)(prev
== test
, "%p: expected prev %p, got %p\n", hwnd
, prev
, test
);
2452 test
= GetWindow(hwnd
, GW_OWNER
);
2453 ok_(file
, line
)(owner
== test
, "%p: expected owner %p, got %p\n", hwnd
, owner
, test
);
2455 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
2456 ok_(file
, line
)(!(ex_style
& WS_EX_TOPMOST
) == !topmost
, "%p: expected %stopmost\n",
2457 hwnd
, topmost
? "" : "NOT ");
2460 static void test_popup_zorder(HWND hwnd_D
, HWND hwnd_E
, DWORD style
)
2462 HWND hwnd_A
, hwnd_B
, hwnd_C
, hwnd_F
;
2464 trace("hwnd_D %p, hwnd_E %p\n", hwnd_D
, hwnd_E
);
2466 SetWindowPos(hwnd_E
, hwnd_D
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2468 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2469 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2471 hwnd_F
= CreateWindowExA(0, "MainWindowClass", "Owner window",
2472 WS_OVERLAPPED
| WS_CAPTION
,
2474 0, 0, GetModuleHandleA(NULL
), NULL
);
2475 trace("hwnd_F %p\n", hwnd_F
);
2476 check_z_order(hwnd_F
, hwnd_D
, 0, 0, FALSE
);
2478 SetWindowPos(hwnd_F
, hwnd_E
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2479 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2480 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2481 check_z_order(hwnd_D
, hwnd_E
, 0, 0, FALSE
);
2483 hwnd_C
= CreateWindowExA(0, "MainWindowClass", NULL
,
2486 hwnd_F
, 0, GetModuleHandleA(NULL
), NULL
);
2487 trace("hwnd_C %p\n", hwnd_C
);
2488 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2489 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2490 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2491 check_z_order(hwnd_C
, hwnd_D
, 0, hwnd_F
, FALSE
);
2493 hwnd_B
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2496 hwnd_F
, 0, GetModuleHandleA(NULL
), NULL
);
2497 trace("hwnd_B %p\n", hwnd_B
);
2498 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2499 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2500 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2501 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2502 check_z_order(hwnd_B
, hwnd_C
, 0, hwnd_F
, TRUE
);
2504 hwnd_A
= CreateWindowExA(WS_EX_TOPMOST
, "MainWindowClass", NULL
,
2507 0, 0, GetModuleHandleA(NULL
), NULL
);
2508 trace("hwnd_A %p\n", hwnd_A
);
2509 check_z_order(hwnd_F
, 0, hwnd_E
, 0, FALSE
);
2510 check_z_order(hwnd_E
, hwnd_F
, hwnd_D
, 0, FALSE
);
2511 check_z_order(hwnd_D
, hwnd_E
, hwnd_C
, 0, FALSE
);
2512 check_z_order(hwnd_C
, hwnd_D
, hwnd_B
, hwnd_F
, FALSE
);
2513 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2514 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2516 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
);
2518 /* move hwnd_F and its popups up */
2519 SetWindowPos(hwnd_F
, HWND_TOP
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2520 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2521 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2522 check_z_order(hwnd_F
, hwnd_D
, hwnd_C
, 0, FALSE
);
2523 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2524 check_z_order(hwnd_B
, hwnd_C
, hwnd_A
, hwnd_F
, TRUE
);
2525 check_z_order(hwnd_A
, hwnd_B
, 0, 0, TRUE
);
2527 /* move hwnd_F and its popups down */
2528 #if 0 /* enable once Wine is fixed to pass this test */
2529 SetWindowPos(hwnd_F
, HWND_BOTTOM
, 0,0,0,0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_NOACTIVATE
);
2530 check_z_order(hwnd_F
, 0, hwnd_C
, 0, FALSE
);
2531 check_z_order(hwnd_C
, hwnd_F
, hwnd_B
, hwnd_F
, FALSE
);
2532 check_z_order(hwnd_B
, hwnd_C
, hwnd_E
, hwnd_F
, FALSE
);
2533 check_z_order(hwnd_E
, hwnd_B
, hwnd_D
, 0, FALSE
);
2534 check_z_order(hwnd_D
, hwnd_E
, hwnd_A
, 0, FALSE
);
2535 check_z_order(hwnd_A
, hwnd_D
, 0, 0, TRUE
);
2538 /* make hwnd_C owned by a topmost window */
2539 DestroyWindow( hwnd_C
);
2540 hwnd_C
= CreateWindowExA(0, "MainWindowClass", NULL
,
2543 hwnd_A
, 0, GetModuleHandleA(NULL
), NULL
);
2544 trace("hwnd_C %p\n", hwnd_C
);
2545 check_z_order(hwnd_E
, 0, hwnd_D
, 0, FALSE
);
2546 check_z_order(hwnd_D
, hwnd_E
, hwnd_F
, 0, FALSE
);
2547 check_z_order(hwnd_F
, hwnd_D
, hwnd_B
, 0, FALSE
);
2548 check_z_order(hwnd_B
, hwnd_F
, hwnd_A
, hwnd_F
, TRUE
);
2549 check_z_order(hwnd_A
, hwnd_B
, hwnd_C
, 0, TRUE
);
2550 check_z_order(hwnd_C
, hwnd_A
, 0, hwnd_A
, TRUE
);
2552 DestroyWindow(hwnd_A
);
2553 DestroyWindow(hwnd_B
);
2554 DestroyWindow(hwnd_C
);
2555 DestroyWindow(hwnd_F
);
2558 static void test_vis_rgn( HWND hwnd
)
2560 RECT win_rect
, rgn_rect
;
2561 HRGN hrgn
= CreateRectRgn( 0, 0, 0, 0 );
2564 ShowWindow(hwnd
,SW_SHOW
);
2565 hdc
= GetDC( hwnd
);
2566 ok( GetRandomRgn( hdc
, hrgn
, SYSRGN
) != 0, "GetRandomRgn failed\n" );
2567 GetWindowRect( hwnd
, &win_rect
);
2568 GetRgnBox( hrgn
, &rgn_rect
);
2571 trace("win9x, mapping to screen coords\n");
2572 MapWindowPoints( hwnd
, 0, (POINT
*)&rgn_rect
, 2 );
2574 trace("win: %d,%d-%d,%d\n", win_rect
.left
, win_rect
.top
, win_rect
.right
, win_rect
.bottom
);
2575 trace("rgn: %d,%d-%d,%d\n", rgn_rect
.left
, rgn_rect
.top
, rgn_rect
.right
, rgn_rect
.bottom
);
2576 ok( win_rect
.left
<= rgn_rect
.left
, "rgn left %d not inside win rect %d\n",
2577 rgn_rect
.left
, win_rect
.left
);
2578 ok( win_rect
.top
<= rgn_rect
.top
, "rgn top %d not inside win rect %d\n",
2579 rgn_rect
.top
, win_rect
.top
);
2580 ok( win_rect
.right
>= rgn_rect
.right
, "rgn right %d not inside win rect %d\n",
2581 rgn_rect
.right
, win_rect
.right
);
2582 ok( win_rect
.bottom
>= rgn_rect
.bottom
, "rgn bottom %d not inside win rect %d\n",
2583 rgn_rect
.bottom
, win_rect
.bottom
);
2584 ReleaseDC( hwnd
, hdc
);
2587 static LRESULT WINAPI
set_focus_on_activate_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
2589 if (msg
== WM_ACTIVATE
&& LOWORD(wp
) == WA_ACTIVE
)
2591 HWND child
= GetWindow(hwnd
, GW_CHILD
);
2592 ok(child
!= 0, "couldn't find child window\n");
2594 ok(GetFocus() == child
, "Focus should be on child %p\n", child
);
2597 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
2600 static void test_SetFocus(HWND hwnd
)
2602 HWND child
, child2
, ret
;
2603 WNDPROC old_wnd_proc
;
2605 /* check if we can set focus to non-visible windows */
2607 ShowWindow(hwnd
, SW_SHOW
);
2610 ok( GetFocus() == hwnd
, "Failed to set focus to visible window %p\n", hwnd
);
2611 ok( GetWindowLongA(hwnd
,GWL_STYLE
) & WS_VISIBLE
, "Window %p not visible\n", hwnd
);
2612 ShowWindow(hwnd
, SW_HIDE
);
2615 ok( GetFocus() == hwnd
, "Failed to set focus to invisible window %p\n", hwnd
);
2616 ok( !(GetWindowLongA(hwnd
,GWL_STYLE
) & WS_VISIBLE
), "Window %p still visible\n", hwnd
);
2617 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2620 ok( GetFocus() == child
, "Failed to set focus to invisible child %p\n", child
);
2621 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2622 ShowWindow(child
, SW_SHOW
);
2623 ok( GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
, "Child %p is not visible\n", child
);
2624 ok( GetFocus() == child
, "Focus no longer on child %p\n", child
);
2625 ShowWindow(child
, SW_HIDE
);
2626 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2627 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2628 ShowWindow(child
, SW_SHOW
);
2629 child2
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 0, 0, child
, 0, 0, NULL
);
2631 ShowWindow(child2
, SW_SHOW
);
2633 ShowWindow(child
, SW_HIDE
);
2634 ok( !(GetWindowLongA(child
,GWL_STYLE
) & WS_VISIBLE
), "Child %p is visible\n", child
);
2635 ok( GetFocus() == child2
, "Focus should be on %p, not %p\n", child2
, GetFocus() );
2636 ShowWindow(child
, SW_SHOW
);
2638 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2639 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_HIDEWINDOW
);
2640 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2642 ShowWindow(child
, SW_HIDE
);
2644 ok( GetFocus() == hwnd
, "Focus should be on parent %p, not %p\n", hwnd
, GetFocus() );
2645 SetWindowPos(child
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_SHOWWINDOW
);
2646 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2647 ShowWindow(child
, SW_HIDE
);
2648 ok( GetFocus() == hwnd
, "Focus should still be on parent %p, not %p\n", hwnd
, GetFocus() );
2650 ShowWindow(hwnd
, SW_SHOW
);
2651 ShowWindow(child
, SW_SHOW
);
2653 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2654 EnableWindow(hwnd
, FALSE
);
2655 ok( GetFocus() == child
, "Focus should still be on child %p\n", child
);
2656 EnableWindow(hwnd
, TRUE
);
2658 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2659 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2660 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2662 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2663 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2664 ShowWindow(hwnd
, SW_RESTORE
);
2665 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2666 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2667 ShowWindow(hwnd
, SW_SHOWMINIMIZED
);
2668 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2669 ok( GetFocus() != child
, "Focus should not be on child %p\n", child
);
2671 ok( GetFocus() != hwnd
, "Focus should not be on parent %p\n", hwnd
);
2672 old_wnd_proc
= (WNDPROC
)SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)set_focus_on_activate_proc
);
2673 ShowWindow(hwnd
, SW_RESTORE
);
2674 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2676 ok( GetFocus() == child
, "Focus should be on child %p, not %p\n", child
, GetFocus() );
2677 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (LONG_PTR
)old_wnd_proc
);
2680 SetParent( child
, GetDesktopWindow());
2681 SetParent( child2
, child
);
2682 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2683 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2684 ret
= SetFocus( child2
);
2685 ok( ret
== 0, "SetFocus %p should fail\n", child2
);
2686 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2687 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2688 ret
= SetFocus( child
);
2689 ok( ret
== 0, "SetFocus %p should fail\n", child
);
2690 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2691 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2692 SetWindowLongW( child
, GWL_STYLE
, WS_POPUP
|WS_CHILD
);
2694 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
2695 ok( GetFocus() == child2
, "Focus should be on child2 %p\n", child2
);
2697 ok( GetActiveWindow() == hwnd
, "parent window %p should be active\n", hwnd
);
2698 ok( GetFocus() == hwnd
, "Focus should be on parent %p\n", hwnd
);
2700 ok( GetActiveWindow() == child
, "child window %p should be active\n", child
);
2701 ok( GetFocus() == child
, "Focus should be on child %p\n", child
);
2703 DestroyWindow( child2
);
2704 DestroyWindow( child
);
2707 static void test_SetActiveWindow(HWND hwnd
)
2711 flush_events( TRUE
);
2712 ShowWindow(hwnd
, SW_HIDE
);
2715 check_wnd_state(0, 0, 0, 0);
2717 /*trace("testing SetActiveWindow %p\n", hwnd);*/
2719 ShowWindow(hwnd
, SW_SHOW
);
2720 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2722 hwnd2
= SetActiveWindow(0);
2723 ok(hwnd2
== hwnd
, "SetActiveWindow returned %p instead of %p\n", hwnd2
, hwnd
);
2724 if (!GetActiveWindow()) /* doesn't always work on vista */
2726 check_wnd_state(0, 0, 0, 0);
2727 hwnd2
= SetActiveWindow(hwnd
);
2728 ok(hwnd2
== 0, "SetActiveWindow returned %p instead of 0\n", hwnd2
);
2730 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2732 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2733 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2735 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2736 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2738 ShowWindow(hwnd
, SW_HIDE
);
2739 check_wnd_state(0, 0, 0, 0);
2741 /*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/
2742 SetActiveWindow(hwnd
);
2743 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2745 ShowWindow(hwnd
, SW_SHOW
);
2746 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2748 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2749 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2751 DestroyWindow(hwnd2
);
2752 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2754 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2755 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2757 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2758 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2760 DestroyWindow(hwnd2
);
2761 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2764 struct create_window_thread_params
2767 HANDLE window_created
;
2768 HANDLE test_finished
;
2771 static DWORD WINAPI
create_window_thread(void *param
)
2773 struct create_window_thread_params
*p
= param
;
2777 p
->window
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
2779 ret
= SetEvent(p
->window_created
);
2780 ok(ret
, "SetEvent failed, last error %#x.\n", GetLastError());
2782 res
= WaitForSingleObject(p
->test_finished
, INFINITE
);
2783 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
2785 DestroyWindow(p
->window
);
2789 static void test_SetForegroundWindow(HWND hwnd
)
2791 struct create_window_thread_params thread_params
;
2799 flush_events( TRUE
);
2800 ShowWindow(hwnd
, SW_HIDE
);
2803 check_wnd_state(0, 0, 0, 0);
2805 /*trace("testing SetForegroundWindow %p\n", hwnd);*/
2807 ShowWindow(hwnd
, SW_SHOW
);
2808 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2810 hwnd2
= SetActiveWindow(0);
2811 ok(hwnd2
== hwnd
, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2
, hwnd
);
2812 if (GetActiveWindow() == hwnd
) /* doesn't always work on vista */
2813 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2815 check_wnd_state(0, 0, 0, 0);
2817 ret
= SetForegroundWindow(hwnd
);
2820 skip( "SetForegroundWindow not working\n" );
2823 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2825 SetLastError(0xdeadbeef);
2826 ret
= SetForegroundWindow(0);
2827 ok(!ret
, "SetForegroundWindow returned TRUE instead of FALSE\n");
2828 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
||
2829 broken(GetLastError() == 0xdeadbeef), /* win9x */
2830 "got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
2831 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2833 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2834 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2836 SetWindowPos(hwnd
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_SHOWWINDOW
);
2837 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2839 hwnd2
= GetForegroundWindow();
2840 ok(hwnd2
== hwnd
, "Wrong foreground window %p\n", hwnd2
);
2841 ret
= SetForegroundWindow( GetDesktopWindow() );
2842 ok(ret
, "SetForegroundWindow(desktop) error: %d\n", GetLastError());
2843 hwnd2
= GetForegroundWindow();
2844 ok(hwnd2
!= hwnd
, "Wrong foreground window %p\n", hwnd2
);
2846 ShowWindow(hwnd
, SW_HIDE
);
2847 check_wnd_state(0, 0, 0, 0);
2849 /*trace("testing SetForegroundWindow on an invisible window %p\n", hwnd);*/
2850 ret
= SetForegroundWindow(hwnd
);
2851 ok(ret
|| broken(!ret
), /* win98 */ "SetForegroundWindow returned FALSE instead of TRUE\n");
2852 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2854 ShowWindow(hwnd
, SW_SHOW
);
2855 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2857 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2858 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2860 DestroyWindow(hwnd2
);
2861 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2863 hwnd2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
|WS_VISIBLE
, 0, 0, 0, 0, hwnd
, 0, 0, NULL
);
2864 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2866 SetWindowPos(hwnd2
,0,0,0,0,0,SWP_NOZORDER
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOACTIVATE
|SWP_HIDEWINDOW
);
2867 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2869 DestroyWindow(hwnd2
);
2870 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2872 hwnd2
= CreateWindowA("static", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 0, 0, 0, 0, 0, 0);
2873 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2875 thread_params
.window_created
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2876 ok(!!thread_params
.window_created
, "CreateEvent failed, last error %#x.\n", GetLastError());
2877 thread_params
.test_finished
= CreateEventW(NULL
, FALSE
, FALSE
, NULL
);
2878 ok(!!thread_params
.test_finished
, "CreateEvent failed, last error %#x.\n", GetLastError());
2879 thread
= CreateThread(NULL
, 0, create_window_thread
, &thread_params
, 0, &tid
);
2880 ok(!!thread
, "Failed to create thread, last error %#x.\n", GetLastError());
2881 res
= WaitForSingleObject(thread_params
.window_created
, INFINITE
);
2882 ok(res
== WAIT_OBJECT_0
, "Wait failed (%#x), last error %#x.\n", res
, GetLastError());
2883 check_wnd_state(hwnd2
, thread_params
.window
, hwnd2
, 0);
2885 SetForegroundWindow(hwnd2
);
2886 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2888 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
)) DispatchMessageA(&msg
);
2889 if (0) check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2890 todo_wine
ok(GetActiveWindow() == hwnd2
, "Expected active window %p, got %p.\n", hwnd2
, GetActiveWindow());
2891 todo_wine
ok(GetFocus() == hwnd2
, "Expected focus window %p, got %p.\n", hwnd2
, GetFocus());
2893 SetForegroundWindow(hwnd
);
2894 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2895 style
= GetWindowLongA(hwnd2
, GWL_STYLE
) | WS_CHILD
;
2896 ok(SetWindowLongA(hwnd2
, GWL_STYLE
, style
), "SetWindowLong failed\n");
2897 ok(SetForegroundWindow(hwnd2
), "SetForegroundWindow failed\n");
2898 check_wnd_state(hwnd2
, hwnd2
, hwnd2
, 0);
2900 SetForegroundWindow(hwnd
);
2901 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2902 ok(SetWindowLongA(hwnd2
, GWL_STYLE
, style
& (~WS_POPUP
)), "SetWindowLong failed\n");
2903 ok(!SetForegroundWindow(hwnd2
), "SetForegroundWindow failed\n");
2904 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2906 SetEvent(thread_params
.test_finished
);
2907 WaitForSingleObject(thread
, INFINITE
);
2908 CloseHandle(thread_params
.test_finished
);
2909 CloseHandle(thread_params
.window_created
);
2910 CloseHandle(thread
);
2911 DestroyWindow(hwnd2
);
2914 static WNDPROC old_button_proc
;
2916 static LRESULT WINAPI
button_hook_proc(HWND button
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
2921 key_state
= GetKeyState(VK_LBUTTON
);
2922 ok(!(key_state
& 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state
);
2924 ret
= CallWindowProcA(old_button_proc
, button
, msg
, wparam
, lparam
);
2926 if (msg
== WM_LBUTTONDOWN
)
2930 check_wnd_state(button
, button
, button
, button
);
2932 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2934 trace("hwnd %p\n", hwnd
);
2936 check_wnd_state(button
, button
, button
, button
);
2938 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
2940 check_wnd_state(button
, button
, button
, button
);
2942 DestroyWindow(hwnd
);
2944 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2946 trace("hwnd %p\n", hwnd
);
2948 check_wnd_state(button
, button
, button
, button
);
2950 /* button wnd proc should release capture on WM_KILLFOCUS if it does
2951 * match internal button state.
2953 SendMessageA(button
, WM_KILLFOCUS
, 0, 0);
2954 check_wnd_state(button
, button
, button
, 0);
2956 ShowWindow(hwnd
, SW_SHOW
);
2957 check_wnd_state(hwnd
, hwnd
, hwnd
, 0);
2959 capture
= SetCapture(hwnd
);
2960 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2962 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
2964 DestroyWindow(hwnd
);
2966 check_wnd_state(button
, 0, button
, 0);
2972 static void test_capture_1(void)
2974 HWND button
, capture
;
2976 capture
= GetCapture();
2977 ok(capture
== 0, "GetCapture() = %p\n", capture
);
2979 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
2981 trace("button %p\n", button
);
2983 old_button_proc
= (WNDPROC
)SetWindowLongPtrA(button
, GWLP_WNDPROC
, (LONG_PTR
)button_hook_proc
);
2985 SendMessageA(button
, WM_LBUTTONDOWN
, 0, 0);
2987 capture
= SetCapture(button
);
2988 ok(capture
== 0, "SetCapture() = %p\n", capture
);
2989 check_wnd_state(button
, 0, button
, button
);
2991 DestroyWindow(button
);
2992 /* old active window test depends on previously executed window
2993 * activation tests, and fails under NT4.
2994 check_wnd_state(oldActive, 0, oldFocus, 0);*/
2997 static void test_capture_2(void)
2999 HWND button
, hwnd
, capture
, oldFocus
, oldActive
;
3001 oldFocus
= GetFocus();
3002 oldActive
= GetActiveWindow();
3003 check_wnd_state(oldActive
, 0, oldFocus
, 0);
3005 button
= CreateWindowExA(0, "button", NULL
, WS_POPUP
| WS_VISIBLE
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3007 trace("button %p\n", button
);
3009 check_wnd_state(button
, button
, button
, 0);
3011 capture
= SetCapture(button
);
3012 ok(capture
== 0, "SetCapture() = %p\n", capture
);
3014 check_wnd_state(button
, button
, button
, button
);
3016 /* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
3017 * internal button state.
3019 SendMessageA(button
, WM_KILLFOCUS
, 0, 0);
3020 check_wnd_state(button
, button
, button
, button
);
3022 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3024 trace("hwnd %p\n", hwnd
);
3026 check_wnd_state(button
, button
, button
, button
);
3028 ShowWindow(hwnd
, SW_SHOWNOACTIVATE
);
3030 check_wnd_state(button
, button
, button
, button
);
3032 DestroyWindow(hwnd
);
3034 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 10, 10, 0, 0, 0, NULL
);
3036 trace("hwnd %p\n", hwnd
);
3038 check_wnd_state(button
, button
, button
, button
);
3040 ShowWindow(hwnd
, SW_SHOW
);
3042 check_wnd_state(hwnd
, hwnd
, hwnd
, button
);
3044 capture
= SetCapture(hwnd
);
3045 ok(capture
== button
, "SetCapture() = %p\n", capture
);
3047 check_wnd_state(hwnd
, hwnd
, hwnd
, hwnd
);
3049 DestroyWindow(hwnd
);
3050 check_wnd_state(button
, button
, button
, 0);
3052 DestroyWindow(button
);
3053 check_wnd_state(oldActive
, 0, oldFocus
, 0);
3056 static void test_capture_3(HWND hwnd1
, HWND hwnd2
)
3060 ShowWindow(hwnd1
, SW_HIDE
);
3061 ShowWindow(hwnd2
, SW_HIDE
);
3063 ok(!IsWindowVisible(hwnd1
), "%p should be invisible\n", hwnd1
);
3064 ok(!IsWindowVisible(hwnd2
), "%p should be invisible\n", hwnd2
);
3067 check_wnd_state(0, 0, 0, hwnd1
);
3070 check_wnd_state(0, 0, 0, hwnd2
);
3072 ShowWindow(hwnd1
, SW_SHOW
);
3073 check_wnd_state(hwnd1
, hwnd1
, hwnd1
, hwnd2
);
3075 ret
= ReleaseCapture();
3076 ok (ret
, "releasecapture did not return TRUE.\n");
3077 ret
= ReleaseCapture();
3078 ok (ret
, "releasecapture did not return TRUE after second try.\n");
3081 static LRESULT CALLBACK
test_capture_4_proc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
3084 HWND cap_wnd
, cap_wnd2
, set_cap_wnd
;
3088 case WM_CAPTURECHANGED
:
3090 /* now try to release capture from menu. this should fail */
3091 if (pGetGUIThreadInfo
)
3093 memset(>i
, 0, sizeof(GUITHREADINFO
));
3094 gti
.cbSize
= sizeof(GUITHREADINFO
);
3095 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
3096 ok(status
, "GetGUIThreadInfo() failed!\n");
3097 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
3099 cap_wnd
= GetCapture();
3101 /* check that re-setting the capture for the menu fails */
3102 set_cap_wnd
= SetCapture(cap_wnd
);
3103 ok(!set_cap_wnd
|| broken(set_cap_wnd
== cap_wnd
), /* nt4 */
3104 "SetCapture should have failed!\n");
3107 DestroyWindow(hWnd
);
3111 /* check that SetCapture fails for another window and that it does not touch the error code */
3112 set_cap_wnd
= SetCapture(hWnd
);
3113 ok(!set_cap_wnd
, "SetCapture should have failed!\n");
3115 /* check that ReleaseCapture fails and does not touch the error code */
3116 status
= ReleaseCapture();
3117 ok(!status
, "ReleaseCapture should have failed!\n");
3119 /* check that thread info did not change */
3120 if (pGetGUIThreadInfo
)
3122 memset(>i
, 0, sizeof(GUITHREADINFO
));
3123 gti
.cbSize
= sizeof(GUITHREADINFO
);
3124 status
= pGetGUIThreadInfo(GetCurrentThreadId(), >i
);
3125 ok(status
, "GetGUIThreadInfo() failed!\n");
3126 ok(gti
.flags
& GUI_INMENUMODE
, "Thread info incorrect (flags=%08X)!\n", gti
.flags
);
3129 /* verify that no capture change took place */
3130 cap_wnd2
= GetCapture();
3131 ok(cap_wnd2
== cap_wnd
, "Capture changed!\n");
3133 /* we are done. kill the window */
3134 DestroyWindow(hWnd
);
3138 return( DefWindowProcA( hWnd
, msg
, wParam
, lParam
) );
3143 /* Test that no-one can mess around with the current capture while a menu is open */
3144 static void test_capture_4(void)
3150 HINSTANCE hInstance
= GetModuleHandleA( NULL
);
3153 if (!pGetGUIThreadInfo
)
3155 win_skip("GetGUIThreadInfo is not available\n");
3158 wclass
.lpszClassName
= "TestCapture4Class";
3159 wclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
3160 wclass
.lpfnWndProc
= test_capture_4_proc
;
3161 wclass
.hInstance
= hInstance
;
3162 wclass
.hIcon
= LoadIconA( 0, (LPCSTR
)IDI_APPLICATION
);
3163 wclass
.hCursor
= LoadCursorA( 0, (LPCSTR
)IDC_ARROW
);
3164 wclass
.hbrBackground
= (HBRUSH
)( COLOR_WINDOW
+ 1 );
3165 wclass
.lpszMenuName
= 0;
3166 wclass
.cbClsExtra
= 0;
3167 wclass
.cbWndExtra
= 0;
3168 aclass
= RegisterClassA( &wclass
);
3169 ok( aclass
, "RegisterClassA failed with error %d\n", GetLastError());
3170 hwnd
= CreateWindowA( wclass
.lpszClassName
, "MenuTest",
3171 WS_OVERLAPPEDWINDOW
, CW_USEDEFAULT
, 0,
3172 400, 200, NULL
, NULL
, hInstance
, NULL
);
3173 ok(hwnd
!= NULL
, "CreateWindowEx failed with error %d\n", GetLastError());
3175 hmenu
= CreatePopupMenu();
3177 ret
= AppendMenuA( hmenu
, MF_STRING
, 1, "winetest2");
3178 ok( ret
, "AppendMenuA has failed!\n");
3180 /* set main window to have initial capture */
3185 win_skip("TrackPopupMenu test crashes on Win9x/WinMe\n");
3189 /* create popup (it will self-destruct) */
3190 ret
= TrackPopupMenu(hmenu
, TPM_RETURNCMD
, 100, 100, 0, hwnd
, NULL
);
3191 ok( ret
== 0, "TrackPopupMenu returned %d expected zero\n", ret
);
3196 DestroyWindow(hwnd
);
3199 /* PeekMessage wrapper that ignores the messages we don't care about */
3200 static BOOL
peek_message( MSG
*msg
)
3205 ret
= PeekMessageA(msg
, 0, 0, 0, PM_REMOVE
);
3206 } while (ret
&& (msg
->message
== WM_TIMER
|| ignore_message(msg
->message
)));
3210 static void test_keyboard_input(HWND hwnd
)
3215 flush_events( TRUE
);
3216 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
|SWP_SHOWWINDOW
);
3218 flush_events( TRUE
);
3220 ok(GetActiveWindow() == hwnd
, "wrong active window %p\n", GetActiveWindow());
3223 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3225 flush_events( TRUE
);
3227 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3228 ret
= peek_message(&msg
);
3229 ok( ret
, "no message available\n");
3230 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3231 ret
= peek_message(&msg
);
3232 ok( !ret
, "message %04x available\n", msg
.message
);
3234 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3236 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3237 ret
= peek_message(&msg
);
3238 ok(ret
, "no message available\n");
3239 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3240 ret
= peek_message(&msg
);
3241 ok( !ret
, "message %04x available\n", msg
.message
);
3243 ok(GetFocus() == hwnd
, "wrong focus window %p\n", GetFocus());
3245 keybd_event(VK_SPACE
, 0, 0, 0);
3246 if (!peek_message(&msg
))
3248 skip( "keybd_event didn't work, skipping keyboard test\n" );
3251 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3252 ret
= peek_message(&msg
);
3253 ok( !ret
, "message %04x available\n", msg
.message
);
3256 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3258 flush_events( TRUE
);
3260 PostMessageA(hwnd
, WM_KEYDOWN
, 0, 0);
3261 ret
= peek_message(&msg
);
3262 ok(ret
, "no message available\n");
3263 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3264 ret
= peek_message(&msg
);
3265 ok( !ret
, "message %04x available\n", msg
.message
);
3267 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3269 PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN
, 0, 0);
3270 ret
= peek_message(&msg
);
3271 ok(ret
, "no message available\n");
3272 ok(!msg
.hwnd
&& msg
.message
== WM_KEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3273 ret
= peek_message(&msg
);
3274 ok( !ret
, "message %04x available\n", msg
.message
);
3276 ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
3278 keybd_event(VK_SPACE
, 0, 0, 0);
3279 ret
= peek_message(&msg
);
3280 ok(ret
, "no message available\n");
3281 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_SYSKEYDOWN
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3282 ret
= peek_message(&msg
);
3283 ok( !ret
, "message %04x available\n", msg
.message
);
3286 static BOOL
wait_for_message( MSG
*msg
)
3292 ret
= peek_message(msg
);
3295 if (msg
->message
== WM_PAINT
) DispatchMessageA(msg
);
3298 else if (MsgWaitForMultipleObjects( 0, NULL
, FALSE
, 100, QS_ALLINPUT
) == WAIT_TIMEOUT
) break;
3300 if (!ret
) msg
->message
= 0;
3304 static void test_mouse_input(HWND hwnd
)
3314 ShowWindow(hwnd
, SW_SHOWNORMAL
);
3316 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3318 GetWindowRect(hwnd
, &rc
);
3319 trace("main window %p: (%d,%d)-(%d,%d)\n", hwnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3321 popup
= CreateWindowExA(0, "MainWindowClass", NULL
, WS_POPUP
,
3322 rc
.left
, rc
.top
, rc
.right
-rc
.left
, rc
.bottom
-rc
.top
,
3325 ShowWindow(popup
, SW_SHOW
);
3326 UpdateWindow(popup
);
3327 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3329 GetWindowRect(popup
, &rc
);
3330 trace("popup window %p: (%d,%d)-(%d,%d)\n", popup
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
3332 x
= rc
.left
+ (rc
.right
- rc
.left
) / 2;
3333 y
= rc
.top
+ (rc
.bottom
- rc
.top
) / 2;
3334 trace("setting cursor to (%d,%d)\n", x
, y
);
3338 if (x
!= pt
.x
|| y
!= pt
.y
)
3340 skip( "failed to set mouse position, skipping mouse input tests\n" );
3344 flush_events( TRUE
);
3346 /* Check that setting the same position may generate WM_MOUSEMOVE */
3349 ret
= peek_message(&msg
);
3352 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n",
3353 msg
.hwnd
, msg
.message
);
3354 ok(msg
.pt
.x
== x
&& msg
.pt
.y
== y
, "wrong message coords (%d,%d)/(%d,%d)\n",
3355 x
, y
, msg
.pt
.x
, msg
.pt
.y
);
3358 /* force the system to update its internal queue mouse position,
3359 * otherwise it won't generate relative mouse movements below.
3361 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3362 flush_events( TRUE
);
3365 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3366 flush_events( FALSE
);
3367 /* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
3368 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
3370 if (msg
.message
== WM_TIMER
|| ignore_message(msg
.message
)) continue;
3371 ok(msg
.hwnd
== popup
&& msg
.message
== WM_MOUSEMOVE
,
3372 "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3373 DispatchMessageA(&msg
);
3375 ret
= peek_message(&msg
);
3376 ok( !ret
, "message %04x available\n", msg
.message
);
3378 mouse_event(MOUSEEVENTF_MOVE
, -1, -1, 0, 0);
3379 ShowWindow(popup
, SW_HIDE
);
3380 ret
= wait_for_message( &msg
);
3382 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_MOUSEMOVE
, "hwnd %p message %04x\n", msg
.hwnd
, msg
.message
);
3383 flush_events( TRUE
);
3385 mouse_event(MOUSEEVENTF_MOVE
, 1, 1, 0, 0);
3386 ShowWindow(hwnd
, SW_HIDE
);
3387 ret
= wait_for_message( &msg
);
3388 ok( !ret
, "message %04x available\n", msg
.message
);
3389 flush_events( TRUE
);
3391 /* test mouse clicks */
3393 ShowWindow(hwnd
, SW_SHOW
);
3394 SetWindowPos( hwnd
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3395 flush_events( TRUE
);
3396 ShowWindow(popup
, SW_SHOW
);
3397 SetWindowPos( popup
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
3398 flush_events( TRUE
);
3400 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3401 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3402 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3403 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3405 ret
= wait_for_message( &msg
);
3408 skip( "simulating mouse click doesn't work, skipping mouse button tests\n" );
3411 if (msg
.message
== WM_MOUSEMOVE
) /* win2k has an extra WM_MOUSEMOVE here */
3413 ret
= wait_for_message( &msg
);
3414 ok(ret
, "no message available\n");
3417 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3418 msg
.hwnd
, popup
, msg
.message
);
3420 ret
= wait_for_message( &msg
);
3421 ok(ret
, "no message available\n");
3422 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3423 msg
.hwnd
, popup
, msg
.message
);
3425 ret
= wait_for_message( &msg
);
3426 ok(ret
, "no message available\n");
3427 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDBLCLK
, "hwnd %p/%p message %04x\n",
3428 msg
.hwnd
, popup
, msg
.message
);
3430 ret
= wait_for_message( &msg
);
3431 ok(ret
, "no message available\n");
3432 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3433 msg
.hwnd
, popup
, msg
.message
);
3435 ret
= peek_message(&msg
);
3436 ok(!ret
, "message %04x available\n", msg
.message
);
3438 ShowWindow(popup
, SW_HIDE
);
3439 flush_events( TRUE
);
3441 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3442 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3443 mouse_event(MOUSEEVENTF_LEFTDOWN
, 0, 0, 0, 0);
3444 mouse_event(MOUSEEVENTF_LEFTUP
, 0, 0, 0, 0);
3446 ret
= wait_for_message( &msg
);
3447 ok(ret
, "no message available\n");
3448 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3449 msg
.hwnd
, hwnd
, msg
.message
);
3450 ret
= wait_for_message( &msg
);
3451 ok(ret
, "no message available\n");
3452 ok(msg
.hwnd
== hwnd
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3453 msg
.hwnd
, hwnd
, msg
.message
);
3455 test_lbuttondown_flag
= TRUE
;
3456 SendMessageA(hwnd
, WM_COMMAND
, (WPARAM
)popup
, 0);
3457 test_lbuttondown_flag
= FALSE
;
3459 ret
= wait_for_message( &msg
);
3460 ok(ret
, "no message available\n");
3461 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONDOWN
, "hwnd %p/%p message %04x\n",
3462 msg
.hwnd
, popup
, msg
.message
);
3463 ok(peek_message(&msg
), "no message available\n");
3464 ok(msg
.hwnd
== popup
&& msg
.message
== WM_LBUTTONUP
, "hwnd %p/%p message %04x\n",
3465 msg
.hwnd
, popup
, msg
.message
);
3466 ok(peek_message(&msg
), "no message available\n");
3468 /* Test WM_MOUSEACTIVATE */
3469 #define TEST_MOUSEACTIVATE(A,B) \
3470 res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
3471 ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
3473 TEST_MOUSEACTIVATE(HTERROR
,MA_ACTIVATE
);
3474 TEST_MOUSEACTIVATE(HTTRANSPARENT
,MA_ACTIVATE
);
3475 TEST_MOUSEACTIVATE(HTNOWHERE
,MA_ACTIVATE
);
3476 TEST_MOUSEACTIVATE(HTCLIENT
,MA_ACTIVATE
);
3477 TEST_MOUSEACTIVATE(HTCAPTION
,MA_ACTIVATE
);
3478 TEST_MOUSEACTIVATE(HTSYSMENU
,MA_ACTIVATE
);
3479 TEST_MOUSEACTIVATE(HTSIZE
,MA_ACTIVATE
);
3480 TEST_MOUSEACTIVATE(HTMENU
,MA_ACTIVATE
);
3481 TEST_MOUSEACTIVATE(HTHSCROLL
,MA_ACTIVATE
);
3482 TEST_MOUSEACTIVATE(HTVSCROLL
,MA_ACTIVATE
);
3483 TEST_MOUSEACTIVATE(HTMINBUTTON
,MA_ACTIVATE
);
3484 TEST_MOUSEACTIVATE(HTMAXBUTTON
,MA_ACTIVATE
);
3485 TEST_MOUSEACTIVATE(HTLEFT
,MA_ACTIVATE
);
3486 TEST_MOUSEACTIVATE(HTRIGHT
,MA_ACTIVATE
);
3487 TEST_MOUSEACTIVATE(HTTOP
,MA_ACTIVATE
);
3488 TEST_MOUSEACTIVATE(HTTOPLEFT
,MA_ACTIVATE
);
3489 TEST_MOUSEACTIVATE(HTTOPRIGHT
,MA_ACTIVATE
);
3490 TEST_MOUSEACTIVATE(HTBOTTOM
,MA_ACTIVATE
);
3491 TEST_MOUSEACTIVATE(HTBOTTOMLEFT
,MA_ACTIVATE
);
3492 TEST_MOUSEACTIVATE(HTBOTTOMRIGHT
,MA_ACTIVATE
);
3493 TEST_MOUSEACTIVATE(HTBORDER
,MA_ACTIVATE
);
3494 TEST_MOUSEACTIVATE(HTOBJECT
,MA_ACTIVATE
);
3495 TEST_MOUSEACTIVATE(HTCLOSE
,MA_ACTIVATE
);
3496 TEST_MOUSEACTIVATE(HTHELP
,MA_ACTIVATE
);
3499 /* Clear any messages left behind by WM_MOUSEACTIVATE tests */
3500 flush_events( TRUE
);
3502 DestroyWindow(popup
);
3505 static void test_validatergn(HWND hwnd
)
3511 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_VISIBLE
, 10, 10, 10, 10, hwnd
, 0, 0, NULL
);
3512 ShowWindow(hwnd
, SW_SHOW
);
3513 UpdateWindow( hwnd
);
3514 /* test that ValidateRect validates children*/
3515 InvalidateRect( child
, NULL
, 1);
3516 GetWindowRect( child
, &rc
);
3517 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3518 ret
= GetUpdateRect( child
, &rc2
, 0);
3519 ok( ret
== 1, "Expected GetUpdateRect to return non-zero, got %d\n", ret
);
3520 ok( rc2
.right
> rc2
.left
&& rc2
.bottom
> rc2
.top
,
3521 "Update rectangle is empty!\n");
3522 ValidateRect( hwnd
, &rc
);
3523 ret
= GetUpdateRect( child
, &rc2
, 0);
3524 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3525 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3526 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
3527 rc2
.right
, rc2
.bottom
);
3529 /* now test ValidateRgn */
3530 InvalidateRect( child
, NULL
, 1);
3531 GetWindowRect( child
, &rc
);
3532 MapWindowPoints( NULL
, hwnd
, (POINT
*) &rc
, 2);
3533 rgn
= CreateRectRgnIndirect( &rc
);
3534 ValidateRgn( hwnd
, rgn
);
3535 ret
= GetUpdateRect( child
, &rc2
, 0);
3536 ok( !ret
, "Expected GetUpdateRect to return zero, got %d\n", ret
);
3537 ok( rc2
.left
== 0 && rc2
.top
== 0 && rc2
.right
== 0 && rc2
.bottom
== 0,
3538 "Update rectangle %d,%d-%d,%d is not empty!\n", rc2
.left
, rc2
.top
,
3539 rc2
.right
, rc2
.bottom
);
3542 DestroyWindow( child
);
3545 static void nccalchelper(HWND hwnd
, INT x
, INT y
, RECT
*prc
)
3548 MoveWindow( hwnd
, 0, 0, x
, y
, 0);
3549 GetWindowRect( hwnd
, prc
);
3551 DefWindowProcA(hwnd
, WM_NCCALCSIZE
, 0, (LPARAM
)prc
);
3552 trace("window rect is %d,%d - %d,%d, nccalc rect is %d,%d - %d,%d\n",
3553 rc
.left
,rc
.top
,rc
.right
,rc
.bottom
, prc
->left
,prc
->top
,prc
->right
,prc
->bottom
);
3556 static void test_nccalcscroll(HWND parent
)
3559 INT sbheight
= GetSystemMetrics( SM_CYHSCROLL
);
3560 INT sbwidth
= GetSystemMetrics( SM_CXVSCROLL
);
3561 HWND hwnd
= CreateWindowExA(0, "static", NULL
,
3562 WS_CHILD
| WS_VISIBLE
| WS_VSCROLL
| WS_HSCROLL
,
3563 10, 10, 200, 200, parent
, 0, 0, NULL
);
3564 ShowWindow( parent
, SW_SHOW
);
3565 UpdateWindow( parent
);
3567 /* test window too low for a horizontal scroll bar */
3568 nccalchelper( hwnd
, 100, sbheight
, &rc1
);
3569 ok( rc1
.bottom
- rc1
.top
== sbheight
, "Height should be %d size is %d,%d - %d,%d\n",
3570 sbheight
, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3572 /* test window just high enough for a horizontal scroll bar */
3573 nccalchelper( hwnd
, 100, sbheight
+ 1, &rc1
);
3574 ok( rc1
.bottom
- rc1
.top
== 1, "Height should be %d size is %d,%d - %d,%d\n",
3575 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3577 /* test window too narrow for a vertical scroll bar */
3578 nccalchelper( hwnd
, sbwidth
- 1, 100, &rc1
);
3579 ok( rc1
.right
- rc1
.left
== sbwidth
- 1 , "Width should be %d size is %d,%d - %d,%d\n",
3580 sbwidth
- 1, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3582 /* test window just wide enough for a vertical scroll bar */
3583 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
3584 ok( rc1
.right
- rc1
.left
== 0, "Width should be %d size is %d,%d - %d,%d\n",
3585 0, rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3587 /* same test, but with client edge: not enough width */
3588 SetWindowLongA( hwnd
, GWL_EXSTYLE
, WS_EX_CLIENTEDGE
| GetWindowLongA( hwnd
, GWL_EXSTYLE
));
3589 nccalchelper( hwnd
, sbwidth
, 100, &rc1
);
3590 ok( rc1
.right
- rc1
.left
== sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
),
3591 "Width should be %d size is %d,%d - %d,%d\n",
3592 sbwidth
- 2 * GetSystemMetrics(SM_CXEDGE
), rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
);
3594 DestroyWindow( hwnd
);
3597 static void test_SetParent(void)
3599 HWND desktop
= GetDesktopWindow();
3601 HWND ret
, parent
, child1
, child2
, child3
, child4
, sibling
, popup
;
3604 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3605 100, 100, 200, 200, 0, 0, 0, NULL
);
3606 assert(parent
!= 0);
3607 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3608 0, 0, 50, 50, parent
, 0, 0, NULL
);
3609 assert(child1
!= 0);
3610 child2
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3611 0, 0, 50, 50, child1
, 0, 0, NULL
);
3612 assert(child2
!= 0);
3613 child3
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3614 0, 0, 50, 50, child2
, 0, 0, NULL
);
3615 assert(child3
!= 0);
3616 child4
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3617 0, 0, 50, 50, child3
, 0, 0, NULL
);
3618 assert(child4
!= 0);
3620 trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
3621 parent
, child1
, child2
, child3
, child4
);
3623 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
3624 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
3625 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3626 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3627 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3629 ok(!IsChild(desktop
, parent
), "wrong parent/child %p/%p\n", desktop
, parent
);
3630 ok(!IsChild(desktop
, child1
), "wrong parent/child %p/%p\n", desktop
, child1
);
3631 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
3632 ok(!IsChild(desktop
, child3
), "wrong parent/child %p/%p\n", desktop
, child3
);
3633 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
3635 ok(IsChild(parent
, child1
), "wrong parent/child %p/%p\n", parent
, child1
);
3636 ok(!IsChild(desktop
, child2
), "wrong parent/child %p/%p\n", desktop
, child2
);
3637 ok(!IsChild(parent
, child2
), "wrong parent/child %p/%p\n", parent
, child2
);
3638 ok(!IsChild(child1
, child2
), "wrong parent/child %p/%p\n", child1
, child2
);
3639 ok(!IsChild(parent
, child3
), "wrong parent/child %p/%p\n", parent
, child3
);
3640 ok(IsChild(child2
, child3
), "wrong parent/child %p/%p\n", child2
, child3
);
3641 ok(!IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
3642 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
3643 ok(!IsChild(desktop
, child4
), "wrong parent/child %p/%p\n", desktop
, child4
);
3645 if (!is_win9x
) /* Win9x doesn't survive this test */
3647 ok(!SetParent(parent
, child1
), "SetParent should fail\n");
3648 ok(!SetParent(child2
, child3
), "SetParent should fail\n");
3649 ok(SetParent(child1
, parent
) != 0, "SetParent should not fail\n");
3650 ret
= SetParent(parent
, child2
);
3651 todo_wine
ok( !ret
|| broken( ret
!= 0 ), "SetParent should fail\n");
3652 if (ret
) /* nt4, win2k */
3654 ret
= SetParent(parent
, child3
);
3655 ok(ret
!= 0, "SetParent should not fail\n");
3656 ret
= SetParent(child2
, parent
);
3657 ok(!ret
, "SetParent should fail\n");
3658 ret
= SetParent(parent
, child4
);
3659 ok(ret
!= 0, "SetParent should not fail\n");
3660 check_parents(parent
, child4
, child4
, 0, 0, child4
, parent
);
3661 check_parents(child1
, parent
, parent
, parent
, 0, child4
, parent
);
3662 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3663 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3664 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3668 ret
= SetParent(parent
, child3
);
3669 ok(ret
!= 0, "SetParent should not fail\n");
3670 ret
= SetParent(child2
, parent
);
3671 ok(!ret
, "SetParent should fail\n");
3672 ret
= SetParent(parent
, child4
);
3673 ok(!ret
, "SetParent should fail\n");
3674 check_parents(parent
, child3
, child3
, 0, 0, child2
, parent
);
3675 check_parents(child1
, parent
, parent
, parent
, 0, child2
, parent
);
3676 check_parents(child2
, desktop
, parent
, parent
, parent
, child2
, parent
);
3677 check_parents(child3
, child2
, child2
, child2
, 0, child2
, parent
);
3678 check_parents(child4
, desktop
, child2
, child2
, child2
, child4
, parent
);
3682 skip("Win9x/WinMe crash\n");
3684 hMenu
= CreateMenu();
3685 sibling
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3686 100, 100, 200, 200, 0, hMenu
, 0, NULL
);
3687 assert(sibling
!= 0);
3689 ok(SetParent(sibling
, parent
) != 0, "SetParent should not fail\n");
3690 ok(GetMenu(sibling
) == hMenu
, "SetParent should not remove menu\n");
3692 ok(SetParent(parent
, desktop
) != 0, "SetParent should not fail\n");
3693 ok(SetParent(child4
, child3
) != 0, "SetParent should not fail\n");
3694 ok(SetParent(child3
, child2
) != 0, "SetParent should not fail\n");
3695 ok(SetParent(child2
, child1
) != 0, "SetParent should not fail\n");
3696 ok(!IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
3697 SetWindowLongW(child4
, GWL_STYLE
, WS_CHILD
);
3698 ok(IsChild(child3
, child4
), "wrong parent/child %p/%p\n", child3
, child4
);
3699 ok(IsChild(child2
, child4
), "wrong parent/child %p/%p\n", child2
, child4
);
3700 ok(!IsChild(child1
, child4
), "wrong parent/child %p/%p\n", child1
, child4
);
3701 SetWindowLongW(child2
, GWL_STYLE
, WS_CHILD
);
3702 ok(IsChild(child1
, child4
), "wrong parent/child %p/%p\n", child1
, child4
);
3703 ok(IsChild(parent
, child4
), "wrong parent/child %p/%p\n", parent
, child4
);
3705 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
3707 ok(!IsWindow(parent
), "parent still exists\n");
3708 ok(!IsWindow(sibling
), "sibling still exists\n");
3709 ok(!IsWindow(child1
), "child1 still exists\n");
3710 ok(!IsWindow(child2
), "child2 still exists\n");
3711 ok(!IsWindow(child3
), "child3 still exists\n");
3712 ok(!IsWindow(child4
), "child4 still exists\n");
3714 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3715 100, 100, 200, 200, 0, 0, 0, NULL
);
3716 assert(parent
!= 0);
3717 child1
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
3718 0, 0, 50, 50, parent
, 0, 0, NULL
);
3719 assert(child1
!= 0);
3720 popup
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
3721 0, 0, 50, 50, 0, 0, 0, NULL
);
3724 trace("parent %p, child %p, popup %p\n", parent
, child1
, popup
);
3726 check_parents(parent
, desktop
, 0, 0, 0, parent
, parent
);
3727 check_parents(child1
, parent
, parent
, parent
, 0, parent
, parent
);
3728 check_parents(popup
, desktop
, 0, 0, 0, popup
, popup
);
3730 SetActiveWindow(parent
);
3732 check_active_state(parent
, 0, parent
);
3734 ret
= SetParent(popup
, child1
);
3735 ok(ret
== desktop
, "expected %p, got %p\n", desktop
, ret
);
3736 check_parents(popup
, child1
, child1
, 0, 0, parent
, popup
);
3737 check_active_state(popup
, 0, popup
);
3739 SetActiveWindow(parent
);
3741 check_active_state(popup
, 0, popup
);
3743 EnableWindow(child1
, FALSE
);
3744 check_active_state(popup
, 0, popup
);
3746 check_active_state(parent
, 0, parent
);
3748 check_active_state(popup
, 0, popup
);
3749 EnableWindow(child1
, TRUE
);
3751 ShowWindow(child1
, SW_MINIMIZE
);
3753 check_active_state(parent
, 0, parent
);
3755 check_active_state(popup
, 0, popup
);
3756 ShowWindow(child1
, SW_HIDE
);
3758 SetActiveWindow(parent
);
3760 check_active_state(parent
, 0, parent
);
3762 bret
= SetForegroundWindow(popup
);
3763 ok(bret
, "SetForegroundWindow() failed\n");
3764 check_active_state(popup
, popup
, popup
);
3766 ok(DestroyWindow(parent
), "DestroyWindow() failed\n");
3768 ok(!IsWindow(parent
), "parent still exists\n");
3769 ok(!IsWindow(child1
), "child1 still exists\n");
3770 ok(!IsWindow(popup
), "popup still exists\n");
3773 static LRESULT WINAPI
StyleCheckProc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3775 LPCREATESTRUCTA lpcs
;
3782 lpcs
= (LPCREATESTRUCTA
)lparam
;
3783 lpss
= lpcs
->lpCreateParams
;
3786 if ((lpcs
->dwExStyle
& WS_EX_DLGMODALFRAME
) ||
3787 ((!(lpcs
->dwExStyle
& WS_EX_STATICEDGE
)) &&
3788 (lpcs
->style
& (WS_DLGFRAME
| WS_THICKFRAME
))))
3789 ok(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
, "Window should have WS_EX_WINDOWEDGE style\n");
3791 ok(!(lpcs
->dwExStyle
& WS_EX_WINDOWEDGE
), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
3793 ok((lpss
->styleOld
& ~WS_EX_WINDOWEDGE
) == (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
),
3794 "Ex style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
3795 (lpss
->styleOld
& ~WS_EX_WINDOWEDGE
), (lpcs
->dwExStyle
& ~WS_EX_WINDOWEDGE
));
3797 ok(lpss
->styleNew
== lpcs
->style
,
3798 "Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
3799 lpss
->styleNew
, lpcs
->style
);
3803 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
3806 static ATOM atomStyleCheckClass
;
3808 static void register_style_check_class(void)
3816 GetModuleHandleA(NULL
),
3818 LoadCursorA(0, (LPCSTR
)IDC_ARROW
),
3819 (HBRUSH
)(COLOR_BTNFACE
+1),
3824 atomStyleCheckClass
= RegisterClassA(&wc
);
3825 assert(atomStyleCheckClass
);
3828 static void check_window_style(DWORD dwStyleIn
, DWORD dwExStyleIn
, DWORD dwStyleOut
, DWORD dwExStyleOut
)
3830 DWORD dwActualStyle
;
3831 DWORD dwActualExStyle
;
3834 HWND hwndParent
= NULL
;
3836 ss
.styleNew
= dwStyleIn
;
3837 ss
.styleOld
= dwExStyleIn
;
3839 if (dwStyleIn
& WS_CHILD
)
3841 hwndParent
= CreateWindowExA(0, (LPCSTR
)MAKEINTATOM(atomStyleCheckClass
), NULL
,
3842 WS_OVERLAPPEDWINDOW
, 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
3845 hwnd
= CreateWindowExA(dwExStyleIn
, (LPCSTR
)MAKEINTATOM(atomStyleCheckClass
), NULL
,
3846 dwStyleIn
, 0, 0, 0, 0, hwndParent
, NULL
, NULL
, &ss
);
3849 flush_events( TRUE
);
3851 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
3852 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3853 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3854 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3856 /* try setting the styles explicitly */
3857 SetWindowLongA( hwnd
, GWL_EXSTYLE
, dwExStyleIn
);
3858 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
3859 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3860 /* WS_EX_WINDOWEDGE can't always be changed */
3861 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
3862 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3863 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
3864 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3866 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
3867 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3868 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3870 SetWindowLongA( hwnd
, GWL_STYLE
, dwStyleIn
);
3871 dwActualStyle
= GetWindowLongA(hwnd
, GWL_STYLE
);
3872 dwActualExStyle
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3873 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
3874 if ((dwStyleIn
& (WS_CHILD
|WS_POPUP
)) == WS_CHILD
) dwStyleOut
= dwStyleIn
;
3875 else dwStyleOut
= dwStyleIn
| WS_CLIPSIBLINGS
;
3876 /* WS_EX_WINDOWEDGE can't always be changed */
3877 if (dwExStyleIn
& WS_EX_DLGMODALFRAME
)
3878 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3879 else if ((dwActualStyle
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(dwExStyleIn
& WS_EX_STATICEDGE
))
3880 dwExStyleOut
= dwExStyleIn
| WS_EX_WINDOWEDGE
;
3882 dwExStyleOut
= dwExStyleIn
& ~WS_EX_WINDOWEDGE
;
3883 ok(dwActualStyle
== dwStyleOut
, "expected style %#x, got %#x\n", dwStyleOut
, dwActualStyle
);
3884 /* FIXME: Remove the condition below once Wine is fixed */
3885 if (dwActualExStyle
!= dwExStyleOut
)
3886 todo_wine
ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3888 ok(dwActualExStyle
== dwExStyleOut
, "expected ex_style %#x, got %#x\n", dwExStyleOut
, dwActualExStyle
);
3890 DestroyWindow(hwnd
);
3891 if (hwndParent
) DestroyWindow(hwndParent
);
3894 /* tests what window styles the window manager automatically adds */
3895 static void test_window_styles(void)
3897 register_style_check_class();
3899 check_window_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3900 check_window_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3901 check_window_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3902 check_window_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
3903 check_window_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
);
3904 check_window_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
);
3905 check_window_style(WS_CHILD
, 0, WS_CHILD
, 0);
3906 check_window_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
3907 check_window_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
3908 check_window_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
3909 check_window_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
3910 check_window_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
3911 check_window_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
3912 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3913 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3914 check_window_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
3915 check_window_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3916 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3917 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3918 check_window_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3919 check_window_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3920 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
3921 check_window_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3922 check_window_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
3923 check_window_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
);
3924 check_window_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3925 check_window_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, 0);
3926 check_window_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3927 check_window_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
3928 check_window_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3929 check_window_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
3930 check_window_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
);
3931 check_window_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
);
3933 if (pGetLayeredWindowAttributes
)
3935 check_window_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
);
3936 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_WINDOWEDGE
);
3937 check_window_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
3938 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
);
3942 static INT_PTR WINAPI
empty_dlg_proc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
3947 static void check_dialog_style(DWORD style_in
, DWORD ex_style_in
, DWORD style_out
, DWORD ex_style_out
)
3957 DWORD style
, ex_style
;
3958 HWND hwnd
, parent
= 0;
3960 if (style_in
& WS_CHILD
)
3961 parent
= CreateWindowExA(0, "static", NULL
, WS_OVERLAPPEDWINDOW
,
3962 0, 0, 0, 0, NULL
, NULL
, NULL
, NULL
);
3964 dlg_data
.dt
.style
= style_in
;
3965 dlg_data
.dt
.dwExtendedStyle
= ex_style_in
;
3966 dlg_data
.dt
.cdit
= 0;
3969 dlg_data
.dt
.cx
= 100;
3970 dlg_data
.dt
.cy
= 100;
3971 dlg_data
.menu_name
= 0;
3972 dlg_data
.class_id
= 0;
3973 dlg_data
.class_atom
= 0;
3974 dlg_data
.caption
[0] = 0;
3976 hwnd
= CreateDialogIndirectParamA(GetModuleHandleA(NULL
), &dlg_data
.dt
, parent
, empty_dlg_proc
, 0);
3977 ok(hwnd
!= 0, "dialog creation failed, style %#x, exstyle %#x\n", style_in
, ex_style_in
);
3979 flush_events( TRUE
);
3981 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3982 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3983 ok(style
== (style_out
| DS_3DLOOK
), "expected style %#x, got %#x\n", style_out
| DS_3DLOOK
, style
);
3984 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
3986 /* try setting the styles explicitly */
3987 SetWindowLongA(hwnd
, GWL_EXSTYLE
, ex_style_in
);
3988 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
3989 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
3990 ok(style
== (style_out
| DS_3DLOOK
), "expected style %#x, got %#x\n", style_out
|DS_3DLOOK
, style
);
3991 /* WS_EX_WINDOWEDGE can't always be changed */
3992 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
3993 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
3994 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
3995 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
3997 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
3998 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4000 SetWindowLongA(hwnd
, GWL_STYLE
, style_in
);
4001 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
4002 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
4003 /* WS_CLIPSIBLINGS can't be reset on top-level windows */
4004 if ((style_in
& (WS_CHILD
| WS_POPUP
)) == WS_CHILD
) style_out
= style_in
;
4005 else style_out
= style_in
| WS_CLIPSIBLINGS
;
4006 ok(style
== style_out
, "expected style %#x, got %#x\n", style_out
, style
);
4007 /* WS_EX_WINDOWEDGE can't always be changed */
4008 if (ex_style_in
& WS_EX_DLGMODALFRAME
)
4009 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4010 else if ((style
& (WS_DLGFRAME
| WS_THICKFRAME
)) && !(ex_style_in
& WS_EX_STATICEDGE
))
4011 ex_style_out
= ex_style_in
| WS_EX_WINDOWEDGE
;
4013 ex_style_out
= ex_style_in
& ~WS_EX_WINDOWEDGE
;
4014 /* FIXME: Remove the condition below once Wine is fixed */
4015 if (ex_style
!= ex_style_out
)
4016 todo_wine
ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4018 ok(ex_style
== ex_style_out
, "expected ex_style %#x, got %#x\n", ex_style_out
, ex_style
);
4020 DestroyWindow(hwnd
);
4021 DestroyWindow(parent
);
4024 static void test_dialog_styles(void)
4026 check_dialog_style(0, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4027 check_dialog_style(WS_DLGFRAME
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4028 check_dialog_style(WS_THICKFRAME
, 0, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4029 check_dialog_style(WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4030 check_dialog_style(WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_THICKFRAME
|WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4031 check_dialog_style(DS_CONTROL
, 0, WS_CLIPSIBLINGS
|WS_CAPTION
|DS_CONTROL
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4032 check_dialog_style(WS_CAPTION
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4033 check_dialog_style(WS_BORDER
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4034 check_dialog_style(WS_DLGFRAME
, 0, WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4035 check_dialog_style(WS_BORDER
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4036 check_dialog_style(WS_DLGFRAME
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4037 check_dialog_style(WS_CAPTION
|WS_SYSMENU
, 0, WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4038 check_dialog_style(WS_SYSMENU
, 0, WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4039 check_dialog_style(WS_CAPTION
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4040 check_dialog_style(WS_SYSMENU
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4041 check_dialog_style(WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CAPTION
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4042 check_dialog_style(WS_OVERLAPPEDWINDOW
, 0, WS_CLIPSIBLINGS
|WS_OVERLAPPEDWINDOW
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4043 check_dialog_style(WS_CHILD
, 0, WS_CHILD
, 0);
4044 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
4045 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, 0, WS_CHILD
|WS_THICKFRAME
, WS_EX_WINDOWEDGE
);
4046 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_DLGFRAME
, WS_EX_STATICEDGE
);
4047 check_dialog_style(WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_THICKFRAME
, WS_EX_STATICEDGE
);
4048 check_dialog_style(WS_CHILD
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4049 check_dialog_style(WS_CHILD
|WS_CAPTION
, 0, WS_CHILD
|WS_CAPTION
, WS_EX_WINDOWEDGE
);
4050 check_dialog_style(WS_CHILD
|WS_BORDER
, 0, WS_CHILD
|WS_BORDER
, 0);
4051 check_dialog_style(WS_CHILD
|WS_DLGFRAME
, 0, WS_CHILD
|WS_DLGFRAME
, WS_EX_WINDOWEDGE
);
4052 check_dialog_style(WS_CHILD
|WS_BORDER
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4053 check_dialog_style(WS_CHILD
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4054 check_dialog_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, 0, WS_CHILD
|WS_CAPTION
|WS_SYSMENU
, WS_EX_WINDOWEDGE
);
4055 check_dialog_style(WS_CHILD
|WS_SYSMENU
, 0, WS_CHILD
|WS_SYSMENU
, 0);
4056 check_dialog_style(WS_CHILD
|WS_CAPTION
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4057 check_dialog_style(WS_CHILD
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4058 check_dialog_style(WS_CHILD
|WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4059 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4060 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
, WS_CHILD
, WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4061 check_dialog_style(WS_CHILD
, WS_EX_DLGMODALFRAME
|WS_EX_STATICEDGE
, WS_CHILD
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_DLGMODALFRAME
);
4062 check_dialog_style(WS_CHILD
|WS_POPUP
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4063 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4064 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4065 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4066 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_CHILD
|WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
);
4067 check_dialog_style(WS_CHILD
|WS_POPUP
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4068 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
, 0, WS_CHILD
|WS_POPUP
|WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4069 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_BORDER
, 0, WS_CHILD
|WS_POPUP
|WS_BORDER
|WS_CLIPSIBLINGS
, 0);
4070 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
, 0, WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
);
4071 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_BORDER
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4072 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4073 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
);
4074 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_SYSMENU
, 0, WS_CHILD
|WS_POPUP
|WS_SYSMENU
|WS_CLIPSIBLINGS
, 0);
4075 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_CAPTION
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4076 check_dialog_style(WS_CHILD
|WS_POPUP
|WS_SYSMENU
|DS_CONTROL
, 0, WS_CHILD
|WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4077 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
);
4078 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_APPWINDOW
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_APPWINDOW
);
4079 check_dialog_style(WS_CHILD
|WS_POPUP
, WS_EX_WINDOWEDGE
, WS_CHILD
|WS_POPUP
|WS_CLIPSIBLINGS
, 0);
4080 check_dialog_style(WS_CHILD
, WS_EX_WINDOWEDGE
, WS_CHILD
, 0);
4081 check_dialog_style(0, WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_WINDOWEDGE
|WS_EX_TOOLWINDOW
|WS_EX_CONTROLPARENT
);
4082 check_dialog_style(WS_POPUP
, 0, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4083 check_dialog_style(WS_POPUP
, WS_EX_WINDOWEDGE
, WS_POPUP
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4084 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4085 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, 0, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4086 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4087 check_dialog_style(WS_POPUP
|WS_THICKFRAME
, WS_EX_STATICEDGE
, WS_POPUP
|WS_THICKFRAME
|WS_CLIPSIBLINGS
, WS_EX_STATICEDGE
|WS_EX_CONTROLPARENT
);
4088 check_dialog_style(WS_POPUP
|DS_CONTROL
, 0, WS_POPUP
|WS_CLIPSIBLINGS
|DS_CONTROL
, WS_EX_CONTROLPARENT
);
4089 check_dialog_style(WS_POPUP
|WS_CAPTION
, 0, WS_POPUP
|WS_CAPTION
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4090 check_dialog_style(WS_POPUP
|WS_BORDER
, 0, WS_POPUP
|WS_BORDER
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4091 check_dialog_style(WS_POPUP
|WS_DLGFRAME
, 0, WS_POPUP
|WS_DLGFRAME
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4092 check_dialog_style(WS_POPUP
|WS_BORDER
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4093 check_dialog_style(WS_POPUP
|WS_DLGFRAME
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4094 check_dialog_style(WS_POPUP
|WS_CAPTION
|WS_SYSMENU
, 0, WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4095 check_dialog_style(WS_POPUP
|WS_SYSMENU
, 0, WS_POPUP
|WS_SYSMENU
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4096 check_dialog_style(WS_POPUP
|WS_CAPTION
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4097 check_dialog_style(WS_POPUP
|WS_SYSMENU
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4098 check_dialog_style(WS_POPUP
|WS_CAPTION
|WS_SYSMENU
|DS_CONTROL
, 0, WS_POPUP
|DS_CONTROL
|WS_CLIPSIBLINGS
, WS_EX_CONTROLPARENT
);
4099 check_dialog_style(WS_CAPTION
, WS_EX_STATICEDGE
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_STATICEDGE
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4100 check_dialog_style(0, WS_EX_APPWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_APPWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4102 if (pGetLayeredWindowAttributes
)
4104 check_dialog_style(0, WS_EX_LAYERED
, WS_CLIPSIBLINGS
|WS_CAPTION
, WS_EX_LAYERED
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4105 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
);
4106 check_dialog_style(0, WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
, WS_CLIPSIBLINGS
|WS_CAPTION
,
4107 WS_EX_LAYERED
|WS_EX_TRANSPARENT
|WS_EX_TOOLWINDOW
|WS_EX_WINDOWEDGE
|WS_EX_CONTROLPARENT
);
4111 static void test_scrollwindow( HWND hwnd
)
4117 ShowWindow( hwnd
, SW_SHOW
);
4118 UpdateWindow( hwnd
);
4119 flush_events( TRUE
);
4120 GetClientRect( hwnd
, &rc
);
4122 /* test ScrollWindow(Ex) with no clip rectangle */
4123 /* paint the lower half of the window black */
4125 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4126 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4127 /* paint the upper half of the window white */
4128 rc2
.bottom
= rc2
.top
;
4130 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
4131 /* scroll lower half up */
4133 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4134 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, NULL
, NULL
, NULL
, SW_ERASE
);
4135 flush_events(FALSE
);
4136 /* expected: black should have scrolled to the upper half */
4137 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
4138 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4139 /* Repeat that test of ScrollWindow(Ex) now with clip rectangle */
4140 /* paint the lower half of the window black */
4142 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4143 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4144 /* paint the upper half of the window white */
4145 rc2
.bottom
= rc2
.top
;
4147 FillRect( hdc
, &rc2
, GetStockObject(WHITE_BRUSH
));
4148 /* scroll lower half up */
4150 rc2
.top
= ( rc2
.top
+ rc2
.bottom
) / 2;
4152 rc3
.left
= rc3
.right
/ 4;
4153 rc3
.right
-= rc3
.right
/ 4;
4154 ScrollWindowEx( hwnd
, 0, - rc2
.top
, &rc2
, &rc3
, NULL
, NULL
, SW_ERASE
);
4155 flush_events(FALSE
);
4156 /* expected: black should have scrolled to the upper half */
4157 colr
= GetPixel( hdc
, (rc2
.left
+rc2
.right
)/ 2, rc2
.bottom
/ 4 );
4158 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4161 ReleaseDC( hwnd
, hdc
);
4164 static void test_scrollvalidate( HWND parent
)
4167 HRGN hrgn
=CreateRectRgn(0,0,0,0);
4168 HRGN exprgn
, tmprgn
, clipping
;
4169 RECT rc
, rcu
, cliprc
;
4170 /* create two overlapping child windows. The visual region
4171 * of hwnd1 is clipped by the overlapping part of
4172 * hwnd2 because of the WS_CLIPSIBLING style */
4175 clipping
= CreateRectRgn(0,0,0,0);
4176 tmprgn
= CreateRectRgn(0,0,0,0);
4177 exprgn
= CreateRectRgn(0,0,0,0);
4178 hwnd2
= CreateWindowExA(0, "static", NULL
,
4179 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4180 75, 30, 100, 100, parent
, 0, 0, NULL
);
4181 hwnd1
= CreateWindowExA(0, "static", NULL
,
4182 WS_CHILD
| WS_VISIBLE
| WS_CLIPSIBLINGS
| WS_BORDER
,
4183 25, 50, 100, 100, parent
, 0, 0, NULL
);
4184 ShowWindow( parent
, SW_SHOW
);
4185 UpdateWindow( parent
);
4186 GetClientRect( hwnd1
, &rc
);
4188 SetRectRgn( clipping
, 10, 10, 90, 90);
4189 hdc
= GetDC( hwnd1
);
4190 /* for a visual touch */
4191 TextOutA( hdc
, 0,10, "0123456789", 10);
4192 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4193 if (winetest_debug
> 0) dump_region(hrgn
);
4194 /* create a region with what is expected */
4195 SetRectRgn( exprgn
, 39,0,49,74);
4196 SetRectRgn( tmprgn
, 88,79,98,93);
4197 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4198 SetRectRgn( tmprgn
, 0,93,98,98);
4199 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4200 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4201 trace("update rect is %d,%d - %d,%d\n",
4202 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
4203 /* now with clipping region */
4204 SelectClipRgn( hdc
, clipping
);
4205 ScrollDC( hdc
, -10, -5, &rc
, &cliprc
, hrgn
, &rcu
);
4206 if (winetest_debug
> 0) dump_region(hrgn
);
4207 /* create a region with what is expected */
4208 SetRectRgn( exprgn
, 39,10,49,74);
4209 SetRectRgn( tmprgn
, 80,79,90,85);
4210 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4211 SetRectRgn( tmprgn
, 10,85,90,90);
4212 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4213 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4214 trace("update rect is %d,%d - %d,%d\n",
4215 rcu
.left
,rcu
.top
,rcu
.right
,rcu
.bottom
);
4216 ReleaseDC( hwnd1
, hdc
);
4218 /* test scrolling a window with an update region */
4219 DestroyWindow( hwnd2
);
4220 ValidateRect( hwnd1
, NULL
);
4221 SetRect( &rc
, 40,40, 50,50);
4222 InvalidateRect( hwnd1
, &rc
, 1);
4223 GetClientRect( hwnd1
, &rc
);
4225 ScrollWindowEx( hwnd1
, -10, 0, &rc
, &cliprc
, hrgn
, &rcu
,
4226 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4227 if (winetest_debug
> 0) dump_region(hrgn
);
4228 SetRectRgn( exprgn
, 88,0,98,98);
4229 SetRectRgn( tmprgn
, 30, 40, 50, 50);
4230 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4231 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4233 /* clear an update region */
4234 UpdateWindow( hwnd1
);
4236 SetRect( &rc
, 0,40, 100,60);
4237 SetRect( &cliprc
, 0,0, 100,100);
4238 ScrollWindowEx( hwnd1
, 0, -25, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4239 if (winetest_debug
> 0) dump_region( hrgn
);
4240 SetRectRgn( exprgn
, 0, 40, 98, 60 );
4241 ok( EqualRgn( exprgn
, hrgn
), "wrong update region in excessive scroll\n");
4243 /* now test ScrollWindowEx with a combination of
4244 * WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
4245 /* make hwnd2 the child of hwnd1 */
4246 hwnd2
= CreateWindowExA(0, "static", NULL
,
4247 WS_CHILD
| WS_VISIBLE
| WS_BORDER
,
4248 50, 50, 100, 100, hwnd1
, 0, 0, NULL
);
4249 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPSIBLINGS
);
4250 GetClientRect( hwnd1
, &rc
);
4253 /* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
4254 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
4255 ValidateRect( hwnd1
, NULL
);
4256 ValidateRect( hwnd2
, NULL
);
4257 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
,
4258 SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4259 if (winetest_debug
> 0) dump_region(hrgn
);
4260 SetRectRgn( exprgn
, 88,0,98,88);
4261 SetRectRgn( tmprgn
, 0,88,98,98);
4262 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4263 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4265 /* SW_SCROLLCHILDREN */
4266 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
4267 ValidateRect( hwnd1
, NULL
);
4268 ValidateRect( hwnd2
, NULL
);
4269 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_SCROLLCHILDREN
| SW_INVALIDATE
);
4270 if (winetest_debug
> 0) dump_region(hrgn
);
4271 /* expected region is the same as in previous test */
4272 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4274 /* no SW_SCROLLCHILDREN */
4275 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) & ~WS_CLIPCHILDREN
);
4276 ValidateRect( hwnd1
, NULL
);
4277 ValidateRect( hwnd2
, NULL
);
4278 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4279 if (winetest_debug
> 0) dump_region(hrgn
);
4280 /* expected region is the same as in previous test */
4281 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4283 /* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
4284 SetWindowLongA( hwnd1
, GWL_STYLE
, GetWindowLongA( hwnd1
, GWL_STYLE
) | WS_CLIPCHILDREN
);
4285 ValidateRect( hwnd1
, NULL
);
4286 ValidateRect( hwnd2
, NULL
);
4287 ScrollWindowEx( hwnd1
, -10, -10, &rc
, &cliprc
, hrgn
, &rcu
, SW_INVALIDATE
);
4288 if (winetest_debug
> 0) dump_region(hrgn
);
4289 SetRectRgn( exprgn
, 88,0,98,20);
4290 SetRectRgn( tmprgn
, 20,20,98,30);
4291 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4292 SetRectRgn( tmprgn
, 20,30,30,88);
4293 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4294 SetRectRgn( tmprgn
, 0,88,30,98);
4295 CombineRgn( exprgn
, exprgn
, tmprgn
, RGN_OR
);
4296 ok( EqualRgn( exprgn
, hrgn
), "wrong update region\n");
4299 DeleteObject( hrgn
);
4300 DeleteObject( exprgn
);
4301 DeleteObject( tmprgn
);
4302 DestroyWindow( hwnd1
);
4303 DestroyWindow( hwnd2
);
4306 /* couple of tests of return values of scrollbar functions
4307 * called on a scrollbarless window */
4308 static void test_scroll(void)
4313 HWND hwnd
= CreateWindowExA(0, "Static", "Wine test window",
4314 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
,
4315 100, 100, 200, 200, 0, 0, 0, NULL
);
4317 ret
= GetScrollRange( hwnd
, SB_HORZ
, &min
, &max
);
4318 if (!ret
) /* win9x */
4320 win_skip( "GetScrollRange doesn't work\n" );
4321 DestroyWindow( hwnd
);
4324 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
4325 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
4326 si
.cbSize
= sizeof( si
);
4327 si
.fMask
= SIF_PAGE
;
4328 si
.nPage
= 0xdeadbeef;
4329 ret
= GetScrollInfo( hwnd
, SB_HORZ
, &si
);
4330 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
4331 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
4333 ret
= GetScrollRange( hwnd
, SB_VERT
, &min
, &max
);
4334 ok( ret
, "GetScrollRange returns FALSE\n");
4335 ok( min
== 0, "minimum scroll pos is %d (should be zero)\n", min
);
4336 ok( max
== 0, "maximum scroll pos is %d (should be zero)\n", min
);
4337 si
.cbSize
= sizeof( si
);
4338 si
.fMask
= SIF_PAGE
;
4339 si
.nPage
= 0xdeadbeef;
4340 ret
= GetScrollInfo( hwnd
, SB_VERT
, &si
);
4341 ok( !ret
, "GetScrollInfo returns %d (should be zero)\n", ret
);
4342 ok( si
.nPage
== 0xdeadbeef, "unexpected value for nPage is %d\n", si
.nPage
);
4344 DestroyWindow( hwnd
);
4347 static void test_scrolldc( HWND parent
)
4350 HRGN exprgn
, tmprgn
, hrgn
;
4351 RECT rc
, rc2
, rcu
, cliprc
;
4355 hrgn
= CreateRectRgn(0,0,0,0);
4356 tmprgn
= CreateRectRgn(0,0,0,0);
4357 exprgn
= CreateRectRgn(0,0,0,0);
4359 hwnd1
= CreateWindowExA(0, "static", NULL
,
4360 WS_CHILD
| WS_VISIBLE
,
4361 25, 50, 100, 100, parent
, 0, 0, NULL
);
4362 ShowWindow( parent
, SW_SHOW
);
4363 UpdateWindow( parent
);
4364 flush_events( TRUE
);
4365 GetClientRect( hwnd1
, &rc
);
4366 hdc
= GetDC( hwnd1
);
4367 /* paint the upper half of the window black */
4369 rc2
.bottom
= ( rc
.top
+ rc
.bottom
) /2;
4370 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4371 /* clip region is the lower half */
4373 cliprc
.top
= (rc
.top
+ rc
.bottom
) /2;
4374 /* test whether scrolled pixels are properly clipped */
4375 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
4376 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4377 /* this scroll should not cause any visible changes */
4378 ScrollDC( hdc
, 5, -20, &rc
, &cliprc
, hrgn
, &rcu
);
4379 colr
= GetPixel( hdc
, (rc
.left
+rc
.right
)/2, ( rc
.top
+ rc
.bottom
) /2 - 1);
4380 ok ( colr
== 0, "pixel should be black, color is %08x\n", colr
);
4381 /* test with NULL clip rect */
4382 ScrollDC( hdc
, 20, -20, &rc
, NULL
, hrgn
, &rcu
);
4383 /*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
4384 trace("update rect: %d,%d - %d,%d\n",
4385 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
4386 if (winetest_debug
> 0) dump_region(hrgn
);
4387 SetRect(&rc2
, 0, 0, 100, 100);
4388 ok(EqualRect(&rcu
, &rc2
), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
4389 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
, rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
4391 SetRectRgn( exprgn
, 0, 0, 20, 80);
4392 SetRectRgn( tmprgn
, 0, 80, 100, 100);
4393 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
4394 if (winetest_debug
> 0) dump_region(exprgn
);
4395 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
4396 /* test clip rect > scroll rect */
4397 FillRect( hdc
, &rc
, GetStockObject(WHITE_BRUSH
));
4399 InflateRect( &rc2
, -(rc
.right
-rc
.left
)/4, -(rc
.bottom
-rc
.top
)/4);
4400 FillRect( hdc
, &rc2
, GetStockObject(BLACK_BRUSH
));
4401 ScrollDC( hdc
, 10, 10, &rc2
, &rc
, hrgn
, &rcu
);
4402 SetRectRgn( exprgn
, 25, 25, 75, 35);
4403 SetRectRgn( tmprgn
, 25, 35, 35, 75);
4404 CombineRgn(exprgn
, exprgn
, tmprgn
, RGN_OR
);
4405 ok(EqualRgn(exprgn
, hrgn
), "wrong update region\n");
4406 trace("update rect: %d,%d - %d,%d\n",
4407 rcu
.left
, rcu
.top
, rcu
.right
, rcu
.bottom
);
4408 if (winetest_debug
> 0) dump_region(hrgn
);
4412 DeleteObject(exprgn
);
4413 DeleteObject(tmprgn
);
4414 DestroyWindow(hwnd1
);
4417 static void test_params(void)
4422 ok(!IsWindow(0), "IsWindow(0)\n");
4423 ok(!IsWindow(HWND_BROADCAST
), "IsWindow(HWND_BROADCAST)\n");
4424 ok(!IsWindow(HWND_TOPMOST
), "IsWindow(HWND_TOPMOST)\n");
4426 /* Just a param check */
4427 if (pGetMonitorInfoA
)
4429 SetLastError(0xdeadbeef);
4430 rc
= GetWindowTextA(hwndMain2
, NULL
, 1024);
4431 ok( rc
==0, "GetWindowText: rc=%d err=%d\n",rc
,GetLastError());
4435 /* Skips actually on Win95 and NT4 */
4436 win_skip("Test would crash on Win95\n");
4439 SetLastError(0xdeadbeef);
4440 hwnd
=CreateWindowA("LISTBOX", "TestList",
4441 (LBS_STANDARD
& ~LBS_SORT
),
4443 NULL
, (HMENU
)1, NULL
, 0);
4445 ok(!hwnd
|| broken(hwnd
!= NULL
), /* w2k3 sp2 */
4446 "CreateWindow with invalid menu handle should fail\n");
4448 ok(GetLastError() == ERROR_INVALID_MENU_HANDLE
|| /* NT */
4449 GetLastError() == 0xdeadbeef, /* Win9x */
4450 "wrong last error value %d\n", GetLastError());
4453 static void test_AWRwindow(LPCSTR
class, LONG style
, LONG exStyle
, BOOL menu
)
4457 hwnd
= CreateWindowExA(exStyle
, class, class, style
,
4464 trace("Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style
, exStyle
);
4467 ShowWindow(hwnd
, SW_SHOW
);
4469 test_nonclient_area(hwnd
);
4472 DestroyWindow(hwnd
);
4475 static BOOL
AWR_init(void)
4479 class.style
= CS_HREDRAW
| CS_VREDRAW
;
4480 class.lpfnWndProc
= DefWindowProcA
;
4481 class.cbClsExtra
= 0;
4482 class.cbWndExtra
= 0;
4483 class.hInstance
= 0;
4484 class.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
4485 class.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4486 class.hbrBackground
= 0;
4487 class.lpszMenuName
= 0;
4488 class.lpszClassName
= szAWRClass
;
4490 if (!RegisterClassA(&class)) {
4491 ok(FALSE
, "RegisterClass failed\n");
4495 hmenu
= CreateMenu();
4498 ok(hmenu
!= 0, "Failed to create menu\n");
4499 ok(AppendMenuA(hmenu
, MF_STRING
, 1, "Test!"), "Failed to create menu item\n");
4505 static void test_AWR_window_size(BOOL menu
)
4509 WS_MAXIMIZE
, WS_BORDER
, WS_DLGFRAME
,
4512 WS_MINIMIZEBOX
, WS_MAXIMIZEBOX
,
4513 WS_HSCROLL
, WS_VSCROLL
4517 WS_EX_TOOLWINDOW
, WS_EX_WINDOWEDGE
,
4520 /* These styles have problems on (at least) WinXP (SP2) and Wine */
4521 WS_EX_DLGMODALFRAME
,
4528 /* A exhaustive check of all the styles takes too long
4529 * so just do a (hopefully representative) sample
4531 for (i
= 0; i
< COUNTOF(styles
); ++i
)
4532 test_AWRwindow(szAWRClass
, styles
[i
], 0, menu
);
4533 for (i
= 0; i
< COUNTOF(exStyles
); ++i
) {
4534 test_AWRwindow(szAWRClass
, WS_POPUP
, exStyles
[i
], menu
);
4535 test_AWRwindow(szAWRClass
, WS_THICKFRAME
, exStyles
[i
], menu
);
4540 #define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
4542 static void test_AdjustWindowRect(void)
4547 SHOWSYSMETRIC(SM_CYCAPTION
);
4548 SHOWSYSMETRIC(SM_CYSMCAPTION
);
4549 SHOWSYSMETRIC(SM_CYMENU
);
4550 SHOWSYSMETRIC(SM_CXEDGE
);
4551 SHOWSYSMETRIC(SM_CYEDGE
);
4552 SHOWSYSMETRIC(SM_CXVSCROLL
);
4553 SHOWSYSMETRIC(SM_CYHSCROLL
);
4554 SHOWSYSMETRIC(SM_CXFRAME
);
4555 SHOWSYSMETRIC(SM_CYFRAME
);
4556 SHOWSYSMETRIC(SM_CXDLGFRAME
);
4557 SHOWSYSMETRIC(SM_CYDLGFRAME
);
4558 SHOWSYSMETRIC(SM_CXBORDER
);
4559 SHOWSYSMETRIC(SM_CYBORDER
);
4561 test_AWR_window_size(FALSE
);
4562 test_AWR_window_size(TRUE
);
4566 #undef SHOWSYSMETRIC
4569 /* Global variables to trigger exit from loop */
4570 static int redrawComplete
, WMPAINT_count
;
4572 static LRESULT WINAPI
redraw_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4577 trace("doing WM_PAINT %d\n", WMPAINT_count
);
4579 if (WMPAINT_count
> 10 && redrawComplete
== 0) {
4581 BeginPaint(hwnd
, &ps
);
4582 EndPaint(hwnd
, &ps
);
4587 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4590 /* Ensure we exit from RedrawNow regardless of invalidated area */
4591 static void test_redrawnow(void)
4596 cls
.style
= CS_DBLCLKS
;
4597 cls
.lpfnWndProc
= redraw_window_procA
;
4600 cls
.hInstance
= GetModuleHandleA(0);
4602 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4603 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4604 cls
.lpszMenuName
= NULL
;
4605 cls
.lpszClassName
= "RedrawWindowClass";
4607 if(!RegisterClassA(&cls
)) {
4608 trace("Register failed %d\n", GetLastError());
4612 hwndMain
= CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
4613 CW_USEDEFAULT
, 0, 100, 100, NULL
, NULL
, 0, NULL
);
4615 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4616 ShowWindow(hwndMain
, SW_SHOW
);
4617 ok( WMPAINT_count
== 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4618 RedrawWindow(hwndMain
, NULL
,NULL
,RDW_UPDATENOW
| RDW_ALLCHILDREN
);
4619 ok( WMPAINT_count
== 1 || broken(WMPAINT_count
== 0), /* sometimes on win9x */
4620 "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count
);
4621 redrawComplete
= TRUE
;
4622 ok( WMPAINT_count
< 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count
);
4625 DestroyWindow( hwndMain
);
4628 struct parentdc_stat
{
4634 struct parentdc_test
{
4635 struct parentdc_stat main
, main_todo
;
4636 struct parentdc_stat child1
, child1_todo
;
4637 struct parentdc_stat child2
, child2_todo
;
4640 static LRESULT WINAPI
parentdc_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4645 struct parentdc_stat
*t
= (struct parentdc_stat
*)GetWindowLongPtrA(hwnd
, GWLP_USERDATA
);
4650 GetClientRect(hwnd
, &rc
);
4651 CopyRect(&t
->client
, &rc
);
4652 GetWindowRect(hwnd
, &rc
);
4653 trace("WM_PAINT: hwnd %p, client rect (%d,%d)-(%d,%d), window rect (%d,%d)-(%d,%d)\n", hwnd
,
4654 t
->client
.left
, t
->client
.top
, t
->client
.right
, t
->client
.bottom
,
4655 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
4656 BeginPaint(hwnd
, &ps
);
4657 CopyRect(&t
->paint
, &ps
.rcPaint
);
4658 GetClipBox(ps
.hdc
, &rc
);
4659 CopyRect(&t
->clip
, &rc
);
4660 trace("clip rect (%d,%d)-(%d,%d), paint rect (%d,%d)-(%d,%d)\n",
4661 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
4662 ps
.rcPaint
.left
, ps
.rcPaint
.top
, ps
.rcPaint
.right
, ps
.rcPaint
.bottom
);
4663 EndPaint(hwnd
, &ps
);
4666 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4669 static void zero_parentdc_stat(struct parentdc_stat
*t
)
4671 SetRectEmpty(&t
->client
);
4672 SetRectEmpty(&t
->clip
);
4673 SetRectEmpty(&t
->paint
);
4676 static void zero_parentdc_test(struct parentdc_test
*t
)
4678 zero_parentdc_stat(&t
->main
);
4679 zero_parentdc_stat(&t
->child1
);
4680 zero_parentdc_stat(&t
->child2
);
4683 #define parentdc_field_ok(t, w, r, f, got) \
4684 ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
4685 ": expected %d, got %d\n", \
4688 #define parentdc_todo_field_ok(t, w, r, f, got) \
4689 if (t.w##_todo.r.f) todo_wine { parentdc_field_ok(t, w, r, f, got); } \
4690 else parentdc_field_ok(t, w, r, f, got)
4692 #define parentdc_rect_ok(t, w, r, got) \
4693 parentdc_todo_field_ok(t, w, r, left, got); \
4694 parentdc_todo_field_ok(t, w, r, top, got); \
4695 parentdc_todo_field_ok(t, w, r, right, got); \
4696 parentdc_todo_field_ok(t, w, r, bottom, got);
4698 #define parentdc_win_ok(t, w, got) \
4699 parentdc_rect_ok(t, w, client, got); \
4700 parentdc_rect_ok(t, w, clip, got); \
4701 parentdc_rect_ok(t, w, paint, got);
4703 #define parentdc_ok(t, got) \
4704 parentdc_win_ok(t, main, got); \
4705 parentdc_win_ok(t, child1, got); \
4706 parentdc_win_ok(t, child2, got);
4708 static void test_csparentdc(void)
4710 WNDCLASSA clsMain
, cls
;
4711 HWND hwndMain
, hwnd1
, hwnd2
;
4714 struct parentdc_test test_answer
;
4716 #define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
4717 const struct parentdc_test test1
=
4719 {{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo
,
4720 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4721 {{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4724 const struct parentdc_test test2
=
4726 {{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo
,
4727 {{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4728 {{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4731 const struct parentdc_test test3
=
4733 {{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4734 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4735 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4738 const struct parentdc_test test4
=
4740 {{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo
,
4741 {{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo
,
4742 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4745 const struct parentdc_test test5
=
4747 {{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo
,
4748 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4749 {{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
4752 const struct parentdc_test test6
=
4754 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4755 {{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo
,
4756 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4759 const struct parentdc_test test7
=
4761 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4762 {{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
4763 {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo
,
4767 clsMain
.style
= CS_DBLCLKS
;
4768 clsMain
.lpfnWndProc
= parentdc_window_procA
;
4769 clsMain
.cbClsExtra
= 0;
4770 clsMain
.cbWndExtra
= 0;
4771 clsMain
.hInstance
= GetModuleHandleA(0);
4773 clsMain
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4774 clsMain
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4775 clsMain
.lpszMenuName
= NULL
;
4776 clsMain
.lpszClassName
= "ParentDcMainWindowClass";
4778 if(!RegisterClassA(&clsMain
)) {
4779 trace("Register failed %d\n", GetLastError());
4783 cls
.style
= CS_DBLCLKS
| CS_PARENTDC
;
4784 cls
.lpfnWndProc
= parentdc_window_procA
;
4787 cls
.hInstance
= GetModuleHandleA(0);
4789 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
4790 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
4791 cls
.lpszMenuName
= NULL
;
4792 cls
.lpszClassName
= "ParentDcWindowClass";
4794 if(!RegisterClassA(&cls
)) {
4795 trace("Register failed %d\n", GetLastError());
4799 SetRect(&rc
, 0, 0, 150, 150);
4800 AdjustWindowRectEx(&rc
, WS_OVERLAPPEDWINDOW
, FALSE
, 0);
4801 hwndMain
= CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW
,
4802 CW_USEDEFAULT
, 0, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
, NULL
, NULL
, 0, NULL
);
4803 SetWindowLongPtrA(hwndMain
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.main
);
4804 hwnd1
= CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD
,
4805 20, 20, 40, 40, hwndMain
, NULL
, 0, NULL
);
4806 SetWindowLongPtrA(hwnd1
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child1
);
4807 hwnd2
= CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD
,
4808 40, 40, 40, 40, hwndMain
, NULL
, 0, NULL
);
4809 SetWindowLongPtrA(hwnd2
, GWLP_USERDATA
, (DWORD_PTR
)&test_answer
.child2
);
4810 ShowWindow(hwndMain
, SW_SHOW
);
4811 ShowWindow(hwnd1
, SW_SHOW
);
4812 ShowWindow(hwnd2
, SW_SHOW
);
4813 SetWindowPos(hwndMain
, HWND_TOPMOST
, 0, 0, 0, 0, SWP_NOSIZE
|SWP_NOMOVE
);
4814 flush_events( TRUE
);
4816 zero_parentdc_test(&test_answer
);
4817 InvalidateRect(hwndMain
, NULL
, TRUE
);
4818 flush_events( TRUE
);
4819 parentdc_ok(test1
, test_answer
);
4821 zero_parentdc_test(&test_answer
);
4822 SetRect(&rc
, 0, 0, 50, 50);
4823 InvalidateRect(hwndMain
, &rc
, TRUE
);
4824 flush_events( TRUE
);
4825 parentdc_ok(test2
, test_answer
);
4827 zero_parentdc_test(&test_answer
);
4828 SetRect(&rc
, 0, 0, 10, 10);
4829 InvalidateRect(hwndMain
, &rc
, TRUE
);
4830 flush_events( TRUE
);
4831 parentdc_ok(test3
, test_answer
);
4833 zero_parentdc_test(&test_answer
);
4834 SetRect(&rc
, 40, 40, 50, 50);
4835 InvalidateRect(hwndMain
, &rc
, TRUE
);
4836 flush_events( TRUE
);
4837 parentdc_ok(test4
, test_answer
);
4839 zero_parentdc_test(&test_answer
);
4840 SetRect(&rc
, 20, 20, 60, 60);
4841 InvalidateRect(hwndMain
, &rc
, TRUE
);
4842 flush_events( TRUE
);
4843 parentdc_ok(test5
, test_answer
);
4845 zero_parentdc_test(&test_answer
);
4846 SetRect(&rc
, 0, 0, 10, 10);
4847 InvalidateRect(hwnd1
, &rc
, TRUE
);
4848 flush_events( TRUE
);
4849 parentdc_ok(test6
, test_answer
);
4851 zero_parentdc_test(&test_answer
);
4852 SetRect(&rc
, -5, -5, 65, 65);
4853 InvalidateRect(hwnd1
, &rc
, TRUE
);
4854 flush_events( TRUE
);
4855 parentdc_ok(test7
, test_answer
);
4857 DestroyWindow(hwndMain
);
4858 DestroyWindow(hwnd1
);
4859 DestroyWindow(hwnd2
);
4862 static LRESULT WINAPI
def_window_procA(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4864 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
4867 static LRESULT WINAPI
def_window_procW(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
4869 return DefWindowProcW(hwnd
, msg
, wparam
, lparam
);
4872 static void test_IsWindowUnicode(void)
4874 static const char ansi_class_nameA
[] = "ansi class name";
4875 static const WCHAR ansi_class_nameW
[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
4876 static const char unicode_class_nameA
[] = "unicode class name";
4877 static const WCHAR unicode_class_nameW
[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
4882 memset(&classW
, 0, sizeof(classW
));
4883 classW
.hInstance
= GetModuleHandleA(0);
4884 classW
.lpfnWndProc
= def_window_procW
;
4885 classW
.lpszClassName
= unicode_class_nameW
;
4886 if (!RegisterClassW(&classW
)) return; /* this catches Win9x as well */
4888 memset(&classA
, 0, sizeof(classA
));
4889 classA
.hInstance
= GetModuleHandleA(0);
4890 classA
.lpfnWndProc
= def_window_procA
;
4891 classA
.lpszClassName
= ansi_class_nameA
;
4892 assert(RegisterClassA(&classA
));
4894 /* unicode class: window proc */
4895 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
4896 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4899 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4900 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4901 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4902 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4903 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4905 DestroyWindow(hwnd
);
4907 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
4908 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4911 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4912 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4913 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4914 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4915 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4917 DestroyWindow(hwnd
);
4919 /* ansi class: window proc */
4920 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
4921 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4924 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4925 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4926 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4927 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4928 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4930 DestroyWindow(hwnd
);
4932 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
4933 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4936 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4937 SetWindowLongPtrW(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4938 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4939 SetWindowLongPtrA(hwnd
, GWLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4940 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4942 DestroyWindow(hwnd
);
4944 /* unicode class: class proc */
4945 hwnd
= CreateWindowExW(0, unicode_class_nameW
, NULL
, WS_POPUP
,
4946 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4949 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4950 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4951 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4952 /* do not restore class window proc back to unicode */
4954 DestroyWindow(hwnd
);
4956 hwnd
= CreateWindowExA(0, unicode_class_nameA
, NULL
, WS_POPUP
,
4957 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4960 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4961 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4962 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4964 DestroyWindow(hwnd
);
4966 /* ansi class: class proc */
4967 hwnd
= CreateWindowExW(0, ansi_class_nameW
, NULL
, WS_POPUP
,
4968 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4971 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4972 SetClassLongPtrW(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procW
);
4973 ok(!IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return FALSE\n");
4974 /* do not restore class window proc back to ansi */
4976 DestroyWindow(hwnd
);
4978 hwnd
= CreateWindowExA(0, ansi_class_nameA
, NULL
, WS_POPUP
,
4979 0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL
);
4982 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4983 SetClassLongPtrA(hwnd
, GCLP_WNDPROC
, (ULONG_PTR
)def_window_procA
);
4984 ok(IsWindowUnicode(hwnd
), "IsWindowUnicode expected to return TRUE\n");
4986 DestroyWindow(hwnd
);
4989 static LRESULT CALLBACK
minmax_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
4993 if (msg
!= WM_GETMINMAXINFO
)
4994 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
4996 minmax
= (MINMAXINFO
*)lp
;
4998 if ((GetWindowLongA(hwnd
, GWL_STYLE
) & WS_CHILD
))
5000 minmax
->ptReserved
.x
= 0;
5001 minmax
->ptReserved
.y
= 0;
5002 minmax
->ptMaxSize
.x
= 400;
5003 minmax
->ptMaxSize
.y
= 400;
5004 minmax
->ptMaxPosition
.x
= 300;
5005 minmax
->ptMaxPosition
.y
= 300;
5006 minmax
->ptMaxTrackSize
.x
= 200;
5007 minmax
->ptMaxTrackSize
.y
= 200;
5008 minmax
->ptMinTrackSize
.x
= 100;
5009 minmax
->ptMinTrackSize
.y
= 100;
5012 DefWindowProcA(hwnd
, msg
, wp
, lp
);
5016 static int expected_cx
, expected_cy
;
5017 static RECT expected_rect
, broken_rect
;
5019 static LRESULT CALLBACK
winsizes_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
5023 case WM_GETMINMAXINFO
:
5026 GetWindowRect( hwnd
, &rect
);
5027 ok( !rect
.left
&& !rect
.top
&& !rect
.right
&& !rect
.bottom
,
5028 "wrong rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5029 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5034 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
5036 GetWindowRect( hwnd
, &rect
);
5037 trace( "hwnd %p msg %x size %dx%d rect %d,%d-%d,%d\n",
5038 hwnd
, msg
, cs
->cx
, cs
->cy
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5039 ok( cs
->cx
== expected_cx
|| broken(cs
->cx
== (short)expected_cx
),
5040 "wrong x size %d/%d\n", cs
->cx
, expected_cx
);
5041 ok( cs
->cy
== expected_cy
|| broken(cs
->cy
== (short)expected_cy
),
5042 "wrong y size %d/%d\n", cs
->cy
, expected_cy
);
5043 ok( (rect
.right
- rect
.left
== expected_rect
.right
- expected_rect
.left
&&
5044 rect
.bottom
- rect
.top
== expected_rect
.bottom
- expected_rect
.top
) ||
5045 (rect
.right
- rect
.left
== min( 65535, expected_rect
.right
- expected_rect
.left
) &&
5046 rect
.bottom
- rect
.top
== min( 65535, expected_rect
.bottom
- expected_rect
.top
)) ||
5047 broken( rect
.right
- rect
.left
== broken_rect
.right
- broken_rect
.left
&&
5048 rect
.bottom
- rect
.top
== broken_rect
.bottom
- broken_rect
.top
) ||
5049 broken( rect
.right
- rect
.left
== (short)broken_rect
.right
- (short)broken_rect
.left
&&
5050 rect
.bottom
- rect
.top
== (short)broken_rect
.bottom
- (short)broken_rect
.top
),
5051 "wrong rect %d,%d-%d,%d / %d,%d-%d,%d\n",
5052 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
5053 expected_rect
.left
, expected_rect
.top
, expected_rect
.right
, expected_rect
.bottom
);
5054 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5058 RECT rect
, *r
= (RECT
*)lp
;
5059 GetWindowRect( hwnd
, &rect
);
5060 ok( !memcmp( &rect
, r
, sizeof(rect
) ),
5061 "passed rect %d,%d-%d,%d doesn't match window rect %d,%d-%d,%d\n",
5062 r
->left
, r
->top
, r
->right
, r
->bottom
, rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
5063 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5066 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
5070 static void test_CreateWindow(void)
5079 #define expect_menu(window, menu) \
5080 SetLastError(0xdeadbeef); \
5081 res = (GetMenu(window) == (HMENU)menu); \
5082 ok(res, "GetMenu error %d\n", GetLastError())
5084 #define expect_style(window, style)\
5085 ok((ULONG)GetWindowLongA(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLongA(window, GWL_STYLE))
5087 #define expect_ex_style(window, ex_style)\
5088 ok((ULONG)GetWindowLongA(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLongA(window, GWL_EXSTYLE))
5090 #define expect_gle_broken_9x(gle)\
5091 ok(GetLastError() == gle ||\
5092 broken(GetLastError() == 0xdeadbeef),\
5093 "IsMenu set error %d\n", GetLastError())
5095 hmenu
= CreateMenu();
5097 parent
= GetDesktopWindow();
5098 assert(parent
!= 0);
5100 SetLastError(0xdeadbeef);
5101 res
= IsMenu(hmenu
);
5102 ok(res
, "IsMenu error %d\n", GetLastError());
5105 SetLastError(0xdeadbeef);
5106 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
,
5107 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5108 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5109 expect_menu(hwnd
, 1);
5110 expect_style(hwnd
, WS_CHILD
);
5111 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5112 DestroyWindow(hwnd
);
5114 SetLastError(0xdeadbeef);
5115 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_CAPTION
,
5116 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5117 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5118 expect_menu(hwnd
, 1);
5119 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
5120 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5121 DestroyWindow(hwnd
);
5123 SetLastError(0xdeadbeef);
5124 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
,
5125 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5126 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5127 expect_menu(hwnd
, 1);
5128 expect_style(hwnd
, WS_CHILD
);
5129 expect_ex_style(hwnd
, 0);
5130 DestroyWindow(hwnd
);
5132 SetLastError(0xdeadbeef);
5133 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_CAPTION
,
5134 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5135 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5136 expect_menu(hwnd
, 1);
5137 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
);
5138 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5139 DestroyWindow(hwnd
);
5142 SetLastError(0xdeadbeef);
5143 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5144 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5145 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5146 expect_menu(hwnd
, hmenu
);
5147 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
5148 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5149 DestroyWindow(hwnd
);
5150 SetLastError(0xdeadbeef);
5151 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5152 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5154 hmenu
= CreateMenu();
5156 SetLastError(0xdeadbeef);
5157 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
| WS_CAPTION
,
5158 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5159 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5160 expect_menu(hwnd
, hmenu
);
5161 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5162 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5163 DestroyWindow(hwnd
);
5164 SetLastError(0xdeadbeef);
5165 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5166 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5168 hmenu
= CreateMenu();
5170 SetLastError(0xdeadbeef);
5171 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
,
5172 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5173 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5174 expect_menu(hwnd
, hmenu
);
5175 expect_style(hwnd
, WS_POPUP
| WS_CLIPSIBLINGS
);
5176 expect_ex_style(hwnd
, 0);
5177 DestroyWindow(hwnd
);
5178 SetLastError(0xdeadbeef);
5179 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5180 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5182 hmenu
= CreateMenu();
5184 SetLastError(0xdeadbeef);
5185 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
| WS_CAPTION
,
5186 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5187 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5188 expect_menu(hwnd
, hmenu
);
5189 expect_style(hwnd
, WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5190 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5191 DestroyWindow(hwnd
);
5192 SetLastError(0xdeadbeef);
5193 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5194 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5196 /* WS_CHILD | WS_POPUP */
5197 SetLastError(0xdeadbeef);
5198 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5199 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5200 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5201 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5203 DestroyWindow(hwnd
);
5205 hmenu
= CreateMenu();
5207 SetLastError(0xdeadbeef);
5208 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
,
5209 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5210 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5211 expect_menu(hwnd
, hmenu
);
5212 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
5213 expect_ex_style(hwnd
, WS_EX_APPWINDOW
);
5214 DestroyWindow(hwnd
);
5215 SetLastError(0xdeadbeef);
5216 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5217 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5219 SetLastError(0xdeadbeef);
5220 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5221 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5222 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5223 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5225 DestroyWindow(hwnd
);
5227 hmenu
= CreateMenu();
5229 SetLastError(0xdeadbeef);
5230 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5231 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5232 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5233 expect_menu(hwnd
, hmenu
);
5234 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5235 expect_ex_style(hwnd
, WS_EX_APPWINDOW
| WS_EX_WINDOWEDGE
);
5236 DestroyWindow(hwnd
);
5237 SetLastError(0xdeadbeef);
5238 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5239 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5241 SetLastError(0xdeadbeef);
5242 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
5243 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5244 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5245 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5247 DestroyWindow(hwnd
);
5249 hmenu
= CreateMenu();
5251 SetLastError(0xdeadbeef);
5252 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
,
5253 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5254 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5255 expect_menu(hwnd
, hmenu
);
5256 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CLIPSIBLINGS
);
5257 expect_ex_style(hwnd
, 0);
5258 DestroyWindow(hwnd
);
5259 SetLastError(0xdeadbeef);
5260 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5261 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5263 SetLastError(0xdeadbeef);
5264 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5265 0, 0, 100, 100, parent
, (HMENU
)1, 0, NULL
);
5266 ok(!hwnd
|| broken(hwnd
!= 0 /* Win9x */), "CreateWindowEx should fail\n");
5267 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5269 DestroyWindow(hwnd
);
5271 hmenu
= CreateMenu();
5273 SetLastError(0xdeadbeef);
5274 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
| WS_POPUP
| WS_CAPTION
,
5275 0, 0, 100, 100, parent
, hmenu
, 0, NULL
);
5276 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5277 expect_menu(hwnd
, hmenu
);
5278 expect_style(hwnd
, WS_CHILD
| WS_POPUP
| WS_CAPTION
| WS_CLIPSIBLINGS
);
5279 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5280 DestroyWindow(hwnd
);
5281 SetLastError(0xdeadbeef);
5282 ok(!IsMenu(hmenu
), "IsMenu should fail\n");
5283 expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE
);
5285 /* test child window sizing */
5287 cls
.lpfnWndProc
= minmax_wnd_proc
;
5290 cls
.hInstance
= GetModuleHandleA(NULL
);
5292 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5293 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5294 cls
.lpszMenuName
= NULL
;
5295 cls
.lpszClassName
= "MinMax_WndClass";
5296 RegisterClassA(&cls
);
5298 SetLastError(0xdeadbeef);
5299 parent
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
5300 0, 0, 100, 100, 0, 0, 0, NULL
);
5301 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
5302 expect_menu(parent
, 0);
5303 expect_style(parent
, WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
| WS_CLIPSIBLINGS
);
5304 expect_ex_style(parent
, WS_EX_WINDOWEDGE
);
5306 memset(&minmax
, 0, sizeof(minmax
));
5307 SendMessageA(parent
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
5308 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxSize
.x
, minmax
.ptMaxSize
.y
);
5309 ok(IsRectEmpty(&rc_minmax
), "ptMaxSize is not empty\n");
5310 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
5311 ok(IsRectEmpty(&rc_minmax
), "ptMaxTrackSize is not empty\n");
5313 GetWindowRect(parent
, &rc
);
5314 ok(!IsRectEmpty(&rc
), "parent window rect is empty\n");
5315 GetClientRect(parent
, &rc
);
5316 ok(!IsRectEmpty(&rc
), "parent client rect is empty\n");
5318 InflateRect(&rc
, 200, 200);
5319 trace("creating child with rect (%d,%d-%d,%d)\n", rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5321 SetLastError(0xdeadbeef);
5322 hwnd
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
,
5323 rc
.left
, rc
.top
, rc
.right
- rc
.left
, rc
.bottom
- rc
.top
,
5324 parent
, (HMENU
)1, 0, NULL
);
5325 ok(hwnd
!= 0, "CreateWindowEx error %d\n", GetLastError());
5326 expect_menu(hwnd
, 1);
5327 expect_style(hwnd
, WS_CHILD
| WS_CAPTION
| WS_SYSMENU
| WS_THICKFRAME
);
5328 expect_ex_style(hwnd
, WS_EX_WINDOWEDGE
);
5330 memset(&minmax
, 0, sizeof(minmax
));
5331 SendMessageA(hwnd
, WM_GETMINMAXINFO
, 0, (LPARAM
)&minmax
);
5332 SetRect(&rc_minmax
, 0, 0, minmax
.ptMaxTrackSize
.x
, minmax
.ptMaxTrackSize
.y
);
5334 GetWindowRect(hwnd
, &rc
);
5335 OffsetRect(&rc
, -rc
.left
, -rc
.top
);
5336 ok(EqualRect(&rc
, &rc_minmax
), "rects don't match: (%d,%d-%d,%d) and (%d,%d-%d,%d)\n",
5337 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
5338 rc_minmax
.left
, rc_minmax
.top
, rc_minmax
.right
, rc_minmax
.bottom
);
5339 DestroyWindow(hwnd
);
5341 cls
.lpfnWndProc
= winsizes_wnd_proc
;
5342 cls
.lpszClassName
= "Sizes_WndClass";
5343 RegisterClassA(&cls
);
5345 expected_cx
= expected_cy
= 200000;
5346 SetRect( &expected_rect
, 0, 0, 200000, 200000 );
5347 broken_rect
= expected_rect
;
5348 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 300000, 300000, 200000, 200000, parent
, 0, 0, NULL
);
5349 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5350 GetClientRect( hwnd
, &rc
);
5351 ok( rc
.right
== 200000 || rc
.right
== 65535 || broken(rc
.right
== (short)200000),
5352 "invalid rect right %u\n", rc
.right
);
5353 ok( rc
.bottom
== 200000 || rc
.bottom
== 65535 || broken(rc
.bottom
== (short)200000),
5354 "invalid rect bottom %u\n", rc
.bottom
);
5355 DestroyWindow(hwnd
);
5357 expected_cx
= expected_cy
= -10;
5358 SetRect( &expected_rect
, 0, 0, 0, 0 );
5359 SetRect( &broken_rect
, 0, 0, -10, -10 );
5360 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -20, -20, -10, -10, parent
, 0, 0, NULL
);
5361 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5362 GetClientRect( hwnd
, &rc
);
5363 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
5364 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
5365 DestroyWindow(hwnd
);
5367 expected_cx
= expected_cy
= -200000;
5368 SetRect( &expected_rect
, 0, 0, 0, 0 );
5369 SetRect( &broken_rect
, 0, 0, -200000, -200000 );
5370 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, -300000, -300000, -200000, -200000, parent
, 0, 0, NULL
);
5371 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5372 GetClientRect( hwnd
, &rc
);
5373 ok( rc
.right
== 0, "invalid rect right %u\n", rc
.right
);
5374 ok( rc
.bottom
== 0, "invalid rect bottom %u\n", rc
.bottom
);
5375 DestroyWindow(hwnd
);
5377 /* we need a parent at 0,0 so that child coordinates match */
5378 DestroyWindow(parent
);
5379 parent
= CreateWindowExA(0, "MinMax_WndClass", NULL
, WS_POPUP
, 0, 0, 100, 100, 0, 0, 0, NULL
);
5380 ok(parent
!= 0, "CreateWindowEx error %d\n", GetLastError());
5383 expected_cy
= 0x7fffffff;
5384 SetRect( &expected_rect
, 10, 10, 110, 0x7fffffff );
5385 SetRect( &broken_rect
, 10, 10, 110, 0x7fffffffU
+ 10 );
5386 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 10, 10, 100, 0x7fffffff, parent
, 0, 0, NULL
);
5387 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5388 GetClientRect( hwnd
, &rc
);
5389 ok( rc
.right
== 100, "invalid rect right %u\n", rc
.right
);
5390 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.bottom
==65535 || broken(rc
.bottom
== 0),
5391 "invalid rect bottom %u\n", rc
.bottom
);
5392 DestroyWindow(hwnd
);
5394 expected_cx
= 0x7fffffff;
5395 expected_cy
= 0x7fffffff;
5396 SetRect( &expected_rect
, 20, 10, 0x7fffffff, 0x7fffffff );
5397 SetRect( &broken_rect
, 20, 10, 0x7fffffffU
+ 20, 0x7fffffffU
+ 10 );
5398 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_CHILD
, 20, 10, 0x7fffffff, 0x7fffffff, parent
, 0, 0, NULL
);
5399 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5400 GetClientRect( hwnd
, &rc
);
5401 ok( rc
.right
== 0x7fffffff - 20 || rc
.right
== 65535 || broken(rc
.right
== 0),
5402 "invalid rect right %u\n", rc
.right
);
5403 ok( rc
.bottom
== 0x7fffffff - 10 || rc
.right
== 65535 || broken(rc
.bottom
== 0),
5404 "invalid rect bottom %u\n", rc
.bottom
);
5405 DestroyWindow(hwnd
);
5407 /* top level window */
5408 expected_cx
= expected_cy
= 200000;
5409 SetRect( &expected_rect
, 0, 0, GetSystemMetrics(SM_CXMAXTRACK
), GetSystemMetrics(SM_CYMAXTRACK
) );
5410 hwnd
= CreateWindowExA(0, "Sizes_WndClass", NULL
, WS_OVERLAPPEDWINDOW
, 300000, 300000, 200000, 200000, 0, 0, 0, NULL
);
5411 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5412 GetClientRect( hwnd
, &rc
);
5413 ok( rc
.right
<= expected_cx
, "invalid rect right %u\n", rc
.right
);
5414 ok( rc
.bottom
<= expected_cy
, "invalid rect bottom %u\n", rc
.bottom
);
5415 DestroyWindow(hwnd
);
5417 if (pGetLayout
&& pSetLayout
)
5419 HDC hdc
= GetDC( parent
);
5420 pSetLayout( hdc
, LAYOUT_RTL
);
5421 if (pGetLayout( hdc
))
5423 ReleaseDC( parent
, hdc
);
5424 DestroyWindow( parent
);
5425 SetLastError( 0xdeadbeef );
5426 parent
= CreateWindowExA(WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
,
5427 0, 0, 100, 100, 0, 0, 0, NULL
);
5428 ok( parent
!= 0, "creation failed err %u\n", GetLastError());
5429 expect_ex_style( parent
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
5430 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5431 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5432 expect_ex_style( hwnd
, WS_EX_LAYOUTRTL
);
5433 DestroyWindow( hwnd
);
5434 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5435 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5436 expect_ex_style( hwnd
, 0 );
5437 DestroyWindow( hwnd
);
5438 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
| WS_EX_NOINHERITLAYOUT
);
5439 hwnd
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 0, 0, 20, 20, parent
, 0, 0, NULL
);
5440 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5441 expect_ex_style( hwnd
, 0 );
5442 DestroyWindow( hwnd
);
5444 if (pGetProcessDefaultLayout
&& pSetProcessDefaultLayout
)
5448 SetLastError( 0xdeadbeef );
5449 ok( !pGetProcessDefaultLayout( NULL
), "GetProcessDefaultLayout succeeded\n" );
5450 ok( GetLastError() == ERROR_NOACCESS
, "wrong error %u\n", GetLastError() );
5451 SetLastError( 0xdeadbeef );
5452 res
= pGetProcessDefaultLayout( &layout
);
5453 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5454 ok( layout
== 0, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5455 SetLastError( 0xdeadbeef );
5456 res
= pSetProcessDefaultLayout( 7 );
5457 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
5458 res
= pGetProcessDefaultLayout( &layout
);
5459 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5460 ok( layout
== 7, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5461 SetLastError( 0xdeadbeef );
5462 res
= pSetProcessDefaultLayout( LAYOUT_RTL
);
5463 ok( res
, "SetProcessDefaultLayout failed err %u\n", GetLastError ());
5464 res
= pGetProcessDefaultLayout( &layout
);
5465 ok( res
, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
5466 ok( layout
== LAYOUT_RTL
, "GetProcessDefaultLayout wrong layout %x\n", layout
);
5467 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5468 0, 0, 100, 100, 0, 0, 0, NULL
);
5469 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5470 expect_ex_style( hwnd
, WS_EX_APPWINDOW
| WS_EX_LAYOUTRTL
);
5471 DestroyWindow( hwnd
);
5472 hwnd
= CreateWindowExA(WS_EX_APPWINDOW
, "static", NULL
, WS_POPUP
,
5473 0, 0, 100, 100, parent
, 0, 0, NULL
);
5474 ok( hwnd
!= 0, "creation failed err %u\n", GetLastError());
5475 expect_ex_style( hwnd
, WS_EX_APPWINDOW
);
5476 DestroyWindow( hwnd
);
5477 pSetProcessDefaultLayout( 0 );
5479 else win_skip( "SetProcessDefaultLayout not supported\n" );
5481 else win_skip( "SetLayout not supported\n" );
5483 else win_skip( "SetLayout not available\n" );
5485 DestroyWindow(parent
);
5487 UnregisterClassA("MinMax_WndClass", GetModuleHandleA(NULL
));
5488 UnregisterClassA("Sizes_WndClass", GetModuleHandleA(NULL
));
5490 #undef expect_gle_broken_9x
5493 #undef expect_ex_style
5496 /* function that remembers whether the system the test is running on sets the
5497 * last error for user32 functions to make the tests stricter */
5498 static int check_error(DWORD actual
, DWORD expected
)
5500 static int sets_last_error
= -1;
5501 if (sets_last_error
== -1)
5502 sets_last_error
= (actual
!= 0xdeadbeef);
5503 return (!sets_last_error
&& (actual
== 0xdeadbeef)) || (actual
== expected
);
5506 static void test_SetWindowLong(void)
5509 WNDPROC old_window_procW
;
5511 SetLastError(0xdeadbeef);
5512 retval
= SetWindowLongPtrA(NULL
, GWLP_WNDPROC
, 0);
5513 ok(!retval
, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval
);
5514 ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE
),
5515 "SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instead of %d\n", GetLastError());
5517 SetLastError(0xdeadbeef);
5518 retval
= SetWindowLongPtrA(hwndMain
, 0xdeadbeef, 0);
5519 ok(!retval
, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval
);
5520 ok(check_error(GetLastError(), ERROR_INVALID_INDEX
),
5521 "SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instead of %d\n", GetLastError());
5523 SetLastError(0xdeadbeef);
5524 retval
= SetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
, 0);
5525 ok((WNDPROC
)retval
== main_window_procA
|| broken(!retval
), /* win9x */
5526 "SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval
);
5527 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
5528 retval
= GetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
);
5529 ok((WNDPROC
)retval
== main_window_procA
,
5530 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
5531 ok(!IsWindowUnicode(hwndMain
), "hwndMain shouldn't be Unicode\n");
5533 old_window_procW
= (WNDPROC
)GetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
);
5534 SetLastError(0xdeadbeef);
5535 retval
= SetWindowLongPtrW(hwndMain
, GWLP_WNDPROC
, 0);
5536 if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED
)
5538 ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
5539 ok(retval
!= 0, "SetWindowLongPtr error %d\n", GetLastError());
5540 ok((WNDPROC
)retval
== old_window_procW
,
5541 "SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval
);
5542 ok(IsWindowUnicode(hwndMain
), "hwndMain should now be Unicode\n");
5544 /* set it back to ANSI */
5545 SetWindowLongPtrA(hwndMain
, GWLP_WNDPROC
, 0);
5549 static void test_ShowWindow(void)
5553 RECT rcMain
, rc
, rcMinimized
;
5556 SetRect(&rcMain
, 120, 120, 210, 210);
5558 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
5559 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
5560 WS_MAXIMIZEBOX
| WS_POPUP
,
5561 rcMain
.left
, rcMain
.top
,
5562 rcMain
.right
- rcMain
.left
, rcMain
.bottom
- rcMain
.top
,
5566 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5567 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5568 ok(!(style
& WS_VISIBLE
), "window should not be visible\n");
5569 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5570 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5571 GetWindowRect(hwnd
, &rc
);
5572 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5573 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5574 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5576 ret
= ShowWindow(hwnd
, SW_SHOW
);
5577 ok(!ret
, "not expected ret: %lu\n", ret
);
5578 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5579 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5580 ok(style
& WS_VISIBLE
, "window should be visible\n");
5581 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5582 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5583 GetWindowRect(hwnd
, &rc
);
5584 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5585 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5586 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5588 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
5589 ok(ret
, "not expected ret: %lu\n", ret
);
5590 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5591 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5592 ok(style
& WS_VISIBLE
, "window should be visible\n");
5593 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5594 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5595 GetWindowRect(hwnd
, &rcMinimized
);
5596 ok(!EqualRect(&rcMain
, &rcMinimized
), "rects shouldn't match\n");
5597 /* shouldn't be able to resize minimized windows */
5598 ret
= SetWindowPos(hwnd
, 0, 0, 0,
5599 (rcMinimized
.right
- rcMinimized
.left
) * 2,
5600 (rcMinimized
.bottom
- rcMinimized
.top
) * 2,
5601 SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
5602 ok(ret
, "not expected ret: %lu\n", ret
);
5603 GetWindowRect(hwnd
, &rc
);
5604 ok(EqualRect(&rc
, &rcMinimized
), "rects should match\n");
5606 ShowWindow(hwnd
, SW_RESTORE
);
5607 ok(ret
, "not expected ret: %lu\n", ret
);
5608 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5609 ok(!(style
& WS_DISABLED
), "window should not be disabled\n");
5610 ok(style
& WS_VISIBLE
, "window should be visible\n");
5611 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5612 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5613 GetWindowRect(hwnd
, &rc
);
5614 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5615 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5616 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5618 ret
= EnableWindow(hwnd
, FALSE
);
5619 ok(!ret
, "not expected ret: %lu\n", ret
);
5620 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5621 ok(style
& WS_DISABLED
, "window should be disabled\n");
5623 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_MINIMIZE
, 0);
5624 ok(!ret
, "not expected ret: %lu\n", ret
);
5625 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5626 ok(style
& WS_DISABLED
, "window should be disabled\n");
5627 ok(style
& WS_VISIBLE
, "window should be visible\n");
5628 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5629 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5630 GetWindowRect(hwnd
, &rc
);
5631 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5632 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5633 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5635 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_MAXIMIZE
, 0);
5636 ok(!ret
, "not expected ret: %lu\n", ret
);
5637 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5638 ok(style
& WS_DISABLED
, "window should be disabled\n");
5639 ok(style
& WS_VISIBLE
, "window should be visible\n");
5640 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5641 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5642 GetWindowRect(hwnd
, &rc
);
5643 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5644 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5645 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5647 ret
= ShowWindow(hwnd
, SW_MINIMIZE
);
5648 ok(ret
, "not expected ret: %lu\n", ret
);
5649 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5650 ok(style
& WS_DISABLED
, "window should be disabled\n");
5651 ok(style
& WS_VISIBLE
, "window should be visible\n");
5652 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5653 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5654 GetWindowRect(hwnd
, &rc
);
5655 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
5657 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_RESTORE
, 0);
5658 ok(!ret
, "not expected ret: %lu\n", ret
);
5659 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5660 ok(style
& WS_DISABLED
, "window should be disabled\n");
5661 ok(style
& WS_VISIBLE
, "window should be visible\n");
5662 ok(style
& WS_MINIMIZE
, "window should be minimized\n");
5663 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5664 GetWindowRect(hwnd
, &rc
);
5665 ok(!EqualRect(&rcMain
, &rc
), "rects shouldn't match\n");
5667 ret
= ShowWindow(hwnd
, SW_RESTORE
);
5668 ok(ret
, "not expected ret: %lu\n", ret
);
5669 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
5670 ok(style
& WS_DISABLED
, "window should be disabled\n");
5671 ok(style
& WS_VISIBLE
, "window should be visible\n");
5672 ok(!(style
& WS_MINIMIZE
), "window should not be minimized\n");
5673 ok(!(style
& WS_MAXIMIZE
), "window should not be maximized\n");
5674 GetWindowRect(hwnd
, &rc
);
5675 ok(EqualRect(&rcMain
, &rc
), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
5676 rcMain
.left
, rcMain
.top
, rcMain
.right
, rcMain
.bottom
,
5677 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
5679 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
5680 ok(!ret
, "not expected ret: %lu\n", ret
);
5681 ok(IsWindow(hwnd
), "window should exist\n");
5683 ret
= EnableWindow(hwnd
, TRUE
);
5684 ok(ret
, "not expected ret: %lu\n", ret
);
5686 ret
= DefWindowProcA(hwnd
, WM_SYSCOMMAND
, SC_CLOSE
, 0);
5687 ok(!ret
, "not expected ret: %lu\n", ret
);
5688 ok(!IsWindow(hwnd
), "window should not exist\n");
5691 static void test_gettext(void)
5694 LPCSTR clsname
= "gettexttest";
5698 memset( &cls
, 0, sizeof cls
);
5699 cls
.lpfnWndProc
= DefWindowProcA
;
5700 cls
.lpszClassName
= clsname
;
5701 cls
.hInstance
= GetModuleHandleA(NULL
);
5703 if (!RegisterClassA( &cls
)) return;
5705 hwnd
= CreateWindowA( clsname
, "test text", WS_OVERLAPPED
, 0, 0, 10, 10, 0, NULL
, NULL
, NULL
);
5706 ok( hwnd
!= NULL
, "window was null\n");
5708 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x10, 0x1000);
5709 ok( r
== 0, "settext should return zero\n");
5711 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x10000, 0);
5712 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5714 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0xff000000, 0x1000);
5715 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5717 r
= SendMessageA( hwnd
, WM_GETTEXT
, 0x1000, 0xff000000);
5718 ok( r
== 0, "settext should return zero (%ld)\n", r
);
5720 DestroyWindow(hwnd
);
5721 UnregisterClassA( clsname
, NULL
);
5725 static void test_GetUpdateRect(void)
5728 BOOL ret
, parent_wm_paint
, grandparent_wm_paint
;
5730 HWND hgrandparent
, hparent
, hchild
;
5732 static const char classNameA
[] = "GetUpdateRectClass";
5734 hgrandparent
= CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW
,
5735 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
5737 hparent
= CreateWindowA("static", "parent", WS_CHILD
|WS_VISIBLE
,
5738 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
5740 hchild
= CreateWindowA("static", "child", WS_CHILD
|WS_VISIBLE
,
5741 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
5743 ShowWindow(hgrandparent
, SW_SHOW
);
5744 UpdateWindow(hgrandparent
);
5745 flush_events( TRUE
);
5747 ShowWindow(hchild
, SW_HIDE
);
5748 SetRect(&rc2
, 0, 0, 0, 0);
5749 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
5750 ok(!ret
, "GetUpdateRect returned not empty region\n");
5751 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5752 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5753 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5755 SetRect(&rc2
, 10, 10, 40, 40);
5756 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
5757 ok(ret
, "GetUpdateRect returned empty region\n");
5758 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5759 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5760 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5762 parent_wm_paint
= FALSE
;
5763 grandparent_wm_paint
= FALSE
;
5764 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
5766 if (msg
.message
== WM_PAINT
)
5768 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
5769 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
5771 DispatchMessageA(&msg
);
5773 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
5774 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
5776 DestroyWindow(hgrandparent
);
5779 cls
.lpfnWndProc
= DefWindowProcA
;
5782 cls
.hInstance
= GetModuleHandleA(0);
5784 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5785 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5786 cls
.lpszMenuName
= NULL
;
5787 cls
.lpszClassName
= classNameA
;
5789 if(!RegisterClassA(&cls
)) {
5790 trace("Register failed %d\n", GetLastError());
5794 hgrandparent
= CreateWindowA(classNameA
, "grandparent", WS_OVERLAPPEDWINDOW
,
5795 0, 0, 100, 100, NULL
, NULL
, 0, NULL
);
5797 hparent
= CreateWindowA(classNameA
, "parent", WS_CHILD
|WS_VISIBLE
,
5798 0, 0, 100, 100, hgrandparent
, NULL
, 0, NULL
);
5800 hchild
= CreateWindowA(classNameA
, "child", WS_CHILD
|WS_VISIBLE
,
5801 10, 10, 30, 30, hparent
, NULL
, 0, NULL
);
5803 ShowWindow(hgrandparent
, SW_SHOW
);
5804 UpdateWindow(hgrandparent
);
5805 flush_events( TRUE
);
5807 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
5808 ok(!ret
, "GetUpdateRect returned not empty region\n");
5810 ShowWindow(hchild
, SW_HIDE
);
5812 SetRect(&rc2
, 0, 0, 0, 0);
5813 ret
= GetUpdateRect(hgrandparent
, &rc1
, FALSE
);
5814 ok(!ret
, "GetUpdateRect returned not empty region\n");
5815 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5816 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5817 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5819 SetRect(&rc2
, 10, 10, 40, 40);
5820 ret
= GetUpdateRect(hparent
, &rc1
, FALSE
);
5821 ok(ret
, "GetUpdateRect returned empty region\n");
5822 ok(EqualRect(&rc1
, &rc2
), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
5823 rc1
.left
, rc1
.top
, rc1
.right
, rc1
.bottom
,
5824 rc2
.left
, rc2
.top
, rc2
.right
, rc2
.bottom
);
5826 parent_wm_paint
= FALSE
;
5827 grandparent_wm_paint
= FALSE
;
5828 while (PeekMessageA(&msg
, 0, 0, 0, PM_REMOVE
))
5830 if (msg
.message
== WM_PAINT
)
5832 if (msg
.hwnd
== hgrandparent
) grandparent_wm_paint
= TRUE
;
5833 if (msg
.hwnd
== hparent
) parent_wm_paint
= TRUE
;
5835 DispatchMessageA(&msg
);
5837 ok(parent_wm_paint
, "WM_PAINT should have been received in parent\n");
5838 ok(!grandparent_wm_paint
, "WM_PAINT should NOT have been received in grandparent\n");
5840 DestroyWindow(hgrandparent
);
5844 static LRESULT CALLBACK
TestExposedRegion_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
5852 const int waitTime
= 2000;
5854 BeginPaint(hwnd
, &ps
);
5856 /* create and destroy window to create an exposed region on this window */
5857 win
= CreateWindowA("static", "win", WS_VISIBLE
,
5858 10,10,50,50, NULL
, NULL
, 0, NULL
);
5861 waitResult
= MsgWaitForMultipleObjects( 0, NULL
, FALSE
, waitTime
, QS_PAINT
);
5863 ValidateRect(hwnd
, NULL
);
5864 EndPaint(hwnd
, &ps
);
5866 if(waitResult
!= WAIT_TIMEOUT
)
5868 GetUpdateRect(hwnd
, &updateRect
, FALSE
);
5869 ok(IsRectEmpty(&updateRect
), "Exposed rect should be empty\n");
5874 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
5877 static void test_Expose(void)
5882 memset(&cls
, 0, sizeof(WNDCLASSA
));
5883 cls
.lpfnWndProc
= TestExposedRegion_WndProc
;
5884 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5885 cls
.lpszClassName
= "TestExposeClass";
5886 RegisterClassA(&cls
);
5888 mw
= CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE
|WS_OVERLAPPEDWINDOW
,
5889 0, 0, 200, 100, NULL
, NULL
, 0, NULL
);
5895 static LRESULT CALLBACK
TestNCRedraw_WndProc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
5897 static UINT ncredrawflags
;
5903 ncredrawflags
= *(UINT
*) (((CREATESTRUCTA
*)lParam
)->lpCreateParams
);
5906 RedrawWindow(hwnd
, NULL
, NULL
, ncredrawflags
);
5909 BeginPaint(hwnd
, &ps
);
5910 EndPaint(hwnd
, &ps
);
5913 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
5916 static void run_NCRedrawLoop(UINT flags
)
5923 hwnd
= CreateWindowA("TestNCRedrawClass", "MainWindow",
5924 WS_OVERLAPPEDWINDOW
, 0, 0, 200, 100,
5925 NULL
, NULL
, 0, &flags
);
5926 ShowWindow(hwnd
, SW_SHOW
);
5928 flush_events( FALSE
);
5929 while (PeekMessageA(&msg
, hwnd
, 0, 0, PM_REMOVE
))
5931 if (msg
.message
== WM_PAINT
) loopcount
++;
5932 if (loopcount
>= 100) break;
5933 TranslateMessage(&msg
);
5934 DispatchMessageA(&msg
);
5935 MsgWaitForMultipleObjects(0, NULL
, FALSE
, 100, QS_ALLINPUT
);
5937 if (flags
== (RDW_INVALIDATE
| RDW_FRAME
))
5938 todo_wine
ok(loopcount
< 100, "Detected infinite WM_PAINT loop (%x).\n", flags
);
5940 ok(loopcount
< 100, "Detected infinite WM_PAINT loop (%x).\n", flags
);
5941 DestroyWindow(hwnd
);
5944 static void test_NCRedraw(void)
5948 wndclass
.lpszClassName
= "TestNCRedrawClass";
5949 wndclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
5950 wndclass
.lpfnWndProc
= TestNCRedraw_WndProc
;
5951 wndclass
.cbClsExtra
= 0;
5952 wndclass
.cbWndExtra
= 0;
5953 wndclass
.hInstance
= 0;
5954 wndclass
.hIcon
= LoadIconA(0, (LPCSTR
)IDI_APPLICATION
);
5955 wndclass
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
5956 wndclass
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
5957 wndclass
.lpszMenuName
= NULL
;
5959 RegisterClassA(&wndclass
);
5961 run_NCRedrawLoop(RDW_INVALIDATE
| RDW_FRAME
);
5962 run_NCRedrawLoop(RDW_INVALIDATE
);
5965 static void test_GetWindowModuleFileName(void)
5970 char buf1
[MAX_PATH
], buf2
[MAX_PATH
];
5972 if (!pGetWindowModuleFileNameA
)
5974 win_skip("GetWindowModuleFileNameA is not available\n");
5978 hwnd
= CreateWindowExA(0, "static", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
5981 hinst
= (HINSTANCE
)GetWindowLongPtrA(hwnd
, GWLP_HINSTANCE
);
5982 ok(hinst
== 0 || broken(hinst
== GetModuleHandleA(NULL
)), /* win9x */ "expected 0, got %p\n", hinst
);
5985 SetLastError(0xdeadbeef);
5986 ret1
= GetModuleFileNameA(hinst
, buf1
, sizeof(buf1
));
5987 ok(ret1
, "GetModuleFileName error %u\n", GetLastError());
5990 SetLastError(0xdeadbeef);
5991 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
5992 ok(ret2
|| broken(!ret2
), /* nt4 sp 3 */
5993 "GetWindowModuleFileNameA error %u\n", GetLastError());
5997 ok(ret1
== ret2
|| broken(ret2
== ret1
+ 1), /* win98 */ "%u != %u\n", ret1
, ret2
);
5998 ok(!strcmp(buf1
, buf2
), "%s != %s\n", buf1
, buf2
);
6000 hinst
= GetModuleHandleA(NULL
);
6002 SetLastError(0xdeadbeef);
6003 ret2
= GetModuleFileNameA(hinst
, buf2
, ret1
- 2);
6004 ok(ret2
== ret1
- 2 || broken(ret2
== ret1
- 3), /* win98 */
6005 "expected %u, got %u\n", ret1
- 2, ret2
);
6006 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6007 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6008 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6010 SetLastError(0xdeadbeef);
6011 ret2
= GetModuleFileNameA(hinst
, buf2
, 0);
6012 ok(!ret2
, "GetModuleFileName should return 0\n");
6013 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6014 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6015 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6017 SetLastError(0xdeadbeef);
6018 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, ret1
- 2);
6019 ok(ret2
== ret1
- 2 || broken(ret2
== ret1
- 3) /* win98 */ || broken(!ret2
), /* nt4 sp3 */
6020 "expected %u, got %u\n", ret1
- 2, ret2
);
6021 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6022 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6023 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6025 SetLastError(0xdeadbeef);
6026 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, 0);
6027 ok(!ret2
, "expected 0, got %u\n", ret2
);
6028 ok(GetLastError() == 0xdeadbeef /* XP */ ||
6029 GetLastError() == ERROR_INSUFFICIENT_BUFFER
, /* win2k3, vista */
6030 "expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
6032 DestroyWindow(hwnd
);
6035 hwnd
= (HWND
)0xdeadbeef;
6036 SetLastError(0xdeadbeef);
6037 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
6038 ok(!ret1
, "expected 0, got %u\n", ret1
);
6039 ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE
|| broken(GetLastError() == 0xdeadbeef), /* win9x */
6040 "expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
6042 hwnd
= FindWindowA("Shell_TrayWnd", NULL
);
6043 ok(IsWindow(hwnd
) || broken(!hwnd
), "got invalid tray window %p\n", hwnd
);
6044 SetLastError(0xdeadbeef);
6045 ret1
= pGetWindowModuleFileNameA(hwnd
, buf1
, sizeof(buf1
));
6046 ok(!ret1
|| broken(ret1
), /* win98 */ "expected 0, got %u\n", ret1
);
6048 if (!ret1
) /* inter-process GetWindowModuleFileName works on win9x, so don't test the desktop there */
6050 ret1
= GetModuleFileNameA(0, buf1
, sizeof(buf1
));
6051 hwnd
= GetDesktopWindow();
6052 ok(IsWindow(hwnd
), "got invalid desktop window %p\n", hwnd
);
6053 SetLastError(0xdeadbeef);
6054 ret2
= pGetWindowModuleFileNameA(hwnd
, buf2
, sizeof(buf2
));
6056 ret1
== ret2
|| /* vista */
6057 broken(ret2
), /* some win98 return user.exe as file name */
6058 "expected 0 or %u, got %u %s\n", ret1
, ret2
, buf2
);
6062 static void test_hwnd_message(void)
6064 static const WCHAR mainwindowclassW
[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
6065 static const WCHAR message_windowW
[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
6067 HWND parent
= 0, hwnd
, found
;
6070 /* HWND_MESSAGE is not supported below w2k, but win9x return != 0
6071 on CreateWindowExA and crash later in the test.
6072 Use UNICODE here to fail on win9x */
6073 hwnd
= CreateWindowExW(0, mainwindowclassW
, message_windowW
, WS_CAPTION
| WS_VISIBLE
,
6074 100, 100, 200, 200, HWND_MESSAGE
, 0, 0, NULL
);
6077 win_skip("CreateWindowExW with parent HWND_MESSAGE failed\n");
6081 ok( !GetParent(hwnd
), "GetParent should return 0 for message only windows\n" );
6085 HWND root
, desktop
= GetDesktopWindow();
6087 parent
= pGetAncestor(hwnd
, GA_PARENT
);
6088 ok(parent
!= 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
6089 ok(parent
!= desktop
, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
6090 root
= pGetAncestor(hwnd
, GA_ROOT
);
6091 ok(root
== hwnd
, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
6092 ok( !pGetAncestor(parent
, GA_PARENT
) || broken(pGetAncestor(parent
, GA_PARENT
) != 0), /* win2k */
6093 "parent shouldn't have parent %p\n", pGetAncestor(parent
, GA_PARENT
) );
6094 trace("parent %p root %p desktop %p\n", parent
, root
, desktop
);
6095 if (!GetClassNameA( parent
, buffer
, sizeof(buffer
) )) buffer
[0] = 0;
6096 ok( !lstrcmpiA( buffer
, "Message" ), "wrong parent class '%s'\n", buffer
);
6097 GetWindowRect( parent
, &rect
);
6098 ok( rect
.left
== 0 && rect
.right
== 100 && rect
.top
== 0 && rect
.bottom
== 100,
6099 "wrong parent rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6101 GetWindowRect( hwnd
, &rect
);
6102 ok( rect
.left
== 100 && rect
.right
== 300 && rect
.top
== 100 && rect
.bottom
== 300,
6103 "wrong window rect %d,%d-%d,%d\n", rect
.left
, rect
.top
, rect
.right
, rect
.bottom
);
6105 /* test FindWindow behavior */
6107 found
= FindWindowExA( 0, 0, 0, "message window" );
6108 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
6109 SetLastError(0xdeadbeef);
6110 found
= FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
6111 ok( found
== 0, "found message window %p/%p\n", found
, hwnd
);
6112 ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %d\n", GetLastError() );
6115 found
= FindWindowExA( parent
, 0, 0, "message window" );
6116 ok( found
== hwnd
, "didn't find message window %p/%p\n", found
, hwnd
);
6119 /* test IsChild behavior */
6121 if (parent
) ok( !IsChild( parent
, hwnd
), "HWND_MESSAGE is child of top window\n" );
6123 /* test IsWindowVisible behavior */
6125 ok( !IsWindowVisible( hwnd
), "HWND_MESSAGE window is visible\n" );
6126 if (parent
) ok( !IsWindowVisible( parent
), "HWND_MESSAGE parent is visible\n" );
6128 DestroyWindow(hwnd
);
6131 static void test_layered_window(void)
6137 POINT pt
= { 0, 0 };
6138 SIZE sz
= { 200, 200 };
6143 if (!pGetLayeredWindowAttributes
|| !pSetLayeredWindowAttributes
|| !pUpdateLayeredWindow
)
6145 win_skip( "layered windows not supported\n" );
6149 hdc
= CreateCompatibleDC( 0 );
6150 hbm
= CreateCompatibleBitmap( hdc
, 200, 200 );
6151 SelectObject( hdc
, hbm
);
6153 hwnd
= CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION
,
6154 100, 100, 200, 200, 0, 0, 0, NULL
);
6156 SetLastError( 0xdeadbeef );
6157 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6158 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
6159 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6160 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6161 ok( !ret
, "GetLayeredWindowAttributes should fail on non-layered window\n" );
6162 ret
= pSetLayeredWindowAttributes( hwnd
, 0, 0, LWA_ALPHA
);
6163 ok( !ret
, "SetLayeredWindowAttributes should fail on non-layered window\n" );
6164 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6165 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6166 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6167 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6168 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
6169 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6170 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6171 ret
= pSetLayeredWindowAttributes( hwnd
, 0x123456, 44, LWA_ALPHA
);
6172 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6173 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6174 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6175 ok( key
== 0x123456 || key
== 0, "wrong color key %x\n", key
);
6176 ok( alpha
== 44, "wrong alpha %u\n", alpha
);
6177 ok( flags
== LWA_ALPHA
, "wrong flags %x\n", flags
);
6178 SetLastError( 0xdeadbeef );
6179 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6180 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
6181 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6183 /* clearing WS_EX_LAYERED resets attributes */
6184 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
6185 SetLastError( 0xdeadbeef );
6186 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6187 ok( !ret
, "UpdateLayeredWindow should fail on non-layered window\n" );
6188 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6189 ok( !ret
, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
6190 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6191 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6192 ok( !ret
, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
6193 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6194 ok( ret
, "UpdateLayeredWindow should succeed on layered window\n" );
6195 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
| ULW_EX_NORESIZE
);
6196 ok( !ret
, "UpdateLayeredWindow should fail with ex flag\n" );
6197 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6198 if (pUpdateLayeredWindowIndirect
)
6200 UPDATELAYEREDWINDOWINFO info
;
6201 info
.cbSize
= sizeof(info
);
6209 info
.dwFlags
= ULW_OPAQUE
| ULW_EX_NORESIZE
;
6210 info
.prcDirty
= NULL
;
6211 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6212 ok( ret
, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
6214 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6215 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6216 ok( GetLastError() == ERROR_INCORRECT_SIZE
|| broken(GetLastError() == ERROR_MR_MID_NOT_FOUND
),
6217 "wrong error %u\n", GetLastError() );
6218 info
.dwFlags
= ULW_OPAQUE
;
6219 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6220 ok( ret
, "UpdateLayeredWindowIndirect should succeed on layered window\n" );
6222 info
.dwFlags
= ULW_OPAQUE
| 0xf00;
6223 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6224 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6225 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6227 info
.dwFlags
= ULW_OPAQUE
;
6228 ret
= pUpdateLayeredWindowIndirect( hwnd
, &info
);
6229 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6230 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6231 ret
= pUpdateLayeredWindowIndirect( hwnd
, NULL
);
6232 ok( !ret
, "UpdateLayeredWindowIndirect should fail\n" );
6233 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "wrong error %u\n", GetLastError() );
6236 ret
= pSetLayeredWindowAttributes( hwnd
, 0x654321, 22, LWA_COLORKEY
| LWA_ALPHA
);
6237 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6238 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6239 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6240 ok( key
== 0x654321, "wrong color key %x\n", key
);
6241 ok( alpha
== 22, "wrong alpha %u\n", alpha
);
6242 ok( flags
== (LWA_COLORKEY
| LWA_ALPHA
), "wrong flags %x\n", flags
);
6243 SetLastError( 0xdeadbeef );
6244 ret
= pUpdateLayeredWindow( hwnd
, 0, NULL
, &sz
, hdc
, &pt
, 0, NULL
, ULW_OPAQUE
);
6245 ok( !ret
, "UpdateLayeredWindow should fail on layered but initialized window\n" );
6246 ok( GetLastError() == ERROR_INVALID_PARAMETER
, "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError() );
6248 ret
= pSetLayeredWindowAttributes( hwnd
, 0x888888, 33, LWA_COLORKEY
);
6249 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6251 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6252 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6253 ok( key
== 0x888888, "wrong color key %x\n", key
);
6254 /* alpha not changed on vista if LWA_ALPHA is not set */
6255 ok( alpha
== 22 || alpha
== 33, "wrong alpha %u\n", alpha
);
6256 ok( flags
== LWA_COLORKEY
, "wrong flags %x\n", flags
);
6258 /* color key may or may not be changed without LWA_COLORKEY */
6259 ret
= pSetLayeredWindowAttributes( hwnd
, 0x999999, 44, 0 );
6260 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6262 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6263 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6264 ok( key
== 0x888888 || key
== 0x999999, "wrong color key %x\n", key
);
6265 ok( alpha
== 22 || alpha
== 44, "wrong alpha %u\n", alpha
);
6266 ok( flags
== 0, "wrong flags %x\n", flags
);
6268 /* default alpha and color key is 0 */
6269 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) & ~WS_EX_LAYERED
);
6270 SetWindowLongA( hwnd
, GWL_EXSTYLE
, GetWindowLongA(hwnd
, GWL_EXSTYLE
) | WS_EX_LAYERED
);
6271 ret
= pSetLayeredWindowAttributes( hwnd
, 0x222222, 55, 0 );
6272 ok( ret
, "SetLayeredWindowAttributes should succeed on layered window\n" );
6273 ret
= pGetLayeredWindowAttributes( hwnd
, &key
, &alpha
, &flags
);
6274 ok( ret
, "GetLayeredWindowAttributes should succeed on layered window\n" );
6275 ok( key
== 0 || key
== 0x222222, "wrong color key %x\n", key
);
6276 ok( alpha
== 0 || alpha
== 55, "wrong alpha %u\n", alpha
);
6277 ok( flags
== 0, "wrong flags %x\n", flags
);
6279 DestroyWindow( hwnd
);
6281 DeleteObject( hbm
);
6284 static MONITORINFO mi
;
6286 static LRESULT CALLBACK
fullscreen_wnd_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
6292 CREATESTRUCTA
*cs
= (CREATESTRUCTA
*)lp
;
6293 trace("WM_NCCREATE: rect %d,%d-%d,%d\n", cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
6294 ok(cs
->x
== mi
.rcMonitor
.left
&& cs
->y
== mi
.rcMonitor
.top
&&
6295 cs
->cx
== mi
.rcMonitor
.right
&& cs
->cy
== mi
.rcMonitor
.bottom
,
6296 "expected %d,%d-%d,%d, got %d,%d-%d,%d\n",
6297 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6298 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
);
6301 case WM_GETMINMAXINFO
:
6303 MINMAXINFO
*minmax
= (MINMAXINFO
*)lp
;
6304 dump_minmax_info(minmax
);
6305 ok(minmax
->ptMaxPosition
.x
<= mi
.rcMonitor
.left
, "%d <= %d\n", minmax
->ptMaxPosition
.x
, mi
.rcMonitor
.left
);
6306 ok(minmax
->ptMaxPosition
.y
<= mi
.rcMonitor
.top
, "%d <= %d\n", minmax
->ptMaxPosition
.y
, mi
.rcMonitor
.top
);
6307 ok(minmax
->ptMaxSize
.x
>= mi
.rcMonitor
.right
, "%d >= %d\n", minmax
->ptMaxSize
.x
, mi
.rcMonitor
.right
);
6308 ok(minmax
->ptMaxSize
.y
>= mi
.rcMonitor
.bottom
, "%d >= %d\n", minmax
->ptMaxSize
.y
, mi
.rcMonitor
.bottom
);
6312 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
6315 static void test_fullscreen(void)
6317 static const DWORD t_style
[] = {
6318 WS_OVERLAPPED
, WS_POPUP
, WS_CHILD
, WS_THICKFRAME
, WS_DLGFRAME
6320 static const DWORD t_ex_style
[] = {
6321 0, WS_EX_APPWINDOW
, WS_EX_TOOLWINDOW
6331 if (!pGetMonitorInfoA
|| !pMonitorFromPoint
)
6333 win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
6338 SetLastError(0xdeadbeef);
6339 hmon
= pMonitorFromPoint(pt
, MONITOR_DEFAULTTOPRIMARY
);
6340 ok(hmon
!= 0, "MonitorFromPoint error %u\n", GetLastError());
6342 mi
.cbSize
= sizeof(mi
);
6343 SetLastError(0xdeadbeef);
6344 ret
= pGetMonitorInfoA(hmon
, &mi
);
6345 ok(ret
, "GetMonitorInfo error %u\n", GetLastError());
6346 trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
6347 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6348 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
6351 cls
.lpfnWndProc
= fullscreen_wnd_proc
;
6354 cls
.hInstance
= GetModuleHandleA(NULL
);
6356 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6357 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6358 cls
.lpszMenuName
= NULL
;
6359 cls
.lpszClassName
= "fullscreen_class";
6360 RegisterClassA(&cls
);
6362 for (i
= 0; i
< sizeof(t_style
)/sizeof(t_style
[0]); i
++)
6364 DWORD style
, ex_style
;
6366 /* avoid a WM interaction */
6367 assert(!(t_style
[i
] & WS_VISIBLE
));
6369 for (j
= 0; j
< sizeof(t_ex_style
)/sizeof(t_ex_style
[0]); j
++)
6374 ex_style
= t_ex_style
[j
];
6376 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6377 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6378 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6379 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6380 GetWindowRect(hwnd
, &rc
);
6381 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6382 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6383 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6384 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6385 DestroyWindow(hwnd
);
6387 style
= t_style
[i
] | WS_MAXIMIZE
;
6388 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6389 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6390 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6391 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6392 GetWindowRect(hwnd
, &rc
);
6393 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6394 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6395 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6396 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6397 DestroyWindow(hwnd
);
6399 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
;
6400 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6401 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6402 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6403 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6404 GetWindowRect(hwnd
, &rc
);
6405 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6406 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6407 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6408 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6409 DestroyWindow(hwnd
);
6411 style
= t_style
[i
] | WS_CAPTION
| WS_MAXIMIZEBOX
;
6412 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6413 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6414 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6415 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6416 GetWindowRect(hwnd
, &rc
);
6417 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6418 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6419 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6420 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6421 DestroyWindow(hwnd
);
6423 style
= t_style
[i
] | WS_MAXIMIZE
| WS_CAPTION
| WS_MAXIMIZEBOX
;
6424 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6425 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6426 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6427 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6428 GetWindowRect(hwnd
, &rc
);
6429 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6430 /* Windows makes a maximized window slightly larger (to hide the borders?) */
6431 fixup
= min(abs(rc
.left
), abs(rc
.top
));
6432 InflateRect(&rc
, -fixup
, -fixup
);
6433 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
6434 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
6435 "%#x/%#x: window rect %d,%d-%d,%d must be in %d,%d-%d,%d\n",
6436 ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
,
6437 mi
.rcWork
.left
, mi
.rcWork
.top
, mi
.rcWork
.right
, mi
.rcWork
.bottom
);
6438 DestroyWindow(hwnd
);
6440 style
= t_style
[i
] | WS_MAXIMIZE
| WS_MAXIMIZEBOX
;
6441 hwnd
= CreateWindowExA(ex_style
, "fullscreen_class", NULL
, style
,
6442 mi
.rcMonitor
.left
, mi
.rcMonitor
.top
, mi
.rcMonitor
.right
, mi
.rcMonitor
.bottom
,
6443 GetDesktopWindow(), 0, GetModuleHandleA(NULL
), NULL
);
6444 ok(hwnd
!= 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i
, ex_style
, style
);
6445 GetWindowRect(hwnd
, &rc
);
6446 trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6447 /* Windows makes a maximized window slightly larger (to hide the borders?) */
6448 fixup
= min(abs(rc
.left
), abs(rc
.top
));
6449 InflateRect(&rc
, -fixup
, -fixup
);
6450 if (style
& (WS_CHILD
| WS_POPUP
))
6451 ok(rc
.left
<= mi
.rcMonitor
.left
&& rc
.top
<= mi
.rcMonitor
.top
&&
6452 rc
.right
>= mi
.rcMonitor
.right
&& rc
.bottom
>= mi
.rcMonitor
.bottom
,
6453 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6455 ok(rc
.left
>= mi
.rcWork
.left
&& rc
.top
<= mi
.rcWork
.top
&&
6456 rc
.right
<= mi
.rcWork
.right
&& rc
.bottom
<= mi
.rcWork
.bottom
,
6457 "%#x/%#x: window rect %d,%d-%d,%d\n", ex_style
, style
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
6458 DestroyWindow(hwnd
);
6462 UnregisterClassA("fullscreen_class", GetModuleHandleA(NULL
));
6465 static BOOL test_thick_child_got_minmax
;
6466 static const char * test_thick_child_name
;
6467 static LONG test_thick_child_style
;
6468 static LONG test_thick_child_exStyle
;
6470 static LRESULT WINAPI
test_thick_child_size_winproc(HWND hwnd
, UINT msg
, WPARAM wparam
, LPARAM lparam
)
6473 int expectedMinTrackX
;
6474 int expectedMinTrackY
;
6475 int actualMinTrackX
;
6476 int actualMinTrackY
;
6477 int expectedMaxTrackX
;
6478 int expectedMaxTrackY
;
6479 int actualMaxTrackX
;
6480 int actualMaxTrackY
;
6481 int expectedMaxSizeX
;
6482 int expectedMaxSizeY
;
6493 case WM_GETMINMAXINFO
:
6495 minmax
= (MINMAXINFO
*)lparam
;
6496 trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd
, wparam
, lparam
);
6497 dump_minmax_info( minmax
);
6499 test_thick_child_got_minmax
= TRUE
;
6502 adjustedStyle
= test_thick_child_style
;
6503 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
6504 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
6505 GetClientRect(GetParent(hwnd
), &rect
);
6506 AdjustWindowRectEx(&rect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
6508 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
6510 expectedMinTrackX
= GetSystemMetrics(SM_CXMINTRACK
);
6511 expectedMinTrackY
= GetSystemMetrics(SM_CYMINTRACK
);
6515 expectedMinTrackX
= -2 * rect
.left
;
6516 expectedMinTrackY
= -2 * rect
.top
;
6518 actualMinTrackX
= minmax
->ptMinTrackSize
.x
;
6519 actualMinTrackY
= minmax
->ptMinTrackSize
.y
;
6521 ok(actualMinTrackX
== expectedMinTrackX
&& actualMinTrackY
== expectedMinTrackY
,
6522 "expected minTrack %dx%d, actual minTrack %dx%d for %s\n",
6523 expectedMinTrackX
, expectedMinTrackY
, actualMinTrackX
, actualMinTrackY
,
6524 test_thick_child_name
);
6526 actualMaxTrackX
= minmax
->ptMaxTrackSize
.x
;
6527 actualMaxTrackY
= minmax
->ptMaxTrackSize
.y
;
6528 expectedMaxTrackX
= GetSystemMetrics(SM_CXMAXTRACK
);
6529 expectedMaxTrackY
= GetSystemMetrics(SM_CYMAXTRACK
);
6530 ok(actualMaxTrackX
== expectedMaxTrackX
&& actualMaxTrackY
== expectedMaxTrackY
,
6531 "expected maxTrack %dx%d, actual maxTrack %dx%d for %s\n",
6532 expectedMaxTrackX
, expectedMaxTrackY
, actualMaxTrackX
, actualMaxTrackY
,
6533 test_thick_child_name
);
6535 expectedMaxSizeX
= rect
.right
- rect
.left
;
6536 expectedMaxSizeY
= rect
.bottom
- rect
.top
;
6537 actualMaxSizeX
= minmax
->ptMaxSize
.x
;
6538 actualMaxSizeY
= minmax
->ptMaxSize
.y
;
6540 ok(actualMaxSizeX
== expectedMaxSizeX
&& actualMaxSizeY
== expectedMaxSizeY
,
6541 "expected maxSize %dx%d, actual maxSize %dx%d for %s\n",
6542 expectedMaxSizeX
, expectedMaxSizeY
, actualMaxSizeX
, actualMaxSizeY
,
6543 test_thick_child_name
);
6546 expectedPosX
= rect
.left
;
6547 expectedPosY
= rect
.top
;
6548 actualPosX
= minmax
->ptMaxPosition
.x
;
6549 actualPosY
= minmax
->ptMaxPosition
.y
;
6550 ok(actualPosX
== expectedPosX
&& actualPosY
== expectedPosY
,
6551 "expected maxPosition (%d/%d), actual maxPosition (%d/%d) for %s\n",
6552 expectedPosX
, expectedPosY
, actualPosX
, actualPosY
, test_thick_child_name
);
6558 return DefWindowProcA(hwnd
, msg
, wparam
, lparam
);
6561 #define NUMBER_OF_THICK_CHILD_TESTS 16
6562 static void test_thick_child_size(HWND parentWindow
)
6566 RECT adjustedParentRect
;
6571 LONG expectedHeight
;
6573 static const char className
[] = "THICK_CHILD_CLASS";
6576 static const LONG styles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6577 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6578 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6579 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6580 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6581 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6582 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6583 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6584 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6585 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6586 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6587 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6588 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6589 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
,
6590 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
,
6591 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_DLGFRAME
| WS_BORDER
,
6592 WS_CHILD
| WS_VISIBLE
| WS_THICKFRAME
| WS_BORDER
,
6595 static const LONG exStyles
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6600 WS_EX_DLGMODALFRAME
,
6601 WS_EX_DLGMODALFRAME
,
6602 WS_EX_DLGMODALFRAME
,
6603 WS_EX_DLGMODALFRAME
,
6608 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6609 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6610 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6611 WS_EX_STATICEDGE
| WS_EX_DLGMODALFRAME
,
6613 static const char *styleName
[NUMBER_OF_THICK_CHILD_TESTS
] = {
6614 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME",
6615 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME",
6616 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER",
6617 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER",
6618 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_DLGMODALFRAME",
6619 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_DLGMODALFRAME",
6620 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
6621 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
6622 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME exstyle= WS_EX_STATICEDGE",
6623 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE",
6624 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
6625 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
6626 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6627 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6628 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6629 "style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
6633 cls
.lpfnWndProc
= test_thick_child_size_winproc
;
6636 cls
.hInstance
= GetModuleHandleA(0);
6638 cls
.hCursor
= LoadCursorA(0, (LPCSTR
)IDC_ARROW
);
6639 cls
.hbrBackground
= GetStockObject(WHITE_BRUSH
);
6640 cls
.lpszMenuName
= NULL
;
6641 cls
.lpszClassName
= className
;
6642 SetLastError(0xdeadbeef);
6643 success
= RegisterClassA(&cls
);
6644 ok(success
,"RegisterClassA failed, error: %u\n", GetLastError());
6646 for(i
= 0; i
< NUMBER_OF_THICK_CHILD_TESTS
; i
++)
6648 test_thick_child_name
= styleName
[i
];
6649 test_thick_child_style
= styles
[i
];
6650 test_thick_child_exStyle
= exStyles
[i
];
6651 test_thick_child_got_minmax
= FALSE
;
6653 SetLastError(0xdeadbeef);
6654 childWindow
= CreateWindowExA( exStyles
[i
], className
, "", styles
[i
], 0, 0, 0, 0, parentWindow
, 0, GetModuleHandleA(0), NULL
);
6655 ok(childWindow
!= NULL
, "Failed to create child window, error: %u\n", GetLastError());
6657 ok(test_thick_child_got_minmax
, "Got no WM_GETMINMAXINFO\n");
6659 SetLastError(0xdeadbeef);
6660 success
= GetWindowRect(childWindow
, &childRect
);
6661 ok(success
,"GetWindowRect call failed, error: %u\n", GetLastError());
6662 childWidth
= childRect
.right
- childRect
.left
;
6663 childHeight
= childRect
.bottom
- childRect
.top
;
6665 adjustedStyle
= styles
[i
];
6666 if ((adjustedStyle
& WS_CAPTION
) == WS_CAPTION
)
6667 adjustedStyle
&= ~WS_BORDER
; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
6668 GetClientRect(GetParent(childWindow
), &adjustedParentRect
);
6669 AdjustWindowRectEx(&adjustedParentRect
, adjustedStyle
, FALSE
, test_thick_child_exStyle
);
6672 if (test_thick_child_style
& (WS_DLGFRAME
| WS_BORDER
))
6674 expectedWidth
= GetSystemMetrics(SM_CXMINTRACK
);
6675 expectedHeight
= GetSystemMetrics(SM_CYMINTRACK
);
6679 expectedWidth
= -2 * adjustedParentRect
.left
;
6680 expectedHeight
= -2 * adjustedParentRect
.top
;
6683 ok((childWidth
== expectedWidth
) && (childHeight
== expectedHeight
),
6684 "size of window (%s) is wrong: expected size %dx%d != actual size %dx%d\n",
6685 test_thick_child_name
, expectedWidth
, expectedHeight
, childWidth
, childHeight
);
6687 SetLastError(0xdeadbeef);
6688 success
= DestroyWindow(childWindow
);
6689 ok(success
,"DestroyWindow call failed, error: %u\n", GetLastError());
6691 ok(UnregisterClassA(className
, GetModuleHandleA(NULL
)),"UnregisterClass call failed\n");
6694 static void test_handles( HWND full_hwnd
)
6696 HWND hwnd
= full_hwnd
;
6700 SetLastError( 0xdeadbeef );
6701 ret
= GetWindowRect( hwnd
, &rect
);
6702 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6705 if ((ULONG_PTR
)full_hwnd
>> 32)
6706 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
& ~0u);
6708 hwnd
= (HWND
)((ULONG_PTR
)full_hwnd
| ((ULONG_PTR
)~0u << 32));
6709 SetLastError( 0xdeadbeef );
6710 ret
= GetWindowRect( hwnd
, &rect
);
6711 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6713 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& ~0u) | ((ULONG_PTR
)0x1234 << 32));
6714 SetLastError( 0xdeadbeef );
6715 ret
= GetWindowRect( hwnd
, &rect
);
6716 ok( ret
, "GetWindowRect failed for %p err %u\n", hwnd
, GetLastError() );
6718 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x9876 << 16));
6719 SetLastError( 0xdeadbeef );
6720 ret
= GetWindowRect( hwnd
, &rect
);
6721 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
6722 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
6724 hwnd
= (HWND
)(((ULONG_PTR
)full_hwnd
& 0xffff) | ((ULONG_PTR
)0x12345678 << 16));
6725 SetLastError( 0xdeadbeef );
6726 ret
= GetWindowRect( hwnd
, &rect
);
6727 ok( !ret
, "GetWindowRect succeeded for %p\n", hwnd
);
6728 ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE
, "wrong error %u\n", GetLastError() );
6732 static void test_winregion(void)
6739 if (!pGetWindowRgnBox
)
6741 win_skip("GetWindowRgnBox not supported\n");
6745 hwnd
= CreateWindowExA(0, "static", NULL
, WS_VISIBLE
, 10, 10, 10, 10, NULL
, 0, 0, NULL
);
6747 SetLastError(0xdeadbeef);
6748 ret
= pGetWindowRgnBox(hwnd
, NULL
);
6749 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
6750 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
6752 hrgn
= CreateRectRgn(2, 3, 10, 15);
6753 ok( hrgn
!= NULL
, "Region creation failed\n");
6756 SetWindowRgn(hwnd
, hrgn
, FALSE
);
6758 SetLastError(0xdeadbeef);
6759 ret
= pGetWindowRgnBox(hwnd
, NULL
);
6760 ok( ret
== ERROR
, "Expected ERROR, got %d\n", ret
);
6761 ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
6763 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6764 ret
= pGetWindowRgnBox(hwnd
, &r
);
6765 ok( ret
== SIMPLEREGION
, "Expected SIMPLEREGION, got %d\n", ret
);
6766 ok( r
.left
== 2 && r
.top
== 3 && r
.right
== 10 && r
.bottom
== 15,
6767 "Expected (2,3,10,15), got (%d,%d,%d,%d)\n", r
.left
, r
.top
,
6771 hrgn
= CreateRectRgn(2, 3, 10, 15);
6772 ret
= pMirrorRgn( hwnd
, hrgn
);
6773 ok( ret
== TRUE
, "MirrorRgn failed %u\n", ret
);
6774 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6775 GetWindowRect( hwnd
, &r
);
6776 width
= r
.right
- r
.left
;
6777 r
.left
= r
.top
= r
.right
= r
.bottom
= 0;
6778 ret
= GetRgnBox( hrgn
, &r
);
6779 ok( ret
== SIMPLEREGION
, "GetRgnBox failed %u\n", ret
);
6780 ok( r
.left
== width
- 10 && r
.top
== 3 && r
.right
== width
- 2 && r
.bottom
== 15,
6781 "Wrong rectangle (%d,%d,%d,%d) for width %d\n", r
.left
, r
.top
, r
.right
, r
.bottom
, width
);
6783 else win_skip( "MirrorRgn not supported\n" );
6785 DestroyWindow(hwnd
);
6788 static void test_rtl_layout(void)
6794 if (!pSetProcessDefaultLayout
)
6796 win_skip( "SetProcessDefaultLayout not supported\n" );
6800 parent
= CreateWindowExA(WS_EX_LAYOUTRTL
, "static", NULL
, WS_POPUP
, 100, 100, 300, 300, NULL
, 0, 0, NULL
);
6801 child
= CreateWindowExA(0, "static", NULL
, WS_CHILD
, 10, 10, 20, 20, parent
, 0, 0, NULL
);
6803 GetWindowRect( parent
, &r
);
6804 ok( r
.left
== 100 && r
.right
== 400, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6805 GetClientRect( parent
, &r
);
6806 ok( r
.left
== 0 && r
.right
== 300, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6807 GetClientRect( child
, &r
);
6808 ok( r
.left
== 0 && r
.right
== 20, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6809 MapWindowPoints( child
, parent
, (POINT
*)&r
, 2 );
6810 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6811 GetWindowRect( child
, &r
);
6812 ok( r
.left
== 370 && r
.right
== 390, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6813 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6814 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6815 GetWindowRect( child
, &r
);
6816 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 1 );
6817 MapWindowPoints( NULL
, parent
, (POINT
*)&r
+ 1, 1 );
6818 ok( r
.left
== 30 && r
.right
== 10, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6820 MapWindowPoints( child
, parent
, &pt
, 1 );
6821 ok( pt
.x
== 22 && pt
.y
== 22, "wrong point %d,%d\n", pt
.x
, pt
.y
);
6822 SetWindowPos( parent
, 0, 0, 0, 250, 250, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
6823 GetWindowRect( parent
, &r
);
6824 ok( r
.left
== 100 && r
.right
== 350, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6825 GetWindowRect( child
, &r
);
6826 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6827 SetWindowLongW( parent
, GWL_EXSTYLE
, 0 );
6828 GetWindowRect( child
, &r
);
6829 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6830 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6831 ok( r
.left
== 220 && r
.right
== 240, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6832 SetWindowLongW( parent
, GWL_EXSTYLE
, WS_EX_LAYOUTRTL
);
6833 GetWindowRect( child
, &r
);
6834 ok( r
.left
== 320 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6835 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6836 ok( r
.left
== 10 && r
.right
== 30, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6837 SetWindowPos( child
, 0, 0, 0, 30, 30, SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOACTIVATE
);
6838 GetWindowRect( child
, &r
);
6839 ok( r
.left
== 310 && r
.right
== 340, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6840 MapWindowPoints( NULL
, parent
, (POINT
*)&r
, 2 );
6841 ok( r
.left
== 10 && r
.right
== 40, "wrong rect %d,%d - %d,%d\n", r
.left
, r
.top
, r
.right
, r
.bottom
);
6842 DestroyWindow( child
);
6843 DestroyWindow( parent
);
6846 static void test_FlashWindowEx(void)
6852 if (!pFlashWindowEx
)
6854 win_skip( "FlashWindowEx not supported\n" );
6858 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_POPUP
,
6859 0, 0, 0, 0, 0, 0, 0, NULL
);
6860 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6862 finfo
.cbSize
= sizeof(FLASHWINFO
);
6863 finfo
.dwFlags
= FLASHW_TIMER
;
6865 finfo
.dwTimeout
= 200;
6867 SetLastError(0xdeadbeef);
6868 ret
= pFlashWindowEx(&finfo
);
6869 todo_wine
ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
6870 "FlashWindowEx returned with %d\n", GetLastError());
6873 SetLastError(0xdeadbeef);
6874 ret
= pFlashWindowEx(NULL
);
6875 todo_wine
ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
6876 "FlashWindowEx returned with %d\n", GetLastError());
6878 SetLastError(0xdeadbeef);
6879 ret
= pFlashWindowEx(&finfo
);
6880 todo_wine
ok(!ret
, "previous window state should not be active\n");
6882 finfo
.cbSize
= sizeof(FLASHWINFO
) - 1;
6883 SetLastError(0xdeadbeef);
6884 ret
= pFlashWindowEx(&finfo
);
6885 todo_wine
ok(!ret
&& GetLastError()==ERROR_INVALID_PARAMETER
,
6886 "FlashWindowEx succeeded\n");
6888 finfo
.cbSize
= sizeof(FLASHWINFO
) + 1;
6889 SetLastError(0xdeadbeef);
6890 ret
= pFlashWindowEx(&finfo
);
6891 todo_wine
ok(!ret
&& GetLastError()==ERROR_INVALID_PARAMETER
,
6892 "FlashWindowEx succeeded\n");
6893 finfo
.cbSize
= sizeof(FLASHWINFO
);
6895 DestroyWindow( hwnd
);
6897 SetLastError(0xdeadbeef);
6898 ret
= pFlashWindowEx(&finfo
);
6899 todo_wine
ok(!ret
&& GetLastError() == ERROR_INVALID_PARAMETER
,
6900 "FlashWindowEx returned with %d\n", GetLastError());
6902 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
6903 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
6904 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
6905 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
6906 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
6908 hwnd
= CreateWindowExA( 0, "MainWindowClass", "FlashWindow", WS_VISIBLE
| WS_POPUPWINDOW
,
6909 0, 0, 0, 0, 0, 0, 0, NULL
);
6910 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6913 SetLastError(0xdeadbeef);
6914 ret
= pFlashWindowEx(NULL
);
6915 todo_wine
ok(!ret
&& GetLastError() == ERROR_NOACCESS
,
6916 "FlashWindowEx returned with %d\n", GetLastError());
6918 SetLastError(0xdeadbeef);
6919 prev
= pFlashWindowEx(&finfo
);
6921 ok(finfo
.cbSize
== sizeof(FLASHWINFO
), "FlashWindowEx modified cdSize to %x\n", finfo
.cbSize
);
6922 ok(finfo
.hwnd
== hwnd
, "FlashWindowEx modified hwnd to %p\n", finfo
.hwnd
);
6923 ok(finfo
.dwFlags
== FLASHW_TIMER
, "FlashWindowEx modified dwFlags to %x\n", finfo
.dwFlags
);
6924 ok(finfo
.uCount
== 3, "FlashWindowEx modified uCount to %x\n", finfo
.uCount
);
6925 ok(finfo
.dwTimeout
== 200, "FlashWindowEx modified dwTimeout to %x\n", finfo
.dwTimeout
);
6927 finfo
.dwFlags
= FLASHW_STOP
;
6928 SetLastError(0xdeadbeef);
6929 ret
= pFlashWindowEx(&finfo
);
6931 ok(prev
!= ret
, "previous window state should be different\n");
6933 DestroyWindow( hwnd
);
6936 static void test_FindWindowEx(void)
6941 hwnd
= CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
6942 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6946 found
= FindWindowExA( 0, 0, "MainWindowClass", title
);
6947 ok( found
== NULL
, "expected a NULL hwnd\n" );
6948 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
6949 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
6951 DestroyWindow( hwnd
);
6953 hwnd
= CreateWindowExA( 0, "MainWindowClass", NULL
, WS_POPUP
, 0,0,0,0, 0, 0, 0, NULL
);
6954 ok( hwnd
!= 0, "CreateWindowExA error %d\n", GetLastError() );
6956 found
= FindWindowExA( 0, 0, "MainWindowClass", title
);
6957 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
6958 found
= FindWindowExA( 0, 0, "MainWindowClass", NULL
);
6959 ok( found
== hwnd
, "found is %p, expected a valid hwnd\n", found
);
6961 DestroyWindow( hwnd
);
6963 /* test behaviour with a window title that is an empty character */
6964 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", title
);
6965 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
6966 found
= FindWindowExA( 0, 0, "Shell_TrayWnd", NULL
);
6967 ok( found
!= NULL
, "found is NULL, expected a valid hwnd\n" );
6970 static void test_GetLastActivePopup(void)
6972 HWND hwndOwner
, hwndPopup1
, hwndPopup2
;
6974 hwndOwner
= CreateWindowExA(0, "MainWindowClass", NULL
,
6975 WS_VISIBLE
| WS_POPUPWINDOW
,
6977 NULL
, 0, GetModuleHandleA(NULL
), NULL
);
6978 hwndPopup1
= CreateWindowExA(0, "MainWindowClass", NULL
,
6979 WS_VISIBLE
| WS_POPUPWINDOW
,
6981 hwndOwner
, 0, GetModuleHandleA(NULL
), NULL
);
6982 hwndPopup2
= CreateWindowExA(0, "MainWindowClass", NULL
,
6983 WS_VISIBLE
| WS_POPUPWINDOW
,
6985 hwndPopup1
, 0, GetModuleHandleA(NULL
), NULL
);
6986 ok( GetLastActivePopup(hwndOwner
) == hwndPopup2
, "wrong last active popup\n" );
6987 DestroyWindow( hwndPopup2
);
6988 DestroyWindow( hwndPopup1
);
6989 DestroyWindow( hwndOwner
);
6992 static LRESULT WINAPI
my_httrasparent_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
6994 if (msg
== WM_NCHITTEST
) return HTTRANSPARENT
;
6995 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
6998 static LRESULT WINAPI
my_window_proc(HWND hwnd
, UINT msg
, WPARAM wp
, LPARAM lp
)
7000 return DefWindowProcA(hwnd
, msg
, wp
, lp
);
7003 static void create_window_tree(HWND parent
, HWND
*window
, int size
)
7005 static const DWORD style
[] = { 0, WS_VISIBLE
, WS_DISABLED
, WS_VISIBLE
| WS_DISABLED
};
7008 memset(window
, 0, size
* sizeof(window
[0]));
7011 for (i
= 0; i
< sizeof(style
)/sizeof(style
[0]); i
++)
7014 window
[pos
] = CreateWindowExA(0, "my_window", NULL
, style
[i
] | WS_CHILD
,
7015 0, 0, 100, 100, parent
, 0, 0, NULL
);
7016 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7019 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_window", NULL
, style
[i
] | WS_CHILD
,
7020 0, 0, 100, 100, parent
, 0, 0, NULL
);
7021 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7025 window
[pos
] = CreateWindowExA(0, "my_httrasparent", NULL
, style
[i
] | WS_CHILD
,
7026 0, 0, 100, 100, parent
, 0, 0, NULL
);
7027 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7030 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_httrasparent", NULL
, style
[i
] | WS_CHILD
,
7031 0, 0, 100, 100, parent
, 0, 0, NULL
);
7032 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7036 window
[pos
] = CreateWindowExA(0, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7037 0, 0, 100, 100, parent
, 0, 0, NULL
);
7038 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7041 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7042 0, 0, 100, 100, parent
, 0, 0, NULL
);
7043 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7046 window
[pos
] = CreateWindowExA(0, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7047 0, 0, 100, 100, parent
, 0, 0, NULL
);
7048 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7051 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "my_button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7052 0, 0, 100, 100, parent
, 0, 0, NULL
);
7053 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7057 window
[pos
] = CreateWindowExA(0, "Button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7058 0, 0, 100, 100, parent
, 0, 0, NULL
);
7059 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7062 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Button", NULL
, style
[i
] | WS_CHILD
| BS_GROUPBOX
,
7063 0, 0, 100, 100, parent
, 0, 0, NULL
);
7064 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7067 window
[pos
] = CreateWindowExA(0, "Button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7068 0, 0, 100, 100, parent
, 0, 0, NULL
);
7069 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7072 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Button", NULL
, style
[i
] | WS_CHILD
| BS_PUSHBUTTON
,
7073 0, 0, 100, 100, parent
, 0, 0, NULL
);
7074 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7078 window
[pos
] = CreateWindowExA(0, "Static", NULL
, style
[i
] | WS_CHILD
,
7079 0, 0, 100, 100, parent
, 0, 0, NULL
);
7080 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7083 window
[pos
] = CreateWindowExA(WS_EX_TRANSPARENT
, "Static", NULL
, style
[i
] | WS_CHILD
,
7084 0, 0, 100, 100, parent
, 0, 0, NULL
);
7085 ok(window
[pos
] != 0, "CreateWindowEx failed\n");
7090 struct window_attributes
7092 char class_name
[128];
7093 BOOL is_visible
, is_enabled
, is_groupbox
, is_httransparent
, is_extransparent
;
7096 static void get_window_attributes(HWND hwnd
, struct window_attributes
*attrs
)
7098 DWORD style
, ex_style
, hittest
;
7100 style
= GetWindowLongA(hwnd
, GWL_STYLE
);
7101 ex_style
= GetWindowLongA(hwnd
, GWL_EXSTYLE
);
7102 attrs
->class_name
[0] = 0;
7103 GetClassNameA(hwnd
, attrs
->class_name
, sizeof(attrs
->class_name
));
7104 hittest
= SendMessageA(hwnd
, WM_NCHITTEST
, 0, 0);
7106 attrs
->is_visible
= (style
& WS_VISIBLE
) != 0;
7107 attrs
->is_enabled
= (style
& WS_DISABLED
) == 0;
7108 attrs
->is_groupbox
= !lstrcmpiA(attrs
->class_name
, "Button") && (style
& BS_TYPEMASK
) == BS_GROUPBOX
;
7109 attrs
->is_httransparent
= hittest
== HTTRANSPARENT
;
7110 attrs
->is_extransparent
= (ex_style
& WS_EX_TRANSPARENT
) != 0;
7113 static int window_to_index(HWND hwnd
, HWND
*window
, int size
)
7117 for (i
= 0; i
< size
; i
++)
7119 if (!window
[i
]) break;
7120 if (window
[i
] == hwnd
) return i
;
7125 static void test_child_window_from_point(void)
7127 static const int real_child_pos
[] = { 14,15,16,17,18,19,20,21,24,25,26,27,42,43,
7128 44,45,46,47,48,49,52,53,54,55,51,50,23,22,-1 };
7129 static const int real_child_pos_nt4
[] = { 14,15,16,17,20,21,24,25,26,27,42,43,44,45,
7130 48,49,52,53,54,55,51,50,47,46,23,22,19,18,-1 };
7132 HWND hwnd
, parent
, window
[100];
7134 int found_invisible
, found_disabled
, found_groupbox
, found_httransparent
, found_extransparent
;
7137 ret
= GetClassInfoA(0, "Button", &cls
);
7138 ok(ret
, "GetClassInfo(Button) failed\n");
7139 cls
.lpszClassName
= "my_button";
7140 ret
= RegisterClassA(&cls
);
7141 ok(ret
, "RegisterClass(my_button) failed\n");
7143 cls
.lpszClassName
= "my_httrasparent";
7144 cls
.lpfnWndProc
= my_httrasparent_proc
;
7145 ret
= RegisterClassA(&cls
);
7146 ok(ret
, "RegisterClass(my_httrasparent) failed\n");
7148 cls
.lpszClassName
= "my_window";
7149 cls
.lpfnWndProc
= my_window_proc
;
7150 ret
= RegisterClassA(&cls
);
7151 ok(ret
, "RegisterClass(my_window) failed\n");
7153 parent
= CreateWindowExA(0, "MainWindowClass", NULL
,
7154 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
| WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
,
7156 0, 0, GetModuleHandleA(NULL
), NULL
);
7157 ok(parent
!= 0, "CreateWindowEx failed\n");
7158 trace("parent %p\n", parent
);
7160 create_window_tree(parent
, window
, sizeof(window
)/sizeof(window
[0]));
7162 found_invisible
= 0;
7165 found_httransparent
= 0;
7166 found_extransparent
= 0;
7168 /* FIXME: also test WindowFromPoint, ChildWindowFromPoint, ChildWindowFromPointEx */
7169 for (i
= 0; i
< sizeof(real_child_pos
)/sizeof(real_child_pos
[0]); i
++)
7171 struct window_attributes attrs
;
7174 hwnd
= RealChildWindowFromPoint(parent
, pt
);
7175 ok(hwnd
!= 0, "RealChildWindowFromPoint failed\n");
7176 ret
= window_to_index(hwnd
, window
, sizeof(window
)/sizeof(window
[0]));
7177 /* FIXME: remove once Wine is fixed */
7178 if (ret
!= real_child_pos
[i
])
7179 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
);
7181 ok(ret
== real_child_pos
[i
] || broken(ret
== real_child_pos_nt4
[i
]), "expected %d, got %d\n", real_child_pos
[i
], ret
);
7183 get_window_attributes(hwnd
, &attrs
);
7184 if (!attrs
.is_visible
) found_invisible
++;
7185 if (!attrs
.is_enabled
) found_disabled
++;
7186 if (attrs
.is_groupbox
) found_groupbox
++;
7187 if (attrs
.is_httransparent
) found_httransparent
++;
7188 if (attrs
.is_extransparent
) found_extransparent
++;
7190 if (ret
!= real_child_pos
[i
] && ret
!= -1)
7192 trace("found hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
7193 hwnd
, attrs
.class_name
, attrs
.is_visible
, attrs
.is_enabled
, attrs
.is_groupbox
, attrs
.is_httransparent
, attrs
.is_extransparent
);
7194 get_window_attributes(window
[real_child_pos
[i
]], &attrs
);
7195 trace("expected hwnd %p (%s), is_visible %d, is_enabled %d, is_groupbox %d, is_httransparent %d, is_extransparent %d\n",
7196 window
[real_child_pos
[i
]], attrs
.class_name
, attrs
.is_visible
, attrs
.is_enabled
, attrs
.is_groupbox
, attrs
.is_httransparent
, attrs
.is_extransparent
);
7200 ok(hwnd
== parent
, "expected %p, got %p\n", parent
, hwnd
);
7203 DestroyWindow(hwnd
);
7206 DestroyWindow(parent
);
7208 ok(!found_invisible
, "found %d invisible windows\n", found_invisible
);
7209 ok(found_disabled
, "found %d disabled windows\n", found_disabled
);
7211 ok(found_groupbox
== 4, "found %d groupbox windows\n", found_groupbox
);
7212 ok(found_httransparent
, "found %d httransparent windows\n", found_httransparent
);
7214 ok(found_extransparent
, "found %d extransparent windows\n", found_extransparent
);
7216 ret
= UnregisterClassA("my_button", cls
.hInstance
);
7217 ok(ret
, "UnregisterClass(my_button) failed\n");
7218 ret
= UnregisterClassA("my_httrasparent", cls
.hInstance
);
7219 ok(ret
, "UnregisterClass(my_httrasparent) failed\n");
7220 ret
= UnregisterClassA("my_window", cls
.hInstance
);
7221 ok(ret
, "UnregisterClass(my_window) failed\n");
7224 static void test_map_points(void)
7228 HWND wnd
, wnd0
, dwnd
;
7231 POINT pos
= { 100, 200 };
7237 /* Create test windows */
7238 wnd
= CreateWindowA("static", "test1", WS_POPUP
, pos
.x
, pos
.y
, width
, height
, NULL
, NULL
, NULL
, NULL
);
7239 ok(wnd
!= NULL
, "Failed %p\n", wnd
);
7240 wnd0
= CreateWindowA("static", "test2", WS_POPUP
, 0, 0, width
, height
, NULL
, NULL
, NULL
, NULL
);
7241 ok(wnd0
!= NULL
, "Failed %p\n", wnd
);
7242 dwnd
= CreateWindowA("static", "test3", 0, 200, 300, 150, 150, NULL
, NULL
, NULL
, NULL
);
7243 DestroyWindow(dwnd
);
7244 ok(dwnd
!= NULL
, "Failed %p\n", dwnd
);
7246 /* Verify window rect and client rect (they should have the same width and height) */
7247 GetWindowRect(wnd
, &window_rect
);
7248 ok(window_rect
.left
== pos
.x
, "left is %d instead of %d\n", window_rect
.left
, pos
.x
);
7249 ok(window_rect
.top
== pos
.y
, "top is %d instead of %d\n", window_rect
.top
, pos
.y
);
7250 ok(window_rect
.right
== pos
.x
+ width
, "right is %d instead of %d\n", window_rect
.right
, pos
.x
+ width
);
7251 ok(window_rect
.bottom
== pos
.y
+ height
, "bottom is %d instead of %d\n", window_rect
.bottom
, pos
.y
+ height
);
7252 GetClientRect(wnd
, &client_rect
);
7253 ok(client_rect
.left
== 0, "left is %d instead of 0\n", client_rect
.left
);
7254 ok(client_rect
.top
== 0, "top is %d instead of 0\n", client_rect
.top
);
7255 ok(client_rect
.right
== width
, "right is %d instead of %d\n", client_rect
.right
, width
);
7256 ok(client_rect
.bottom
== height
, "bottom is %d instead of %d\n", client_rect
.bottom
, height
);
7258 /* Test MapWindowPoints */
7260 /* MapWindowPoints(NULL or wnd, NULL or wnd, NULL, 1); crashes on Windows */
7262 SetLastError(0xdeadbeef);
7263 n
= MapWindowPoints(NULL
, NULL
, NULL
, 0);
7264 err
= GetLastError();
7265 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7266 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7268 SetLastError(0xdeadbeef);
7269 n
= MapWindowPoints(wnd
, wnd
, NULL
, 0);
7270 err
= GetLastError();
7271 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7272 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7274 n
= MapWindowPoints(wnd
, NULL
, NULL
, 0);
7275 ok(n
== MAKELONG(window_rect
.left
, window_rect
.top
), "Got %x, expected %x\n",
7276 n
, MAKELONG(window_rect
.left
, window_rect
.top
));
7278 n
= MapWindowPoints(NULL
, wnd
, NULL
, 0);
7279 ok(n
== MAKELONG(-window_rect
.left
, -window_rect
.top
), "Got %x, expected %x\n",
7280 n
, MAKELONG(-window_rect
.left
, -window_rect
.top
));
7282 SetLastError(0xdeadbeef);
7284 n
= MapWindowPoints(dwnd
, NULL
, &p
, 1);
7285 err
= GetLastError();
7286 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7287 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7288 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7290 SetLastError(0xdeadbeef);
7292 n
= MapWindowPoints(dwnd
, wnd
, &p
, 1);
7293 err
= GetLastError();
7294 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7295 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7296 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7298 SetLastError(0xdeadbeef);
7300 n
= MapWindowPoints(NULL
, dwnd
, &p
, 1);
7301 err
= GetLastError();
7302 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7303 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7304 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7306 SetLastError(0xdeadbeef);
7308 n
= MapWindowPoints(wnd
, dwnd
, &p
, 1);
7309 err
= GetLastError();
7310 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7311 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7312 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7314 SetLastError(0xdeadbeef);
7316 n
= MapWindowPoints(dwnd
, dwnd
, &p
, 1);
7317 err
= GetLastError();
7318 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7319 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7320 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7322 SetLastError(0xdeadbeef);
7324 n
= MapWindowPoints(NULL
, NULL
, &p
, 1);
7325 err
= GetLastError();
7326 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7327 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7328 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7330 SetLastError(0xdeadbeef);
7332 n
= MapWindowPoints(wnd
, wnd
, &p
, 1);
7333 err
= GetLastError();
7334 ok(n
== 0, "Got %d, expected %d\n", n
, 0);
7335 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7336 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7339 n
= MapWindowPoints(wnd
, NULL
, &p
, 1);
7340 ok(n
== MAKELONG(window_rect
.left
, window_rect
.top
), "Got %x, expected %x\n",
7341 n
, MAKELONG(window_rect
.left
, window_rect
.top
));
7342 ok((p
.x
== (window_rect
.left
+ 100)) && (p
.y
== (window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
7343 p
.x
, p
.y
, window_rect
.left
+ 100, window_rect
.top
+ 100);
7346 n
= MapWindowPoints(NULL
, wnd
, &p
, 1);
7347 ok(n
== MAKELONG(-window_rect
.left
, -window_rect
.top
), "Got %x, expected %x\n",
7348 n
, MAKELONG(-window_rect
.left
, -window_rect
.top
));
7349 ok((p
.x
== (-window_rect
.left
+ 100)) && (p
.y
== (-window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
7350 p
.x
, p
.y
, -window_rect
.left
+ 100, -window_rect
.top
+ 100);
7352 SetLastError(0xdeadbeef);
7354 n
= MapWindowPoints(wnd0
, NULL
, &p
, 1);
7355 err
= GetLastError();
7356 ok(n
== 0, "Got %x, expected 0\n", n
);
7357 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7358 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7360 SetLastError(0xdeadbeef);
7362 n
= MapWindowPoints(NULL
, wnd0
, &p
, 1);
7363 err
= GetLastError();
7364 ok(n
== 0, "Got %x, expected 0\n", n
);
7365 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7366 ok(err
== 0xdeadbeef, "Got %x, expected %x\n", err
, 0xdeadbeef);
7368 /* Test ClientToScreen */
7370 /* ClientToScreen(wnd, NULL); crashes on Windows */
7372 SetLastError(0xdeadbeef);
7373 ret
= ClientToScreen(NULL
, NULL
);
7374 err
= GetLastError();
7375 ok(!ret
, "Should fail\n");
7376 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7378 SetLastError(0xdeadbeef);
7380 ret
= ClientToScreen(NULL
, &p
);
7381 err
= GetLastError();
7382 ok(!ret
, "Should fail\n");
7383 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7384 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7386 SetLastError(0xdeadbeef);
7388 ret
= ClientToScreen(dwnd
, &p
);
7389 err
= GetLastError();
7390 ok(!ret
, "Should fail\n");
7391 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7392 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7395 ret
= ClientToScreen(wnd
, &p
);
7396 ok(ret
, "Failed with error %u\n", GetLastError());
7397 ok((p
.x
== (window_rect
.left
+ 100)) && (p
.y
== (window_rect
.top
+ 100)), "Failed got (%d, %d), expected (%d, %d)\n",
7398 p
.x
, p
.y
, window_rect
.left
+ 100, window_rect
.top
+ 100);
7401 ret
= ClientToScreen(wnd0
, &p
);
7402 ok(ret
, "Failed with error %u\n", GetLastError());
7403 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7405 /* Test ScreenToClient */
7407 /* ScreenToClient(wnd, NULL); crashes on Windows */
7409 SetLastError(0xdeadbeef);
7410 ret
= ScreenToClient(NULL
, NULL
);
7411 err
= GetLastError();
7412 ok(!ret
, "Should fail\n");
7413 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7415 SetLastError(0xdeadbeef);
7417 ret
= ScreenToClient(NULL
, &p
);
7418 err
= GetLastError();
7419 ok(!ret
, "Should fail\n");
7420 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7421 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7423 SetLastError(0xdeadbeef);
7425 ret
= ScreenToClient(dwnd
, &p
);
7426 err
= GetLastError();
7427 ok(!ret
, "Should fail\n");
7428 ok(p
.x
== 100 && p
.y
== 100, "Failed got(%d, %d), expected (%d, %d)\n", p
.x
, p
.y
, 100, 100);
7429 ok(err
== ERROR_INVALID_WINDOW_HANDLE
, "Got %x, expected %x\n", err
, ERROR_INVALID_WINDOW_HANDLE
);
7432 ret
= ScreenToClient(wnd
, &p
);
7433 ok(ret
, "Failed with error %u\n", GetLastError());
7434 ok((p
.x
== (-window_rect
.left
+ 100)) && (p
.y
== (-window_rect
.top
+ 100)), "Failed got(%d, %d), expected (%d, %d)\n",
7435 p
.x
, p
.y
, -window_rect
.left
+ 100, -window_rect
.top
+ 100);
7438 ret
= ScreenToClient(wnd0
, &p
);
7439 ok(ret
, "Failed with error %u\n", GetLastError());
7440 ok((p
.x
== 0) && (p
.y
== 0), "Failed got (%d, %d), expected (0, 0)\n", p
.x
, p
.y
);
7443 DestroyWindow(wnd0
);
7446 static void test_update_region(void)
7448 HWND hwnd
, parent
, child
;
7450 const RECT rc
= {15, 15, 40, 40};
7451 const POINT wnd_orig
= {30, 20};
7452 const POINT child_orig
= {10, 5};
7454 parent
= CreateWindowExA(0, "MainWindowClass", NULL
,
7455 WS_VISIBLE
| WS_CLIPCHILDREN
,
7456 0, 0, 300, 150, NULL
, NULL
, GetModuleHandleA(0), 0);
7457 hwnd
= CreateWindowExA(0, "MainWindowClass", NULL
,
7458 WS_VISIBLE
| WS_CLIPCHILDREN
| WS_CHILD
,
7459 0, 0, 200, 100, parent
, NULL
, GetModuleHandleA(0), 0);
7460 child
= CreateWindowExA(0, "MainWindowClass", NULL
,
7461 WS_VISIBLE
| WS_CHILD
,
7462 child_orig
.x
, child_orig
.y
, 100, 50,
7463 hwnd
, NULL
, GetModuleHandleA(0), 0);
7464 assert(parent
&& hwnd
&& child
);
7466 ValidateRgn(parent
, NULL
);
7467 ValidateRgn(hwnd
, NULL
);
7468 InvalidateRect(hwnd
, &rc
, FALSE
);
7469 ValidateRgn(child
, NULL
);
7471 rgn1
= CreateRectRgn(0, 0, 0, 0);
7472 ok(GetUpdateRgn(parent
, rgn1
, FALSE
) == NULLREGION
,
7473 "has invalid area after ValidateRgn(NULL)\n");
7474 GetUpdateRgn(hwnd
, rgn1
, FALSE
);
7475 rgn2
= CreateRectRgnIndirect(&rc
);
7476 ok(EqualRgn(rgn1
, rgn2
), "assigned and retrieved update regions are different\n");
7477 ok(GetUpdateRgn(child
, rgn2
, FALSE
) == NULLREGION
,
7478 "has invalid area after ValidateRgn(NULL)\n");
7480 SetWindowPos(hwnd
, 0, wnd_orig
.x
, wnd_orig
.y
, 0, 0,
7481 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOSIZE
);
7483 /* parent now has non-simple update region, it consist of
7484 * two rects, that was exposed after hwnd moving ... */
7485 SetRectRgn(rgn1
, 0, 0, 200, wnd_orig
.y
);
7486 SetRectRgn(rgn2
, 0, 0, wnd_orig
.x
, 100);
7487 CombineRgn(rgn1
, rgn1
, rgn2
, RGN_OR
);
7488 /* ... and mapped hwnd's invalid area, that hwnd has before moving */
7489 SetRectRgn(rgn2
, rc
.left
+ wnd_orig
.x
, rc
.top
+ wnd_orig
.y
,
7490 rc
.right
+ wnd_orig
.x
, rc
.bottom
+ wnd_orig
.y
);
7491 CombineRgn(rgn1
, rgn1
, rgn2
, RGN_OR
);
7492 GetUpdateRgn(parent
, rgn2
, FALSE
);
7494 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
7496 /* hwnd has the same invalid region as before moving */
7497 SetRectRgn(rgn1
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
);
7498 GetUpdateRgn(hwnd
, rgn2
, FALSE
);
7499 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
7501 /* hwnd's invalid area maps to child during moving */
7502 SetRectRgn(rgn1
, rc
.left
- child_orig
.x
, rc
.top
- child_orig
.y
,
7503 rc
.right
- child_orig
.x
, rc
.bottom
- child_orig
.y
);
7504 GetUpdateRgn(child
, rgn2
, FALSE
);
7506 ok(EqualRgn(rgn1
, rgn2
), "wrong update region\n");
7510 DestroyWindow(parent
);
7513 static void test_window_without_child_style(void)
7517 hwnd
= CreateWindowExA(0, "edit", NULL
, WS_VISIBLE
|WS_CHILD
,
7518 0, 0, 50, 50, hwndMain
, NULL
, 0, NULL
);
7519 ok(hwnd
!= NULL
, "CreateWindow failed\n");
7521 ok(SetWindowLongA(hwnd
, GWL_STYLE
, GetWindowLongA(hwnd
, GWL_STYLE
) & (~WS_CHILD
)),
7522 "can't remove WS_CHILD style\n");
7524 SetActiveWindow(hwndMain
);
7525 PostMessageW(hwnd
, WM_LBUTTONUP
, 0, 0);
7526 SendMessageW(hwnd
, WM_NCLBUTTONDOWN
, HTCAPTION
, 0);
7527 check_active_state(hwnd
, hwnd
, hwnd
);
7530 DestroyWindow(hwnd
);
7535 HMODULE user32
= GetModuleHandleA( "user32.dll" );
7536 HMODULE gdi32
= GetModuleHandleA("gdi32.dll");
7537 pGetAncestor
= (void *)GetProcAddress( user32
, "GetAncestor" );
7538 pGetWindowInfo
= (void *)GetProcAddress( user32
, "GetWindowInfo" );
7539 pGetWindowModuleFileNameA
= (void *)GetProcAddress( user32
, "GetWindowModuleFileNameA" );
7540 pGetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "GetLayeredWindowAttributes" );
7541 pSetLayeredWindowAttributes
= (void *)GetProcAddress( user32
, "SetLayeredWindowAttributes" );
7542 pUpdateLayeredWindow
= (void *)GetProcAddress( user32
, "UpdateLayeredWindow" );
7543 pUpdateLayeredWindowIndirect
= (void *)GetProcAddress( user32
, "UpdateLayeredWindowIndirect" );
7544 pGetMonitorInfoA
= (void *)GetProcAddress( user32
, "GetMonitorInfoA" );
7545 pMonitorFromPoint
= (void *)GetProcAddress( user32
, "MonitorFromPoint" );
7546 pGetWindowRgnBox
= (void *)GetProcAddress( user32
, "GetWindowRgnBox" );
7547 pGetGUIThreadInfo
= (void *)GetProcAddress( user32
, "GetGUIThreadInfo" );
7548 pGetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "GetProcessDefaultLayout" );
7549 pSetProcessDefaultLayout
= (void *)GetProcAddress( user32
, "SetProcessDefaultLayout" );
7550 pFlashWindowEx
= (void *)GetProcAddress( user32
, "FlashWindowEx" );
7551 pGetLayout
= (void *)GetProcAddress( gdi32
, "GetLayout" );
7552 pSetLayout
= (void *)GetProcAddress( gdi32
, "SetLayout" );
7553 pMirrorRgn
= (void *)GetProcAddress( gdi32
, "MirrorRgn" );
7555 if (!RegisterWindowClasses()) assert(0);
7557 hwndMain
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
7558 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
7559 WS_MAXIMIZEBOX
| WS_POPUP
| WS_VISIBLE
,
7561 0, 0, GetModuleHandleA(NULL
), NULL
);
7564 if(!SetForegroundWindow(hwndMain
)) {
7565 /* workaround for foreground lock timeout */
7569 memset(input
, 0, sizeof(input
));
7570 input
[0].type
= INPUT_MOUSE
;
7571 U(input
[0]).mi
.dx
= 101;
7572 U(input
[0]).mi
.dy
= 101;
7573 U(input
[0]).mi
.dwFlags
= MOUSEEVENTF_LEFTDOWN
;
7574 input
[0].type
= INPUT_MOUSE
;
7575 U(input
[0]).mi
.dx
= 101;
7576 U(input
[0]).mi
.dy
= 101;
7577 U(input
[0]).mi
.dwFlags
= MOUSEEVENTF_LEFTUP
;
7578 events_no
= SendInput(2, input
, sizeof(input
[0]));
7579 ok(events_no
== 2, "SendInput returned %d\n", events_no
);
7580 ok(SetForegroundWindow(hwndMain
), "SetForegroundWindow failed\n");
7583 SetLastError(0xdeafbeef);
7584 GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC
);
7585 is_win9x
= (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED
);
7587 hhook
= SetWindowsHookExA(WH_CBT
, cbt_hook_proc
, 0, GetCurrentThreadId());
7588 if (!hhook
) win_skip( "Cannot set CBT hook, skipping some tests\n" );
7590 /* make sure that these tests are executed first */
7591 test_FindWindowEx();
7594 hwndMain2
= CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
7595 WS_CAPTION
| WS_SYSMENU
| WS_MINIMIZEBOX
|
7596 WS_MAXIMIZEBOX
| WS_POPUP
,
7598 0, 0, GetModuleHandleA(NULL
), NULL
);
7599 assert( hwndMain2
);
7601 our_pid
= GetWindowThreadProcessId(hwndMain
, NULL
);
7603 /* Add the tests below this line */
7604 test_child_window_from_point();
7605 test_thick_child_size(hwndMain
);
7607 test_hwnd_message();
7608 test_nonclient_area(hwndMain
);
7610 test_GetWindowModuleFileName();
7613 test_capture_3(hwndMain
, hwndMain2
);
7616 test_FlashWindowEx();
7618 test_CreateWindow();
7619 test_parent_owner();
7620 test_enum_thread_windows();
7624 test_SetWindowPos(hwndMain
, hwndMain2
);
7625 test_SetMenu(hwndMain
);
7626 test_SetFocus(hwndMain
);
7627 test_SetActiveWindow(hwndMain
);
7630 test_children_zorder(hwndMain
);
7631 test_popup_zorder(hwndMain2
, hwndMain
, WS_POPUP
);
7632 test_popup_zorder(hwndMain2
, hwndMain
, 0);
7633 test_GetLastActivePopup();
7634 test_keyboard_input(hwndMain
);
7635 test_mouse_input(hwndMain
);
7636 test_validatergn(hwndMain
);
7637 test_nccalcscroll( hwndMain
);
7638 test_scrollwindow( hwndMain
);
7639 test_scrollvalidate( hwndMain
);
7640 test_scrolldc( hwndMain
);
7642 test_IsWindowUnicode();
7643 test_vis_rgn(hwndMain
);
7645 test_AdjustWindowRect();
7646 test_window_styles();
7647 test_dialog_styles();
7650 test_SetWindowLong();
7652 if (0) test_gettext(); /* crashes on NT4 */
7653 test_GetUpdateRect();
7655 test_layered_window();
7657 test_SetForegroundWindow(hwndMain
);
7658 if(!winetest_interactive
)
7659 skip("bug ROSTESTS-23: skipping test_shell_window, it crashes ros/win7 explorer\n");
7661 test_shell_window();
7662 test_handles( hwndMain
);
7665 test_update_region();
7666 test_window_without_child_style();
7668 /* add the tests above this line */
7669 if (hhook
) UnhookWindowsHookEx(hhook
);
7671 DestroyWindow(hwndMain2
);
7672 DestroyWindow(hwndMain
);