2002-09-25 02:21:56 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for window handling
|
|
|
|
*
|
|
|
|
* Copyright 2002 Bill Medland
|
|
|
|
* Copyright 2002 Alexandre Julliard
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-09-25 02:21:56 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2002-11-15 01:02:51 +01:00
|
|
|
#include "windef.h"
|
2002-09-25 02:21:56 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
|
2002-10-29 22:24:35 +01:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
|
|
|
#ifndef SPI_GETDESKWALLPAPER
|
|
|
|
#define SPI_GETDESKWALLPAPER 0x0073
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define LONG_PTR INT_PTR
|
|
|
|
#define ULONG_PTR UINT_PTR
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
|
|
|
|
|
|
|
|
static HWND hwndMain, hwndMain2;
|
|
|
|
|
|
|
|
/* check the values returned by the various parent/owner functions on a given window */
|
|
|
|
static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
|
|
|
|
HWND gw_owner, HWND ga_root, HWND ga_root_owner )
|
|
|
|
{
|
|
|
|
HWND res;
|
|
|
|
|
|
|
|
if (pGetAncestor)
|
|
|
|
{
|
|
|
|
res = pGetAncestor( hwnd, GA_PARENT );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p", res, ga_parent );
|
2002-09-25 02:21:56 +02:00
|
|
|
}
|
2003-01-03 20:09:23 +01:00
|
|
|
res = (HWND)GetWindowLongA( hwnd, GWL_HWNDPARENT );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( res == gwl_parent, "Wrong result for GWL_HWNDPARENT %p expected %p", res, gwl_parent );
|
2002-09-25 02:21:56 +02:00
|
|
|
res = GetParent( hwnd );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( res == get_parent, "Wrong result for GetParent %p expected %p", res, get_parent );
|
2002-09-25 02:21:56 +02:00
|
|
|
res = GetWindow( hwnd, GW_OWNER );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( res == gw_owner, "Wrong result for GW_OWNER %p expected %p", res, gw_owner );
|
2002-09-25 02:21:56 +02:00
|
|
|
if (pGetAncestor)
|
|
|
|
{
|
|
|
|
res = pGetAncestor( hwnd, GA_ROOT );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( res == ga_root, "Wrong result for GA_ROOT %p expected %p", res, ga_root );
|
2002-09-25 02:21:56 +02:00
|
|
|
res = pGetAncestor( hwnd, GA_ROOTOWNER );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( res == ga_root_owner, "Wrong result for GA_ROOTOWNER %p expected %p", res, ga_root_owner );
|
2002-09-25 02:21:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HWND create_tool_window( LONG style, HWND parent )
|
|
|
|
{
|
|
|
|
HWND ret = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style,
|
|
|
|
0, 0, 100, 100, parent, 0, 0, NULL );
|
|
|
|
ok( ret != 0, "Creation failed" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test parent and owner values for various combinations */
|
|
|
|
static void test_parent_owner(void)
|
|
|
|
{
|
|
|
|
LONG style;
|
|
|
|
HWND test, owner, ret;
|
|
|
|
HWND desktop = GetDesktopWindow();
|
|
|
|
HWND child = create_tool_window( WS_CHILD, hwndMain );
|
|
|
|
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "main window %p main2 %p desktop %p child %p\n", hwndMain, hwndMain2, desktop, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
|
|
|
/* child without parent, should fail */
|
|
|
|
test = CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
|
|
|
|
WS_CHILD, 0, 0, 100, 100, 0, 0, 0, NULL );
|
|
|
|
ok( !test, "WS_CHILD without parent created" );
|
|
|
|
|
|
|
|
/* desktop window */
|
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
2003-01-03 20:09:23 +01:00
|
|
|
style = GetWindowLongA( desktop, GWL_STYLE );
|
|
|
|
ok( !SetWindowLongA( desktop, GWL_STYLE, WS_POPUP ), "Set GWL_STYLE on desktop succeeded" );
|
|
|
|
ok( !SetWindowLongA( desktop, GWL_STYLE, 0 ), "Set GWL_STYLE on desktop succeeded" );
|
|
|
|
ok( GetWindowLongA( desktop, GWL_STYLE ) == style, "Desktop style changed" );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
|
|
|
/* normal child window */
|
|
|
|
test = create_tool_window( WS_CHILD, hwndMain );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created child %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain, hwndMain, hwndMain, 0, hwndMain, hwndMain );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, 0 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain, hwndMain, 0, 0, hwndMain, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_POPUP );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain, hwndMain, 0, 0, hwndMain, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_POPUP|WS_CHILD );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain, hwndMain, 0, 0, hwndMain, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_CHILD );
|
2002-09-25 02:21:56 +02:00
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* child of desktop */
|
|
|
|
test = create_tool_window( WS_CHILD, desktop );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created child of desktop %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_POPUP );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, 0 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* child of child */
|
|
|
|
test = create_tool_window( WS_CHILD, child );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created child of child %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, child, 0, hwndMain, hwndMain );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, 0 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, 0, 0, hwndMain, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_POPUP );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, 0, 0, hwndMain, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* not owned top-level window */
|
|
|
|
test = create_tool_window( 0, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created top-level %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_POPUP );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_CHILD );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* owned top-level window */
|
|
|
|
test = create_tool_window( 0, hwndMain );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created owned top-level %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_POPUP );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_CHILD );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* not owned popup */
|
|
|
|
test = create_tool_window( WS_POPUP, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created popup %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_CHILD );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, 0 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* owned popup */
|
|
|
|
test = create_tool_window( WS_POPUP, hwndMain );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created owned popup %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, WS_CHILD );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, desktop, hwndMain, test, desktop );
|
2003-01-03 20:09:23 +01:00
|
|
|
SetWindowLongA( test, GWL_STYLE, 0 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* top-level window owned by child (same as owned by top-level) */
|
|
|
|
test = create_tool_window( 0, child );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created top-level owned by child %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, 0, hwndMain, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* popup owned by desktop (same as not owned) */
|
|
|
|
test = create_tool_window( WS_POPUP, desktop );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created popup owned by desktop %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* popup owned by child (same as owned by top-level) */
|
|
|
|
test = create_tool_window( WS_POPUP, child );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created popup owned by child %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* not owned popup with WS_CHILD (same as WS_POPUP only) */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_CHILD, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created WS_CHILD popup %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* owned popup with WS_CHILD (same as WS_POPUP only) */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_CHILD, hwndMain );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created owned WS_CHILD popup %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain, hwndMain, hwndMain, test, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/******************** parent changes *************************/
|
|
|
|
trace( "testing parent changes\n" );
|
|
|
|
|
|
|
|
/* desktop window */
|
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2002-09-25 02:21:56 +02:00
|
|
|
ok( !ret, "Set GWL_HWNDPARENT succeeded on desktop" );
|
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
|
|
|
ok( !SetParent( desktop, hwndMain ), "SetParent succeeded on desktop" );
|
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
|
|
|
|
|
|
|
/* normal child window */
|
|
|
|
test = create_tool_window( WS_CHILD, hwndMain );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created child %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == hwndMain, "GWL_HWNDPARENT return value %p expected %p", ret, hwndMain );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain2, hwndMain2, hwndMain2, 0, hwndMain2, hwndMain2 );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p", ret, hwndMain2 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, child, 0, hwndMain, hwndMain );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)desktop );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p", ret, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
|
|
|
|
|
|
|
/* window is now child of desktop so GWL_HWNDPARENT changes owner from now on */
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, child, desktop, child, test, desktop );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p", ret, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* not owned top-level window */
|
|
|
|
test = create_tool_window( 0, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created top-level %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain2, 0, hwndMain2, test, test );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p", ret, hwndMain2 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, child, 0, child, test, test );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p", ret, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* not owned popup */
|
|
|
|
test = create_tool_window( WS_POPUP, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created popup %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain2, hwndMain2, hwndMain2, test, hwndMain2 );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (LONG_PTR)child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p", ret, hwndMain2 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, child, child, child, test, hwndMain );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p", ret, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, 0, 0, test, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* normal child window */
|
|
|
|
test = create_tool_window( WS_CHILD, hwndMain );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created child %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
|
|
|
ret = SetParent( test, desktop );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == hwndMain, "SetParent return value %p expected %p", ret, hwndMain );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
|
|
|
|
|
|
|
ret = SetParent( test, child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p", ret, desktop );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, child, 0, hwndMain, hwndMain );
|
|
|
|
|
|
|
|
ret = SetParent( test, hwndMain2 );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == child, "SetParent return value %p expected %p", ret, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain2, hwndMain2, hwndMain2, 0, hwndMain2, hwndMain2 );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* not owned top-level window */
|
|
|
|
test = create_tool_window( 0, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created top-level %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
|
|
|
ret = SetParent( test, child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p", ret, desktop );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, 0, 0, hwndMain, test );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* owned popup */
|
|
|
|
test = create_tool_window( WS_POPUP, hwndMain2 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created owned popup %p\n", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
|
|
|
ret = SetParent( test, child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p", ret, desktop );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, hwndMain2, hwndMain2, hwndMain, hwndMain2 );
|
|
|
|
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (ULONG_PTR)hwndMain );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p", ret, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain, hwndMain, hwndMain2, hwndMain2, hwndMain, hwndMain2 );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/**************** test owner destruction *******************/
|
|
|
|
|
|
|
|
/* owned child popup */
|
|
|
|
owner = create_tool_window( 0, 0 );
|
|
|
|
test = create_tool_window( WS_POPUP, owner );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created owner %p and popup %p\n", owner, test );
|
2002-09-25 02:21:56 +02:00
|
|
|
ret = SetParent( test, child );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p", ret, desktop );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, owner, owner, hwndMain, owner );
|
|
|
|
/* window is now child of 'child' but owned by 'owner' */
|
|
|
|
DestroyWindow( owner );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( IsWindow(test), "Window %p destroyed by owner destruction", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, owner, owner, hwndMain, owner );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( !IsWindow(owner), "Owner %p not destroyed", owner );
|
2002-09-25 02:21:56 +02:00
|
|
|
DestroyWindow(test);
|
|
|
|
|
|
|
|
/* owned top-level popup */
|
|
|
|
owner = create_tool_window( 0, 0 );
|
|
|
|
test = create_tool_window( WS_POPUP, owner );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created owner %p and popup %p\n", owner, test );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, owner, owner, owner, test, owner );
|
|
|
|
DestroyWindow( owner );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( !IsWindow(test), "Window %p not destroyed by owner destruction", test );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
|
|
|
/* top-level popup owned by child */
|
|
|
|
owner = create_tool_window( WS_CHILD, hwndMain2 );
|
|
|
|
test = create_tool_window( WS_POPUP, 0 );
|
2002-10-04 02:56:05 +02:00
|
|
|
trace( "created owner %p and popup %p\n", owner, test );
|
2003-01-03 20:09:23 +01:00
|
|
|
ret = (HWND)SetWindowLongA( test, GWL_HWNDPARENT, (ULONG_PTR)owner );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, owner, owner, owner, test, hwndMain2 );
|
|
|
|
DestroyWindow( owner );
|
2002-10-04 02:56:05 +02:00
|
|
|
ok( IsWindow(test), "Window %p destroyed by owner destruction", test );
|
|
|
|
ok( !IsWindow(owner), "Owner %p not destroyed", owner );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, owner, owner, owner, test, owner );
|
|
|
|
DestroyWindow(test);
|
|
|
|
|
|
|
|
/* final cleanup */
|
|
|
|
DestroyWindow(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL RegisterWindowClasses(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = DefWindowProcA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2003-09-10 05:56:47 +02:00
|
|
|
cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
|
2002-09-25 02:21:56 +02:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "MainWindowClass";
|
|
|
|
|
|
|
|
if(!RegisterClassA(&cls)) return FALSE;
|
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = DefWindowProcA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2003-09-10 05:56:47 +02:00
|
|
|
cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
|
2002-09-25 02:21:56 +02:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "ToolWindowClass";
|
|
|
|
|
|
|
|
if(!RegisterClassA(&cls)) return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
START_TEST(win)
|
|
|
|
{
|
|
|
|
pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
|
|
|
|
|
|
|
|
if (!RegisterWindowClasses()) assert(0);
|
|
|
|
|
|
|
|
hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
|
|
|
|
WS_MAXIMIZEBOX | WS_POPUP,
|
|
|
|
100, 100, 200, 200,
|
|
|
|
0, 0, 0, NULL);
|
|
|
|
hwndMain2 = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
|
|
|
|
WS_MAXIMIZEBOX | WS_POPUP,
|
|
|
|
100, 100, 200, 200,
|
|
|
|
0, 0, 0, NULL);
|
|
|
|
assert( hwndMain );
|
|
|
|
assert( hwndMain2 );
|
|
|
|
|
|
|
|
test_parent_owner();
|
|
|
|
}
|