2002-09-25 02:21:56 +02:00
|
|
|
/*
|
|
|
|
* Unit tests for window handling
|
|
|
|
*
|
|
|
|
* Copyright 2002 Bill Medland
|
|
|
|
* Copyright 2002 Alexandre Julliard
|
2003-12-30 22:54:54 +01:00
|
|
|
* Copyright 2003 Dmitry Timoshkov
|
2002-09-25 02:21:56 +02:00
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-09-25 02:21:56 +02:00
|
|
|
*/
|
|
|
|
|
2004-01-16 03:02:19 +01:00
|
|
|
/* To get ICON_SMALL2 with the MSVC headers */
|
|
|
|
#define _WIN32_WINNT 0x0501
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
#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
|
|
|
|
|
2005-03-25 18:11:04 +01:00
|
|
|
void dump_region(HRGN hrgn);
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
static HWND (WINAPI *pGetAncestor)(HWND,UINT);
|
2004-05-12 00:17:19 +02:00
|
|
|
static BOOL (WINAPI *pGetWindowInfo)(HWND,WINDOWINFO*);
|
2008-05-28 13:07:55 +02:00
|
|
|
static UINT (WINAPI *pGetWindowModuleFileNameA)(HWND,LPSTR,UINT);
|
2008-09-12 15:31:05 +02:00
|
|
|
static BOOL (WINAPI *pGetLayeredWindowAttributes)(HWND,COLORREF*,BYTE*,DWORD*);
|
|
|
|
static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
|
2008-10-16 12:58:56 +02:00
|
|
|
static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
|
|
|
|
static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
|
2009-04-02 09:53:00 +02:00
|
|
|
static int (WINAPI *pGetWindowRgnBox)(HWND,LPRECT);
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2005-03-07 18:13:07 +01:00
|
|
|
static BOOL test_lbuttondown_flag;
|
2004-05-12 00:17:19 +02:00
|
|
|
static HWND hwndMessage;
|
2002-09-25 02:21:56 +02:00
|
|
|
static HWND hwndMain, hwndMain2;
|
2003-10-24 06:22:24 +02:00
|
|
|
static HHOOK hhook;
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2005-05-24 11:51:20 +02:00
|
|
|
static const char* szAWRClass = "Winsize";
|
|
|
|
static HMENU hmenu;
|
2008-02-19 13:17:13 +01:00
|
|
|
static DWORD our_pid;
|
2005-05-24 11:51:20 +02:00
|
|
|
|
|
|
|
#define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
|
|
|
|
|
2008-06-04 12:34:53 +02:00
|
|
|
static void dump_minmax_info( const MINMAXINFO *minmax )
|
|
|
|
{
|
|
|
|
trace("Reserved=%d,%d MaxSize=%d,%d MaxPos=%d,%d MinTrack=%d,%d MaxTrack=%d,%d\n",
|
|
|
|
minmax->ptReserved.x, minmax->ptReserved.y,
|
|
|
|
minmax->ptMaxSize.x, minmax->ptMaxSize.y,
|
|
|
|
minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
|
|
|
|
minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
|
|
|
|
minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
|
|
|
|
}
|
|
|
|
|
2006-03-15 12:11:02 +01:00
|
|
|
/* try to make sure pending X events have been processed before continuing */
|
2008-03-21 11:29:18 +01:00
|
|
|
static void flush_events( BOOL remove_messages )
|
2006-03-15 12:11:02 +01:00
|
|
|
{
|
|
|
|
MSG msg;
|
2006-10-03 11:15:02 +02:00
|
|
|
int diff = 200;
|
2009-01-22 13:12:09 +01:00
|
|
|
int min_timeout = 100;
|
2006-03-15 12:11:02 +01:00
|
|
|
DWORD time = GetTickCount() + diff;
|
|
|
|
|
|
|
|
while (diff > 0)
|
|
|
|
{
|
2008-03-05 16:48:04 +01:00
|
|
|
if (MsgWaitForMultipleObjects( 0, NULL, FALSE, min_timeout, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
|
2008-03-21 11:29:18 +01:00
|
|
|
if (remove_messages)
|
|
|
|
while (PeekMessage( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessage( &msg );
|
2006-03-15 12:11:02 +01:00
|
|
|
diff = time - GetTickCount();
|
2009-01-22 13:12:09 +01:00
|
|
|
min_timeout = 50;
|
2006-03-15 12:11:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( res == ga_parent, "Wrong result for GA_PARENT %p expected %p\n", res, ga_parent );
|
2002-09-25 02:21:56 +02:00
|
|
|
}
|
2005-09-09 17:20:04 +02:00
|
|
|
res = (HWND)GetWindowLongPtrA( hwnd, GWLP_HWNDPARENT );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( res == gwl_parent, "Wrong result for GWL_HWNDPARENT %p expected %p\n", res, gwl_parent );
|
2002-09-25 02:21:56 +02:00
|
|
|
res = GetParent( hwnd );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( res == get_parent, "Wrong result for GetParent %p expected %p\n", res, get_parent );
|
2002-09-25 02:21:56 +02:00
|
|
|
res = GetWindow( hwnd, GW_OWNER );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( res == gw_owner, "Wrong result for GW_OWNER %p expected %p\n", res, gw_owner );
|
2002-09-25 02:21:56 +02:00
|
|
|
if (pGetAncestor)
|
|
|
|
{
|
|
|
|
res = pGetAncestor( hwnd, GA_ROOT );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( res == ga_root, "Wrong result for GA_ROOT %p expected %p\n", res, ga_root );
|
2002-09-25 02:21:56 +02:00
|
|
|
res = pGetAncestor( hwnd, GA_ROOTOWNER );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( res == ga_root_owner, "Wrong result for GA_ROOTOWNER %p expected %p\n", res, ga_root_owner );
|
2002-09-25 02:21:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-12 12:09:30 +02:00
|
|
|
static BOOL ignore_message( UINT message )
|
|
|
|
{
|
|
|
|
/* these are always ignored */
|
|
|
|
return (message >= 0xc000 ||
|
|
|
|
message == WM_GETICON ||
|
|
|
|
message == WM_GETOBJECT ||
|
|
|
|
message == WM_TIMECHANGE ||
|
|
|
|
message == WM_DEVICECHANGE);
|
|
|
|
}
|
|
|
|
|
2006-12-10 16:51:26 +01:00
|
|
|
static BOOL CALLBACK EnumChildProc( HWND hwndChild, LPARAM lParam)
|
2005-11-29 10:40:58 +01:00
|
|
|
{
|
|
|
|
(*(LPINT)lParam)++;
|
|
|
|
trace("EnumChildProc on %p\n", hwndChild);
|
|
|
|
if (*(LPINT)lParam > 1) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2006-01-25 15:07:02 +01:00
|
|
|
/* will search for the given window */
|
2006-12-10 16:51:26 +01:00
|
|
|
static BOOL CALLBACK EnumChildProc1( HWND hwndChild, LPARAM lParam)
|
2006-01-25 15:07:02 +01:00
|
|
|
{
|
|
|
|
trace("EnumChildProc1 on %p\n", hwndChild);
|
|
|
|
if ((HWND)lParam == hwndChild) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret != 0, "Creation failed\n" );
|
2002-09-25 02:21:56 +02:00
|
|
|
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 );
|
2005-11-29 10:40:58 +01:00
|
|
|
INT numChildren;
|
2002-09-25 02:21:56 +02:00
|
|
|
|
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 */
|
2006-08-04 19:08:00 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2002-09-25 02:21:56 +02:00
|
|
|
test = CreateWindowExA(0, "ToolWindowClass", "Tool window 1",
|
|
|
|
WS_CHILD, 0, 0, 100, 100, 0, 0, 0, NULL );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( !test, "WS_CHILD without parent created\n" );
|
2008-11-26 12:04:51 +01:00
|
|
|
ok( GetLastError() == ERROR_TLW_WITH_WSCHILD ||
|
|
|
|
broken(GetLastError() == 0xdeadbeef), /* win9x */
|
|
|
|
"CreateWindowExA error %u\n", GetLastError() );
|
2002-09-25 02:21:56 +02:00
|
|
|
|
|
|
|
/* desktop window */
|
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
2003-01-03 20:09:23 +01:00
|
|
|
style = GetWindowLongA( desktop, GWL_STYLE );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( !SetWindowLongA( desktop, GWL_STYLE, WS_POPUP ), "Set GWL_STYLE on desktop succeeded\n" );
|
|
|
|
ok( !SetWindowLongA( desktop, GWL_STYLE, 0 ), "Set GWL_STYLE on desktop succeeded\n" );
|
|
|
|
ok( GetWindowLongA( desktop, GWL_STYLE ) == style, "Desktop style changed\n" );
|
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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* normal child window with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_CHILD | WS_MAXIMIZE, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* normal child window with WS_THICKFRAME */
|
|
|
|
test = create_tool_window( WS_CHILD | WS_THICKFRAME, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* popup window with WS_THICKFRAME */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_THICKFRAME, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* child of desktop with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_CHILD | WS_MAXIMIZE, desktop );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* child of desktop with WS_MINIMIZE */
|
|
|
|
test = create_tool_window( WS_CHILD | WS_MINIMIZE, desktop );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* child of child with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_CHILD | WS_MAXIMIZE, child );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
|
|
|
/* child of child with WS_MINIMIZE */
|
|
|
|
test = create_tool_window( WS_CHILD | WS_MINIMIZE, child );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* not owned top-level window with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_MAXIMIZE, 0 );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* owned top-level window with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_MAXIMIZE, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* not owned popup with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_MAXIMIZE, 0 );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* owned popup with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_MAXIMIZE, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* top-level window owned by child (same as owned by top-level) with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_MAXIMIZE, child );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* popup owned by desktop (same as not owned) with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_MAXIMIZE, desktop );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* popup owned by child (same as owned by top-level) with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_MAXIMIZE, child );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* not owned popup with WS_CHILD | WS_MAXIMIZE (same as WS_POPUP only) */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_CHILD | WS_MAXIMIZE, 0 );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/* 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 );
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
/* owned popup with WS_CHILD (same as WS_POPUP only) with WS_MAXIMIZE */
|
|
|
|
test = create_tool_window( WS_POPUP | WS_CHILD | WS_MAXIMIZE, hwndMain );
|
|
|
|
DestroyWindow( test );
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
/******************** parent changes *************************/
|
|
|
|
trace( "testing parent changes\n" );
|
|
|
|
|
|
|
|
/* desktop window */
|
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
2006-12-14 18:10:47 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* this test succeeds on NT but crashes on win9x systems */
|
2007-05-24 10:15:31 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( !ret, "Set GWL_HWNDPARENT succeeded on desktop\n" );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( !SetParent( desktop, hwndMain ), "SetParent succeeded on desktop\n" );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( desktop, 0, 0, 0, 0, 0, 0 );
|
2006-12-14 18:10:47 +01:00
|
|
|
}
|
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
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == hwndMain, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, hwndMain2, hwndMain2, hwndMain2, 0, hwndMain2, hwndMain2 );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, child, 0, hwndMain, hwndMain );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)desktop );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", ret, child );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
/* window is now child of desktop so GWLP_HWNDPARENT changes owner from now on */
|
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, child, desktop, child, test, desktop );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, 0 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", 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
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain2, 0, hwndMain2, test, test );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, child, 0, child, test, test );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, 0 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", 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
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)hwndMain2 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, hwndMain2, hwndMain2, hwndMain2, test, hwndMain2 );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (LONG_PTR)child );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == hwndMain2, "GWL_HWNDPARENT return value %p expected %p\n", ret, hwndMain2 );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, child, child, child, test, hwndMain );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, 0 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", 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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == hwndMain, "SetParent return value %p expected %p\n", ret, hwndMain );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, 0, desktop, 0, test, desktop );
|
|
|
|
|
|
|
|
ret = SetParent( test, child );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, child, 0, hwndMain, hwndMain );
|
|
|
|
|
|
|
|
ret = SetParent( test, hwndMain2 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == child, "SetParent return value %p expected %p\n", 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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p\n", 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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, child, child, hwndMain2, hwndMain2, hwndMain, hwndMain2 );
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (ULONG_PTR)hwndMain );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == child, "GWL_HWNDPARENT return value %p expected %p\n", 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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p\n", 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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
|
2004-06-18 01:00:40 +02:00
|
|
|
/* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
|
|
|
|
* while Win95, Win2k, WinXP do.
|
|
|
|
*/
|
|
|
|
/*check_parents( test, child, child, owner, owner, hwndMain, owner );*/
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( !IsWindow(owner), "Owner %p not destroyed\n", 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 );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( !IsWindow(test), "Window %p not destroyed by owner destruction\n", 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 );
|
2005-09-09 17:20:04 +02:00
|
|
|
ret = (HWND)SetWindowLongPtrA( test, GWLP_HWNDPARENT, (ULONG_PTR)owner );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( ret == 0, "GWL_HWNDPARENT return value %p expected 0\n", ret );
|
2002-09-25 02:21:56 +02:00
|
|
|
check_parents( test, desktop, owner, owner, owner, test, hwndMain2 );
|
|
|
|
DestroyWindow( owner );
|
2004-01-23 21:50:35 +01:00
|
|
|
ok( IsWindow(test), "Window %p destroyed by owner destruction\n", test );
|
|
|
|
ok( !IsWindow(owner), "Owner %p not destroyed\n", owner );
|
2004-06-18 01:00:40 +02:00
|
|
|
/* Win98 doesn't pass this test. It doesn't allow a destroyed owner,
|
|
|
|
* while Win95, Win2k, WinXP do.
|
|
|
|
*/
|
|
|
|
/*check_parents( test, desktop, owner, owner, owner, test, owner );*/
|
2002-09-25 02:21:56 +02:00
|
|
|
DestroyWindow(test);
|
|
|
|
|
|
|
|
/* final cleanup */
|
|
|
|
DestroyWindow(child);
|
2005-11-29 10:40:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
owner = create_tool_window( WS_OVERLAPPED, 0 );
|
2006-01-25 15:07:02 +01:00
|
|
|
test = create_tool_window( WS_POPUP, desktop );
|
|
|
|
|
|
|
|
ok( !GetWindow( test, GW_OWNER ), "Wrong owner window\n" );
|
2005-11-29 10:40:58 +01:00
|
|
|
numChildren = 0;
|
|
|
|
ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
|
|
|
|
"EnumChildWindows should have returned FALSE\n" );
|
|
|
|
ok( numChildren == 0, "numChildren should be 0 got %d\n", numChildren );
|
|
|
|
|
|
|
|
SetWindowLongA( test, GWL_STYLE, (GetWindowLongA( test, GWL_STYLE ) & ~WS_POPUP) | WS_CHILD );
|
|
|
|
ret = SetParent( test, owner );
|
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
|
|
|
|
|
|
|
|
numChildren = 0;
|
|
|
|
ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
|
|
|
|
"EnumChildWindows should have returned TRUE\n" );
|
|
|
|
ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
|
|
|
|
|
|
|
|
child = create_tool_window( WS_CHILD, owner );
|
|
|
|
numChildren = 0;
|
|
|
|
ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
|
|
|
|
"EnumChildWindows should have returned FALSE\n" );
|
|
|
|
ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
|
2006-01-25 15:07:02 +01:00
|
|
|
DestroyWindow( child );
|
|
|
|
|
|
|
|
child = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, owner );
|
|
|
|
ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
|
|
|
|
numChildren = 0;
|
|
|
|
ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
|
|
|
|
"EnumChildWindows should have returned TRUE\n" );
|
|
|
|
ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
|
|
|
|
|
|
|
|
ret = SetParent( child, owner );
|
|
|
|
ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
|
|
|
|
ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
|
|
|
|
numChildren = 0;
|
|
|
|
ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
|
|
|
|
"EnumChildWindows should have returned FALSE\n" );
|
|
|
|
ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
|
|
|
|
|
|
|
|
ret = SetParent( child, NULL );
|
|
|
|
ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
|
|
|
|
ok( ret == owner, "SetParent return value %p expected %p\n", ret, owner );
|
|
|
|
numChildren = 0;
|
|
|
|
ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
|
|
|
|
"EnumChildWindows should have returned TRUE\n" );
|
|
|
|
ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
|
|
|
|
|
|
|
|
/* even GW_OWNER == owner it's still a desktop's child */
|
|
|
|
ok( !EnumChildWindows( desktop, EnumChildProc1, (LPARAM)child ),
|
|
|
|
"EnumChildWindows should have found %p and returned FALSE\n", child );
|
|
|
|
|
|
|
|
DestroyWindow( child );
|
|
|
|
child = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, NULL );
|
|
|
|
|
|
|
|
ok( !EnumChildWindows( desktop, EnumChildProc1, (LPARAM)child ),
|
|
|
|
"EnumChildWindows should have found %p and returned FALSE\n", child );
|
2005-11-29 10:40:58 +01:00
|
|
|
|
|
|
|
DestroyWindow( child );
|
|
|
|
DestroyWindow( test );
|
|
|
|
DestroyWindow( owner );
|
2002-09-25 02:21:56 +02:00
|
|
|
}
|
|
|
|
|
2009-10-23 14:46:58 +02:00
|
|
|
static BOOL CALLBACK enum_proc( HWND hwnd, LPARAM lParam)
|
|
|
|
{
|
|
|
|
(*(LPINT)lParam)++;
|
|
|
|
if (*(LPINT)lParam > 2) return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
static DWORD CALLBACK enum_thread( void *arg )
|
|
|
|
{
|
|
|
|
INT count;
|
|
|
|
HWND hwnd[3];
|
|
|
|
BOOL ret;
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
PeekMessage( &msg, 0, 0, 0, PM_NOREMOVE ); /* make sure we have a message queue */
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
ret = EnumThreadWindows( GetCurrentThreadId(), enum_proc, (LPARAM)&count );
|
|
|
|
ok( ret, "EnumThreadWindows should have returned TRUE\n" );
|
|
|
|
ok( count == 0, "count should be 0 got %d\n", count );
|
|
|
|
|
|
|
|
hwnd[0] = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", WS_POPUP,
|
|
|
|
0, 0, 100, 100, 0, 0, 0, NULL );
|
|
|
|
count = 0;
|
|
|
|
ret = EnumThreadWindows( GetCurrentThreadId(), enum_proc, (LPARAM)&count );
|
|
|
|
ok( ret, "EnumThreadWindows should have returned TRUE\n" );
|
|
|
|
if (count != 2) /* Vista gives us two windows for the price of one */
|
|
|
|
{
|
|
|
|
ok( count == 1, "count should be 1 got %d\n", count );
|
|
|
|
hwnd[2] = CreateWindowExA(0, "ToolWindowClass", "Tool window 2", WS_POPUP,
|
|
|
|
0, 0, 100, 100, 0, 0, 0, NULL );
|
|
|
|
}
|
|
|
|
else hwnd[2] = 0;
|
|
|
|
|
|
|
|
hwnd[1] = CreateWindowExA(0, "ToolWindowClass", "Tool window 3", WS_POPUP,
|
|
|
|
0, 0, 100, 100, 0, 0, 0, NULL );
|
|
|
|
count = 0;
|
|
|
|
ret = EnumThreadWindows( GetCurrentThreadId(), enum_proc, (LPARAM)&count );
|
|
|
|
ok( !ret, "EnumThreadWindows should have returned FALSE\n" );
|
2009-10-23 18:00:59 +02:00
|
|
|
ok( count == 3, "count should be 3 got %d\n", count );
|
2009-10-23 14:46:58 +02:00
|
|
|
|
|
|
|
if (hwnd[2]) DestroyWindow(hwnd[2]);
|
|
|
|
DestroyWindow(hwnd[1]);
|
|
|
|
DestroyWindow(hwnd[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* test EnumThreadWindows in a separate thread */
|
|
|
|
static void test_enum_thread_windows(void)
|
|
|
|
{
|
|
|
|
DWORD id;
|
|
|
|
HANDLE handle = CreateThread( NULL, 0, enum_thread, 0, 0, &id );
|
|
|
|
ok( !WaitForSingleObject( handle, 10000 ), "wait failed\n" );
|
|
|
|
CloseHandle( handle );
|
|
|
|
}
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
MINMAXINFO* minmax = (MINMAXINFO *)lparam;
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("WM_GETMINMAXINFO: hwnd %p, %08lx, %08lx\n", hwnd, wparam, lparam);
|
2008-06-04 12:34:53 +02:00
|
|
|
dump_minmax_info( minmax );
|
2005-09-09 17:20:04 +02:00
|
|
|
SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021);
|
2003-10-24 06:22:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2004-03-11 04:51:46 +01:00
|
|
|
case WM_WINDOWPOSCHANGING:
|
|
|
|
{
|
2005-02-24 18:03:01 +01:00
|
|
|
BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
|
2004-03-11 04:51:46 +01:00
|
|
|
WINDOWPOS *winpos = (WINDOWPOS *)lparam;
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("main: WM_WINDOWPOSCHANGING %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
|
2004-03-11 04:51:46 +01:00
|
|
|
winpos->hwnd, winpos->hwndInsertAfter,
|
|
|
|
winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
|
|
|
|
if (!(winpos->flags & SWP_NOMOVE))
|
|
|
|
{
|
|
|
|
ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
|
|
|
|
ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
|
|
|
|
}
|
|
|
|
/* Win9x does not fixup cx/xy for WM_WINDOWPOSCHANGING */
|
|
|
|
if (!(winpos->flags & SWP_NOSIZE) && !is_win9x)
|
|
|
|
{
|
|
|
|
ok(winpos->cx >= 0 && winpos->cx <= 32767, "bad winpos->cx %d\n", winpos->cx);
|
|
|
|
ok(winpos->cy >= 0 && winpos->cy <= 32767, "bad winpos->cy %d\n", winpos->cy);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
|
{
|
2004-06-15 20:27:06 +02:00
|
|
|
RECT rc1, rc2;
|
2004-03-11 04:51:46 +01:00
|
|
|
WINDOWPOS *winpos = (WINDOWPOS *)lparam;
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("main: WM_WINDOWPOSCHANGED %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
|
2004-03-11 04:51:46 +01:00
|
|
|
winpos->hwnd, winpos->hwndInsertAfter,
|
|
|
|
winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
|
|
|
|
ok(winpos->x >= -32768 && winpos->x <= 32767, "bad winpos->x %d\n", winpos->x);
|
|
|
|
ok(winpos->y >= -32768 && winpos->y <= 32767, "bad winpos->y %d\n", winpos->y);
|
|
|
|
|
|
|
|
ok(winpos->cx >= 0 && winpos->cx <= 32767, "bad winpos->cx %d\n", winpos->cx);
|
|
|
|
ok(winpos->cy >= 0 && winpos->cy <= 32767, "bad winpos->cy %d\n", winpos->cy);
|
2004-06-15 20:27:06 +02:00
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rc1);
|
|
|
|
SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
|
|
|
|
/* note: winpos coordinates are relative to parent */
|
|
|
|
MapWindowPoints(GetParent(hwnd), 0, (LPPOINT)&rc2, 2);
|
2006-12-14 18:10:47 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* Uncomment this once the test succeeds in all cases */
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
|
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom, rc2.left, rc2.top, rc2.right, rc2.bottom );
|
2004-06-15 20:27:06 +02:00
|
|
|
|
|
|
|
GetClientRect(hwnd, &rc2);
|
|
|
|
DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc1);
|
|
|
|
MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
|
2005-02-22 20:41:43 +01:00
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom, rc2.left, rc2.top, rc2.right, rc2.bottom );
|
2009-02-12 17:32:15 +01:00
|
|
|
}
|
2004-03-11 04:51:46 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-10-24 06:22:24 +02:00
|
|
|
case WM_NCCREATE:
|
|
|
|
{
|
2005-09-09 17:20:04 +02:00
|
|
|
BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021;
|
2003-10-24 06:22:24 +02:00
|
|
|
CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
|
|
|
|
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd, cs->hwndParent, cs->style);
|
2003-10-24 06:22:24 +02:00
|
|
|
if (got_getminmaxinfo)
|
|
|
|
trace("%p got WM_GETMINMAXINFO\n", hwnd);
|
|
|
|
|
|
|
|
if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
|
|
|
|
ok(got_getminmaxinfo, "main: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
|
|
|
|
else
|
|
|
|
ok(!got_getminmaxinfo, "main: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
|
|
|
|
break;
|
|
|
|
}
|
2005-03-07 18:13:07 +01:00
|
|
|
case WM_COMMAND:
|
|
|
|
if (test_lbuttondown_flag)
|
2008-03-21 11:29:18 +01:00
|
|
|
{
|
2005-03-07 18:13:07 +01:00
|
|
|
ShowWindow((HWND)wparam, SW_SHOW);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( FALSE );
|
|
|
|
}
|
2005-03-07 18:13:07 +01:00
|
|
|
break;
|
2003-10-24 06:22:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI tool_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
MINMAXINFO* minmax = (MINMAXINFO *)lparam;
|
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd, wparam, lparam);
|
2008-06-04 12:34:53 +02:00
|
|
|
dump_minmax_info( minmax );
|
2005-09-09 17:20:04 +02:00
|
|
|
SetWindowLongPtrA(hwnd, GWLP_USERDATA, 0x20031021);
|
2003-10-24 06:22:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WM_NCCREATE:
|
|
|
|
{
|
2005-09-09 17:20:04 +02:00
|
|
|
BOOL got_getminmaxinfo = GetWindowLongPtrA(hwnd, GWLP_USERDATA) == 0x20031021;
|
2003-10-24 06:22:24 +02:00
|
|
|
CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
|
|
|
|
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("WM_NCCREATE: hwnd %p, parent %p, style %08x\n", hwnd, cs->hwndParent, cs->style);
|
2003-10-24 06:22:24 +02:00
|
|
|
if (got_getminmaxinfo)
|
|
|
|
trace("%p got WM_GETMINMAXINFO\n", hwnd);
|
|
|
|
|
|
|
|
if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
|
|
|
|
ok(got_getminmaxinfo, "tool: WM_GETMINMAXINFO should have been received before WM_NCCREATE\n");
|
|
|
|
else
|
|
|
|
ok(!got_getminmaxinfo, "tool: WM_GETMINMAXINFO should NOT have been received before WM_NCCREATE\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
static BOOL RegisterWindowClasses(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
2005-03-07 18:13:07 +01:00
|
|
|
cls.style = CS_DBLCLKS;
|
2003-10-24 06:22:24 +02:00
|
|
|
cls.lpfnWndProc = main_window_procA;
|
2002-09-25 02:21:56 +02:00
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, 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;
|
2003-10-24 06:22:24 +02:00
|
|
|
cls.lpfnWndProc = tool_window_procA;
|
2002-09-25 02:21:56 +02:00
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, 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;
|
|
|
|
}
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
static void verify_window_info(const char *hook, HWND hwnd, const WINDOWINFO *info)
|
2004-05-12 00:17:19 +02:00
|
|
|
{
|
|
|
|
RECT rcWindow, rcClient;
|
|
|
|
DWORD status;
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(IsWindow(hwnd), "bad window handle %p in hook %s\n", hwnd, hook);
|
2004-05-12 00:17:19 +02:00
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rcWindow);
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rcWindow, &info->rcWindow), "wrong rcWindow for %p in hook %s\n", hwnd, hook);
|
2004-05-12 00:17:19 +02:00
|
|
|
|
|
|
|
GetClientRect(hwnd, &rcClient);
|
|
|
|
/* translate to screen coordinates */
|
|
|
|
MapWindowPoints(hwnd, 0, (LPPOINT)&rcClient, 2);
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rcClient, &info->rcClient), "wrong rcClient for %p in hook %s\n", hwnd, hook);
|
2004-05-12 00:17:19 +02:00
|
|
|
|
2005-03-14 11:05:50 +01:00
|
|
|
ok(info->dwStyle == (DWORD)GetWindowLongA(hwnd, GWL_STYLE),
|
2009-01-25 17:29:32 +01:00
|
|
|
"wrong dwStyle: %08x != %08x for %p in hook %s\n",
|
|
|
|
info->dwStyle, GetWindowLongA(hwnd, GWL_STYLE), hwnd, hook);
|
2008-06-10 13:03:37 +02:00
|
|
|
/* Windows reports some undocumented exstyles in WINDOWINFO, but
|
|
|
|
* doesn't return them in GetWindowLong(hwnd, GWL_EXSTYLE).
|
2006-11-02 08:17:15 +01:00
|
|
|
*/
|
2008-06-10 13:03:37 +02:00
|
|
|
ok((info->dwExStyle & ~0xe0000800) == (DWORD)GetWindowLongA(hwnd, GWL_EXSTYLE),
|
2009-01-25 17:29:32 +01:00
|
|
|
"wrong dwExStyle: %08x != %08x for %p in hook %s\n",
|
|
|
|
info->dwExStyle, GetWindowLongA(hwnd, GWL_EXSTYLE), hwnd, hook);
|
2008-11-21 15:53:25 +01:00
|
|
|
status = (GetActiveWindow() == hwnd) ? WS_ACTIVECAPTION : 0;
|
|
|
|
if (GetForegroundWindow())
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(info->dwWindowStatus == status, "wrong dwWindowStatus: %04x != %04x active %p fg %p in hook %s\n",
|
|
|
|
info->dwWindowStatus, status, GetActiveWindow(), GetForegroundWindow(), hook);
|
2004-05-12 00:17:19 +02:00
|
|
|
|
2007-03-03 05:49:33 +01:00
|
|
|
/* win2k and XP return broken border info in GetWindowInfo most of
|
|
|
|
* the time, so there is no point in testing it.
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
UINT border;
|
|
|
|
ok(info->cxWindowBorders == (unsigned)(rcClient.left - rcWindow.left),
|
|
|
|
"wrong cxWindowBorders %d != %d\n", info->cxWindowBorders, rcClient.left - rcWindow.left);
|
|
|
|
border = min(rcWindow.bottom - rcClient.bottom, rcClient.top - rcWindow.top);
|
|
|
|
ok(info->cyWindowBorders == border,
|
|
|
|
"wrong cyWindowBorders %d != %d\n", info->cyWindowBorders, border);
|
|
|
|
#endif
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(info->atomWindowType == GetClassLongA(hwnd, GCW_ATOM), "wrong atomWindowType for %p in hook %s\n",
|
|
|
|
hwnd, hook);
|
2007-03-03 05:49:33 +01:00
|
|
|
ok(info->wCreatorVersion == 0x0400 /* NT4, Win2000, XP, Win2003 */ ||
|
|
|
|
info->wCreatorVersion == 0x0500 /* Vista */,
|
2009-01-25 17:29:32 +01:00
|
|
|
"wrong wCreatorVersion %04x for %p in hook %s\n", info->wCreatorVersion, hwnd, hook);
|
2004-05-12 00:17:19 +02:00
|
|
|
}
|
|
|
|
|
2005-05-24 11:51:20 +02:00
|
|
|
static void FixedAdjustWindowRectEx(RECT* rc, LONG style, BOOL menu, LONG exstyle)
|
|
|
|
{
|
|
|
|
AdjustWindowRectEx(rc, style, menu, exstyle);
|
|
|
|
/* AdjustWindowRectEx does not include scroll bars */
|
|
|
|
if (style & WS_VSCROLL)
|
|
|
|
{
|
|
|
|
if(exstyle & WS_EX_LEFTSCROLLBAR)
|
|
|
|
rc->left -= GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
else
|
|
|
|
rc->right += GetSystemMetrics(SM_CXVSCROLL);
|
|
|
|
}
|
|
|
|
if (style & WS_HSCROLL)
|
|
|
|
rc->bottom += GetSystemMetrics(SM_CYHSCROLL);
|
|
|
|
}
|
|
|
|
|
2004-06-15 20:27:06 +02:00
|
|
|
static void test_nonclient_area(HWND hwnd)
|
|
|
|
{
|
|
|
|
DWORD style, exstyle;
|
|
|
|
RECT rc_window, rc_client, rc;
|
|
|
|
BOOL menu;
|
2005-09-09 17:20:04 +02:00
|
|
|
BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
|
2008-11-15 17:15:04 +01:00
|
|
|
LRESULT ret;
|
2004-06-15 20:27:06 +02:00
|
|
|
|
|
|
|
style = GetWindowLongA(hwnd, GWL_STYLE);
|
|
|
|
exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
|
|
|
menu = !(style & WS_CHILD) && GetMenu(hwnd) != 0;
|
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rc_window);
|
|
|
|
GetClientRect(hwnd, &rc_client);
|
|
|
|
|
|
|
|
/* avoid some cases when things go wrong */
|
|
|
|
if (IsRectEmpty(&rc_window) || IsRectEmpty(&rc_client) ||
|
|
|
|
rc_window.right > 32768 || rc_window.bottom > 32768) return;
|
|
|
|
|
|
|
|
CopyRect(&rc, &rc_client);
|
|
|
|
MapWindowPoints(hwnd, 0, (LPPOINT)&rc, 2);
|
2005-05-24 11:51:20 +02:00
|
|
|
FixedAdjustWindowRectEx(&rc, style, menu, exstyle);
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rc, &rc_window),
|
|
|
|
"window rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, win=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
|
|
|
|
style, exstyle, menu, rc_window.left, rc_window.top, rc_window.right, rc_window.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2005-05-24 11:51:20 +02:00
|
|
|
|
2004-06-15 20:27:06 +02:00
|
|
|
|
|
|
|
CopyRect(&rc, &rc_window);
|
|
|
|
DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc);
|
|
|
|
MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rc, &rc_client),
|
|
|
|
"client rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
|
|
|
|
style, exstyle, menu, rc_client.left, rc_client.top, rc_client.right, rc_client.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2005-05-24 11:51:20 +02:00
|
|
|
|
2008-11-15 17:15:04 +01:00
|
|
|
/* NULL rectangle shouldn't crash */
|
|
|
|
ret = DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, 0);
|
|
|
|
ok(ret == 0, "NULL rectangle returned %ld instead of 0\n", ret);
|
|
|
|
|
2005-05-24 11:51:20 +02:00
|
|
|
/* Win9x doesn't like WM_NCCALCSIZE with synthetic data and crashes */;
|
|
|
|
if (is_win9x)
|
|
|
|
return;
|
2004-06-15 20:27:06 +02:00
|
|
|
|
|
|
|
/* and now test AdjustWindowRectEx and WM_NCCALCSIZE on synthetic data */
|
|
|
|
SetRect(&rc_client, 0, 0, 250, 150);
|
|
|
|
CopyRect(&rc_window, &rc_client);
|
|
|
|
MapWindowPoints(hwnd, 0, (LPPOINT)&rc_window, 2);
|
2005-05-24 11:51:20 +02:00
|
|
|
FixedAdjustWindowRectEx(&rc_window, style, menu, exstyle);
|
2004-06-15 20:27:06 +02:00
|
|
|
|
|
|
|
CopyRect(&rc, &rc_window);
|
|
|
|
DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc);
|
|
|
|
MapWindowPoints(0, hwnd, (LPPOINT)&rc, 2);
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rc, &rc_client),
|
|
|
|
"synthetic rect does not match: style:exstyle=0x%08x:0x%08x, menu=%d, client=(%d,%d)-(%d,%d), calc=(%d,%d)-(%d,%d)\n",
|
|
|
|
style, exstyle, menu, rc_client.left, rc_client.top, rc_client.right, rc_client.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2004-06-15 20:27:06 +02:00
|
|
|
}
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
static LRESULT CALLBACK cbt_hook_proc(int nCode, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static const char *CBT_code_name[10] = {
|
|
|
|
"HCBT_MOVESIZE",
|
|
|
|
"HCBT_MINMAX",
|
|
|
|
"HCBT_QS",
|
|
|
|
"HCBT_CREATEWND",
|
|
|
|
"HCBT_DESTROYWND",
|
|
|
|
"HCBT_ACTIVATE",
|
|
|
|
"HCBT_CLICKSKIPPED",
|
|
|
|
"HCBT_KEYSKIPPED",
|
|
|
|
"HCBT_SYSCOMMAND",
|
|
|
|
"HCBT_SETFOCUS" };
|
|
|
|
const char *code_name = (nCode >= 0 && nCode <= HCBT_SETFOCUS) ? CBT_code_name[nCode] : "Unknown";
|
2009-01-25 17:29:32 +01:00
|
|
|
HWND hwnd = (HWND)wParam;
|
2003-10-24 06:22:24 +02:00
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
switch (nCode)
|
2004-06-15 20:27:06 +02:00
|
|
|
{
|
2009-01-22 13:12:09 +01:00
|
|
|
case HCBT_CREATEWND:
|
2003-10-24 06:22:24 +02:00
|
|
|
{
|
2004-05-12 00:17:19 +02:00
|
|
|
static const RECT rc_null;
|
|
|
|
RECT rc;
|
2004-04-13 00:05:53 +02:00
|
|
|
LONG style;
|
2003-10-24 06:22:24 +02:00
|
|
|
CBT_CREATEWNDA *createwnd = (CBT_CREATEWNDA *)lParam;
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("HCBT_CREATEWND: hwnd %p, parent %p, style %08x\n",
|
2009-01-25 17:29:32 +01:00
|
|
|
hwnd, createwnd->lpcs->hwndParent, createwnd->lpcs->style);
|
2003-10-24 06:22:24 +02:00
|
|
|
ok(createwnd->hwndInsertAfter == HWND_TOP, "hwndInsertAfter should be always HWND_TOP\n");
|
2004-02-06 06:18:56 +01:00
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
if (pGetWindowInfo)
|
|
|
|
{
|
|
|
|
WINDOWINFO info;
|
|
|
|
info.cbSize = sizeof(WINDOWINFO);
|
|
|
|
ok(pGetWindowInfo(hwnd, &info), "GetWindowInfo should not fail\n");
|
|
|
|
verify_window_info(code_name, hwnd, &info);
|
|
|
|
}
|
|
|
|
|
2004-02-06 06:18:56 +01:00
|
|
|
/* WS_VISIBLE should be turned off yet */
|
|
|
|
style = createwnd->lpcs->style & ~WS_VISIBLE;
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(style == GetWindowLongA(hwnd, GWL_STYLE),
|
2006-10-07 21:45:11 +02:00
|
|
|
"style of hwnd and style in the CREATESTRUCT do not match: %08x != %08x\n",
|
2009-01-25 17:29:32 +01:00
|
|
|
GetWindowLongA(hwnd, GWL_STYLE), style);
|
2004-05-12 00:17:19 +02:00
|
|
|
|
2006-12-14 18:10:47 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* Uncomment this once the test succeeds in all cases */
|
2004-05-12 00:17:19 +02:00
|
|
|
if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
|
|
|
|
{
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(GetParent(hwnd) == hwndMessage,
|
2004-05-12 00:17:19 +02:00
|
|
|
"wrong result from GetParent %p: message window %p\n",
|
2009-01-25 17:29:32 +01:00
|
|
|
GetParent(hwnd), hwndMessage);
|
2004-05-12 00:17:19 +02:00
|
|
|
}
|
|
|
|
else
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(!GetParent(hwnd), "GetParent should return 0 at this point\n");
|
2004-05-12 00:17:19 +02:00
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(!GetWindow(hwnd, GW_OWNER), "GW_OWNER should be set to 0 at this point\n");
|
2006-12-14 18:10:47 +01:00
|
|
|
}
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* while NT assigns GW_HWNDFIRST/LAST some values at this point,
|
2004-05-12 00:17:19 +02:00
|
|
|
* Win9x still has them set to 0.
|
|
|
|
*/
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(GetWindow(hwnd, GW_HWNDFIRST) != 0, "GW_HWNDFIRST should not be set to 0 at this point\n");
|
|
|
|
ok(GetWindow(hwnd, GW_HWNDLAST) != 0, "GW_HWNDLAST should not be set to 0 at this point\n");
|
2006-12-14 18:10:47 +01:00
|
|
|
}
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(!GetWindow(hwnd, GW_HWNDPREV), "GW_HWNDPREV should be set to 0 at this point\n");
|
|
|
|
ok(!GetWindow(hwnd, GW_HWNDNEXT), "GW_HWNDNEXT should be set to 0 at this point\n");
|
2004-05-12 00:17:19 +02:00
|
|
|
|
2006-12-14 18:10:47 +01:00
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
/* Uncomment this once the test succeeds in all cases */
|
2004-05-12 00:17:19 +02:00
|
|
|
if (pGetAncestor)
|
|
|
|
{
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(pGetAncestor(hwnd, GA_PARENT) == hwndMessage, "GA_PARENT should be set to hwndMessage at this point\n");
|
|
|
|
ok(pGetAncestor(hwnd, GA_ROOT) == hwnd,
|
|
|
|
"GA_ROOT is set to %p, expected %p\n", pGetAncestor(hwnd, GA_ROOT), hwnd);
|
2004-05-12 00:17:19 +02:00
|
|
|
|
|
|
|
if ((style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(pGetAncestor(hwnd, GA_ROOTOWNER) == hwndMessage,
|
2004-05-12 00:17:19 +02:00
|
|
|
"GA_ROOTOWNER should be set to hwndMessage at this point\n");
|
|
|
|
else
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(pGetAncestor(hwnd, GA_ROOTOWNER) == hwnd,
|
|
|
|
"GA_ROOTOWNER is set to %p, expected %p\n", pGetAncestor(hwnd, GA_ROOTOWNER), hwnd);
|
2004-05-12 00:17:19 +02:00
|
|
|
}
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(GetWindowRect(hwnd, &rc), "GetWindowRect failed\n");
|
2004-05-12 00:17:19 +02:00
|
|
|
ok(EqualRect(&rc, &rc_null), "window rect should be set to 0 HCBT_CREATEWND\n");
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(GetClientRect(hwnd, &rc), "GetClientRect failed\n");
|
2004-05-12 00:17:19 +02:00
|
|
|
ok(EqualRect(&rc, &rc_null), "client rect should be set to 0 on HCBT_CREATEWND\n");
|
2006-12-14 18:10:47 +01:00
|
|
|
}
|
2003-10-24 06:22:24 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-01-25 17:29:32 +01:00
|
|
|
case HCBT_MOVESIZE:
|
|
|
|
case HCBT_MINMAX:
|
|
|
|
case HCBT_ACTIVATE:
|
|
|
|
case HCBT_SETFOCUS:
|
|
|
|
if (pGetWindowInfo && IsWindow(hwnd))
|
|
|
|
{
|
|
|
|
WINDOWINFO info;
|
|
|
|
|
|
|
|
/* Win98 actually does check the info.cbSize and doesn't allow
|
|
|
|
* it to be anything except sizeof(WINDOWINFO), while Win95, Win2k,
|
|
|
|
* WinXP do not check it at all.
|
|
|
|
*/
|
|
|
|
info.cbSize = sizeof(WINDOWINFO);
|
|
|
|
ok(pGetWindowInfo(hwnd, &info), "GetWindowInfo should not fail\n");
|
|
|
|
verify_window_info(code_name, hwnd, &info);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* on HCBT_DESTROYWND window state is undefined */
|
|
|
|
case HCBT_DESTROYWND:
|
|
|
|
trace( "HCBT_DESTROYWND: hwnd %p\n", hwnd );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2003-10-24 06:22:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return CallNextHookEx(hhook, nCode, wParam, lParam);
|
|
|
|
}
|
2002-09-25 02:21:56 +02:00
|
|
|
|
2004-09-24 00:52:26 +02:00
|
|
|
static void test_shell_window(void)
|
2003-11-18 01:13:34 +01:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
DWORD error;
|
|
|
|
HMODULE hinst, hUser32;
|
|
|
|
BOOL (WINAPI*SetShellWindow)(HWND);
|
|
|
|
BOOL (WINAPI*SetShellWindowEx)(HWND, HWND);
|
|
|
|
HWND hwnd1, hwnd2, hwnd3, hwnd4, hwnd5;
|
|
|
|
HWND shellWindow, nextWnd;
|
|
|
|
|
2004-09-24 00:52:26 +02:00
|
|
|
if (!GetWindowLongW(GetDesktopWindow(), GWL_STYLE))
|
|
|
|
{
|
|
|
|
trace("Skipping shell window test on Win9x\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-11-18 01:13:34 +01:00
|
|
|
shellWindow = GetShellWindow();
|
|
|
|
hinst = GetModuleHandle(0);
|
|
|
|
hUser32 = GetModuleHandleA("user32");
|
|
|
|
|
|
|
|
SetShellWindow = (void *)GetProcAddress(hUser32, "SetShellWindow");
|
|
|
|
SetShellWindowEx = (void *)GetProcAddress(hUser32, "SetShellWindowEx");
|
|
|
|
|
|
|
|
trace("previous shell window: %p\n", shellWindow);
|
|
|
|
|
|
|
|
if (shellWindow) {
|
2004-09-24 00:52:26 +02:00
|
|
|
DWORD pid;
|
|
|
|
HANDLE hProcess;
|
|
|
|
|
2009-02-09 14:20:17 +01:00
|
|
|
GetWindowThreadProcessId(shellWindow, &pid);
|
|
|
|
hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
|
|
|
if (!hProcess)
|
|
|
|
{
|
|
|
|
skip( "cannot get access to shell process\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-11 23:00:10 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2003-11-18 01:13:34 +01:00
|
|
|
ret = DestroyWindow(shellWindow);
|
|
|
|
error = GetLastError();
|
|
|
|
|
|
|
|
ok(!ret, "DestroyWindow(shellWindow)\n");
|
2004-09-24 00:52:26 +02:00
|
|
|
/* passes on Win XP, but not on Win98 */
|
2008-11-11 23:00:10 +01:00
|
|
|
ok(error==ERROR_ACCESS_DENIED || error == 0xdeadbeef,
|
|
|
|
"got %u after DestroyWindow(shellWindow)\n", error);
|
2004-09-24 00:52:26 +02:00
|
|
|
|
|
|
|
/* close old shell instance */
|
|
|
|
ret = TerminateProcess(hProcess, 0);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(ret, "termination of previous shell process failed: GetLastError()=%d\n", GetLastError());
|
2004-09-24 00:52:26 +02:00
|
|
|
WaitForSingleObject(hProcess, INFINITE); /* wait for termination */
|
|
|
|
CloseHandle(hProcess);
|
2003-11-18 01:13:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hwnd1 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST1"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 100, 100, 300, 200, 0, 0, hinst, 0);
|
|
|
|
trace("created window 1: %p\n", hwnd1);
|
|
|
|
|
|
|
|
ret = SetShellWindow(hwnd1);
|
|
|
|
ok(ret, "first call to SetShellWindow(hwnd1)\n");
|
|
|
|
shellWindow = GetShellWindow();
|
2004-01-23 21:50:35 +01:00
|
|
|
ok(shellWindow==hwnd1, "wrong shell window: %p\n", shellWindow);
|
2003-11-18 01:13:34 +01:00
|
|
|
|
|
|
|
ret = SetShellWindow(hwnd1);
|
|
|
|
ok(!ret, "second call to SetShellWindow(hwnd1)\n");
|
|
|
|
|
|
|
|
ret = SetShellWindow(0);
|
|
|
|
error = GetLastError();
|
|
|
|
/* passes on Win XP, but not on Win98
|
|
|
|
ok(!ret, "reset shell window by SetShellWindow(0)\n");
|
|
|
|
ok(error==ERROR_INVALID_WINDOW_HANDLE, "ERROR_INVALID_WINDOW_HANDLE after SetShellWindow(0)\n"); */
|
|
|
|
|
|
|
|
ret = SetShellWindow(hwnd1);
|
|
|
|
/* passes on Win XP, but not on Win98
|
|
|
|
ok(!ret, "third call to SetShellWindow(hwnd1)\n"); */
|
|
|
|
|
2007-10-31 17:53:58 +01:00
|
|
|
SetWindowLong(hwnd1, GWL_EXSTYLE, GetWindowLong(hwnd1,GWL_EXSTYLE)|WS_EX_TOPMOST);
|
|
|
|
ret = GetWindowLong(hwnd1,GWL_EXSTYLE)&WS_EX_TOPMOST? TRUE: FALSE;
|
|
|
|
ok(!ret, "SetWindowExStyle(hwnd1, WS_EX_TOPMOST)\n");
|
2003-11-18 01:13:34 +01:00
|
|
|
|
|
|
|
ret = DestroyWindow(hwnd1);
|
|
|
|
ok(ret, "DestroyWindow(hwnd1)\n");
|
|
|
|
|
|
|
|
hwnd2 = CreateWindowEx(WS_EX_TOPMOST, TEXT("#32770"), TEXT("TEST2"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 150, 250, 300, 200, 0, 0, hinst, 0);
|
|
|
|
trace("created window 2: %p\n", hwnd2);
|
|
|
|
ret = SetShellWindow(hwnd2);
|
2004-01-23 21:50:35 +01:00
|
|
|
ok(!ret, "SetShellWindow(hwnd2) with WS_EX_TOPMOST\n");
|
2003-11-18 01:13:34 +01:00
|
|
|
|
|
|
|
hwnd3 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST3"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 200, 400, 300, 200, 0, 0, hinst, 0);
|
|
|
|
trace("created window 3: %p\n", hwnd3);
|
|
|
|
|
|
|
|
hwnd4 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST4"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 250, 500, 300, 200, 0, 0, hinst, 0);
|
|
|
|
trace("created window 4: %p\n", hwnd4);
|
|
|
|
|
|
|
|
nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
|
|
|
|
ok(nextWnd==hwnd3, "wrong next window for hwnd4: %p - expected hwnd3\n", nextWnd);
|
|
|
|
|
|
|
|
ret = SetShellWindow(hwnd4);
|
|
|
|
ok(ret, "SetShellWindow(hwnd4)\n");
|
|
|
|
shellWindow = GetShellWindow();
|
2004-01-23 21:50:35 +01:00
|
|
|
ok(shellWindow==hwnd4, "wrong shell window: %p - expected hwnd4\n", shellWindow);
|
2003-11-18 01:13:34 +01:00
|
|
|
|
|
|
|
nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
|
|
|
|
ok(nextWnd==0, "wrong next window for hwnd4: %p - expected 0\n", nextWnd);
|
|
|
|
|
|
|
|
ret = SetWindowPos(hwnd4, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
ok(ret, "SetWindowPos(hwnd4, HWND_TOPMOST)\n");
|
|
|
|
|
|
|
|
ret = SetWindowPos(hwnd4, hwnd3, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
2004-01-23 21:50:35 +01:00
|
|
|
ok(ret, "SetWindowPos(hwnd4, hwnd3\n");
|
2003-11-18 01:13:34 +01:00
|
|
|
|
|
|
|
ret = SetShellWindow(hwnd3);
|
|
|
|
ok(!ret, "SetShellWindow(hwnd3)\n");
|
|
|
|
shellWindow = GetShellWindow();
|
2004-01-23 21:50:35 +01:00
|
|
|
ok(shellWindow==hwnd4, "wrong shell window: %p - expected hwnd4\n", shellWindow);
|
2003-11-18 01:13:34 +01:00
|
|
|
|
|
|
|
hwnd5 = CreateWindowEx(0, TEXT("#32770"), TEXT("TEST5"), WS_OVERLAPPEDWINDOW/*|WS_VISIBLE*/, 300, 600, 300, 200, 0, 0, hinst, 0);
|
|
|
|
trace("created window 5: %p\n", hwnd5);
|
|
|
|
ret = SetWindowPos(hwnd4, hwnd5, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
ok(ret, "SetWindowPos(hwnd4, hwnd5)\n");
|
|
|
|
|
|
|
|
todo_wine
|
|
|
|
{
|
|
|
|
nextWnd = GetWindow(hwnd4, GW_HWNDNEXT);
|
|
|
|
ok(nextWnd==0, "wrong next window for hwnd4 after SetWindowPos(): %p - expected 0\n", nextWnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* destroy test windows */
|
|
|
|
DestroyWindow(hwnd2);
|
|
|
|
DestroyWindow(hwnd3);
|
|
|
|
DestroyWindow(hwnd4);
|
|
|
|
DestroyWindow(hwnd5);
|
|
|
|
}
|
|
|
|
|
2003-12-30 22:54:54 +01:00
|
|
|
/************** MDI test ****************/
|
|
|
|
|
2007-01-12 13:49:08 +01:00
|
|
|
static char mdi_lParam_test_message[] = "just a test string";
|
2003-12-30 22:54:54 +01:00
|
|
|
|
2009-01-03 20:16:33 +01:00
|
|
|
static void test_MDI_create(HWND parent, HWND mdi_client, INT_PTR first_id)
|
2003-12-30 22:54:54 +01:00
|
|
|
{
|
|
|
|
MDICREATESTRUCTA mdi_cs;
|
|
|
|
HWND mdi_child;
|
2009-01-03 20:16:33 +01:00
|
|
|
INT_PTR id;
|
2004-01-20 05:29:20 +01:00
|
|
|
static const WCHAR classW[] = {'M','D','I','_','c','h','i','l','d','_','C','l','a','s','s','_','1',0};
|
|
|
|
static const WCHAR titleW[] = {'M','D','I',' ','c','h','i','l','d',0};
|
|
|
|
BOOL isWin9x = FALSE;
|
2003-12-30 22:54:54 +01:00
|
|
|
|
|
|
|
mdi_cs.szClass = "MDI_child_Class_1";
|
2004-01-20 05:29:20 +01:00
|
|
|
mdi_cs.szTitle = "MDI child";
|
2003-12-30 22:54:54 +01:00
|
|
|
mdi_cs.hOwner = GetModuleHandle(0);
|
2004-01-20 05:29:20 +01:00
|
|
|
mdi_cs.x = CW_USEDEFAULT;
|
|
|
|
mdi_cs.y = CW_USEDEFAULT;
|
2003-12-30 22:54:54 +01:00
|
|
|
mdi_cs.cx = CW_USEDEFAULT;
|
|
|
|
mdi_cs.cy = CW_USEDEFAULT;
|
2004-01-20 05:29:20 +01:00
|
|
|
mdi_cs.style = 0;
|
2003-12-30 22:54:54 +01:00
|
|
|
mdi_cs.lParam = (LPARAM)mdi_lParam_test_message;
|
|
|
|
mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
2003-12-30 22:54:54 +01:00
|
|
|
|
2004-01-20 05:29:20 +01:00
|
|
|
mdi_cs.style = 0x7fffffff; /* without WS_POPUP */
|
|
|
|
mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
|
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
mdi_cs.style = 0xffffffff; /* with WS_POPUP */
|
|
|
|
mdi_child = (HWND)SendMessageA(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
|
|
|
|
if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
|
|
|
|
{
|
|
|
|
ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
|
|
|
|
}
|
|
|
|
else
|
2004-10-11 21:55:28 +02:00
|
|
|
{
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
|
|
|
}
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
/* test MDICREATESTRUCT A<->W mapping */
|
|
|
|
/* MDICREATESTRUCTA and MDICREATESTRUCTW have the same layout */
|
|
|
|
mdi_cs.style = 0;
|
|
|
|
mdi_cs.szClass = (LPCSTR)classW;
|
|
|
|
mdi_cs.szTitle = (LPCSTR)titleW;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
mdi_child = (HWND)SendMessageW(mdi_client, WM_MDICREATE, 0, (LPARAM)&mdi_cs);
|
|
|
|
if (!mdi_child)
|
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
isWin9x = TRUE;
|
|
|
|
else
|
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
|
|
|
}
|
2004-10-11 21:55:28 +02:00
|
|
|
else
|
|
|
|
{
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
|
|
|
}
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
|
|
|
|
0,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, GetModuleHandle(0),
|
|
|
|
(LPARAM)mdi_lParam_test_message);
|
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
|
|
|
|
0x7fffffff, /* without WS_POPUP */
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
2003-12-30 22:54:54 +01:00
|
|
|
mdi_client, GetModuleHandle(0),
|
|
|
|
(LPARAM)mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
2003-12-30 22:54:54 +01:00
|
|
|
|
2004-01-20 05:29:20 +01:00
|
|
|
mdi_child = CreateMDIWindowA("MDI_child_Class_1", "MDI child",
|
|
|
|
0xffffffff, /* with WS_POPUP */
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, GetModuleHandle(0),
|
|
|
|
(LPARAM)mdi_lParam_test_message);
|
|
|
|
if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
|
|
|
|
{
|
|
|
|
ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
|
|
|
|
}
|
|
|
|
else
|
2004-10-11 21:55:28 +02:00
|
|
|
{
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
|
|
|
}
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
/* test MDICREATESTRUCT A<->W mapping */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
mdi_child = CreateMDIWindowW(classW, titleW,
|
|
|
|
0,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, GetModuleHandle(0),
|
|
|
|
(LPARAM)mdi_lParam_test_message);
|
|
|
|
if (!mdi_child)
|
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
isWin9x = TRUE;
|
|
|
|
else
|
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
|
|
|
}
|
2004-10-11 21:55:28 +02:00
|
|
|
else
|
|
|
|
{
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
|
|
|
}
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
|
|
|
|
0,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
|
|
|
|
0x7fffffff, /* without WS_POPUP */
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
2003-12-30 22:54:54 +01:00
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_1", "MDI child",
|
|
|
|
0xffffffff, /* with WS_POPUP */
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
if (GetWindowLongA(mdi_client, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
|
|
|
|
{
|
|
|
|
ok(!mdi_child, "MDI child with WS_POPUP and with MDIS_ALLCHILDSTYLES should fail\n");
|
|
|
|
}
|
|
|
|
else
|
2004-10-11 21:55:28 +02:00
|
|
|
{
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
|
|
|
}
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
/* test MDICREATESTRUCT A<->W mapping */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
mdi_child = CreateWindowExW(WS_EX_MDICHILD, classW, titleW,
|
|
|
|
0,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
if (!mdi_child)
|
|
|
|
{
|
|
|
|
if (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
isWin9x = TRUE;
|
|
|
|
else
|
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
|
|
|
}
|
2004-10-11 21:55:28 +02:00
|
|
|
else
|
|
|
|
{
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == first_id, "wrong child id %ld\n", id);
|
2004-10-11 21:55:28 +02:00
|
|
|
SendMessageA(mdi_client, WM_MDIDESTROY, (WPARAM)mdi_child, 0);
|
|
|
|
ok(!IsWindow(mdi_child), "WM_MDIDESTROY failed\n");
|
|
|
|
}
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
/* This test fails on Win9x */
|
|
|
|
if (!isWin9x)
|
|
|
|
{
|
|
|
|
mdi_child = CreateWindowExA(WS_EX_MDICHILD, "MDI_child_Class_2", "MDI child",
|
|
|
|
WS_CHILD,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
parent, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(!mdi_child, "WS_EX_MDICHILD with a not MDIClient parent should fail\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
|
|
|
|
WS_CHILD, /* without WS_POPUP */
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == 0, "wrong child id %ld\n", id);
|
2004-01-20 05:29:20 +01:00
|
|
|
DestroyWindow(mdi_child);
|
|
|
|
|
|
|
|
mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
|
|
|
|
WS_CHILD | WS_POPUP, /* with WS_POPUP */
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == 0, "wrong child id %ld\n", id);
|
2003-12-30 22:54:54 +01:00
|
|
|
DestroyWindow(mdi_child);
|
2004-05-07 02:41:32 +02:00
|
|
|
|
|
|
|
/* maximized child */
|
|
|
|
mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
|
|
|
|
WS_CHILD | WS_MAXIMIZE,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-05-07 02:41:32 +02:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == 0, "wrong child id %ld\n", id);
|
2004-05-07 02:41:32 +02:00
|
|
|
DestroyWindow(mdi_child);
|
|
|
|
|
|
|
|
trace("Creating maximized child with a caption\n");
|
|
|
|
mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
|
|
|
|
WS_CHILD | WS_MAXIMIZE | WS_CAPTION,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-05-07 02:41:32 +02:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == 0, "wrong child id %ld\n", id);
|
2004-05-07 02:41:32 +02:00
|
|
|
DestroyWindow(mdi_child);
|
|
|
|
|
|
|
|
trace("Creating maximized child with a caption and a thick frame\n");
|
|
|
|
mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
|
|
|
|
WS_CHILD | WS_MAXIMIZE | WS_CAPTION | WS_THICKFRAME,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
mdi_client, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
mdi_lParam_test_message);
|
2004-05-07 02:41:32 +02:00
|
|
|
ok(mdi_child != 0, "MDI child creation failed\n");
|
2009-01-03 20:16:33 +01:00
|
|
|
id = GetWindowLongPtrA(mdi_child, GWLP_ID);
|
|
|
|
ok(id == 0, "wrong child id %ld\n", id);
|
2004-05-07 02:41:32 +02:00
|
|
|
DestroyWindow(mdi_child);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
|
|
|
|
*
|
|
|
|
* Note: The rule here is that client rect of the maximized MDI child
|
|
|
|
* is equal to the client rect of the MDI client window.
|
|
|
|
*/
|
|
|
|
static void MDI_ChildGetMinMaxInfo( HWND client, HWND hwnd, MINMAXINFO* lpMinMax )
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
GetClientRect( client, &rect );
|
|
|
|
AdjustWindowRectEx( &rect, GetWindowLongA( hwnd, GWL_STYLE ),
|
|
|
|
0, GetWindowLongA( hwnd, GWL_EXSTYLE ));
|
|
|
|
|
|
|
|
rect.right -= rect.left;
|
|
|
|
rect.bottom -= rect.top;
|
|
|
|
lpMinMax->ptMaxSize.x = rect.right;
|
|
|
|
lpMinMax->ptMaxSize.y = rect.bottom;
|
|
|
|
|
|
|
|
lpMinMax->ptMaxPosition.x = rect.left;
|
|
|
|
lpMinMax->ptMaxPosition.y = rect.top;
|
|
|
|
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("max rect (%d,%d - %d, %d)\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
rect.left, rect.top, rect.right, rect.bottom);
|
2003-12-30 22:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
2004-01-20 05:29:20 +01:00
|
|
|
case WM_NCCREATE:
|
2003-12-30 22:54:54 +01:00
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
|
2009-02-05 09:53:39 +01:00
|
|
|
MDICREATESTRUCTA *mdi_cs = cs->lpCreateParams;
|
2003-12-30 22:54:54 +01:00
|
|
|
|
|
|
|
ok(cs->dwExStyle & WS_EX_MDICHILD, "WS_EX_MDICHILD should be set\n");
|
|
|
|
ok(mdi_cs->lParam == (LPARAM)mdi_lParam_test_message, "wrong mdi_cs->lParam\n");
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_1"), "wrong class name\n");
|
|
|
|
ok(!lstrcmpA(cs->lpszClass, mdi_cs->szClass), "class name does not match\n");
|
|
|
|
ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
|
|
|
|
ok(!lstrcmpA(cs->lpszName, mdi_cs->szTitle), "title does not match\n");
|
|
|
|
ok(cs->hInstance == mdi_cs->hOwner, "%p != %p\n", cs->hInstance, mdi_cs->hOwner);
|
|
|
|
|
|
|
|
/* MDICREATESTRUCT should have original values */
|
|
|
|
ok(mdi_cs->style == 0 || mdi_cs->style == 0x7fffffff || mdi_cs->style == 0xffffffff,
|
2006-10-07 21:45:11 +02:00
|
|
|
"mdi_cs->style does not match (%08x)\n", mdi_cs->style);
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(mdi_cs->x == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->x);
|
|
|
|
ok(mdi_cs->y == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->y);
|
|
|
|
ok(mdi_cs->cx == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cx);
|
|
|
|
ok(mdi_cs->cy == CW_USEDEFAULT, "%d != CW_USEDEFAULT\n", mdi_cs->cy);
|
|
|
|
|
|
|
|
/* CREATESTRUCT should have fixed values */
|
|
|
|
ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);
|
|
|
|
ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
|
|
|
|
|
|
|
|
/* cx/cy == CW_USEDEFAULT are translated to NOT zero values */
|
|
|
|
ok(cs->cx != CW_USEDEFAULT && cs->cx != 0, "%d == CW_USEDEFAULT\n", cs->cx);
|
|
|
|
ok(cs->cy != CW_USEDEFAULT && cs->cy != 0, "%d == CW_USEDEFAULT\n", cs->cy);
|
|
|
|
|
|
|
|
ok(!(cs->style & WS_POPUP), "WS_POPUP is not allowed\n");
|
|
|
|
|
|
|
|
if (GetWindowLongA(cs->hwndParent, GWL_STYLE) & MDIS_ALLCHILDSTYLES)
|
|
|
|
{
|
2004-04-13 00:05:53 +02:00
|
|
|
LONG style = mdi_cs->style | WS_CHILD | WS_CLIPSIBLINGS;
|
|
|
|
ok(cs->style == style,
|
2006-10-07 21:45:11 +02:00
|
|
|
"cs->style does not match (%08x)\n", cs->style);
|
2004-01-20 05:29:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-04-13 00:05:53 +02:00
|
|
|
LONG style = mdi_cs->style;
|
2004-01-20 05:29:20 +01:00
|
|
|
style &= ~WS_POPUP;
|
|
|
|
style |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CAPTION |
|
|
|
|
WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;
|
|
|
|
ok(cs->style == style,
|
2006-10-07 21:45:11 +02:00
|
|
|
"cs->style does not match (%08x)\n", cs->style);
|
2004-01-20 05:29:20 +01:00
|
|
|
}
|
2003-12-30 22:54:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2004-05-07 02:41:32 +02:00
|
|
|
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
HWND client = GetParent(hwnd);
|
|
|
|
RECT rc;
|
|
|
|
MINMAXINFO *minmax = (MINMAXINFO *)lparam;
|
|
|
|
MINMAXINFO my_minmax;
|
|
|
|
LONG style, exstyle;
|
|
|
|
|
|
|
|
style = GetWindowLongA(hwnd, GWL_STYLE);
|
|
|
|
exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
|
|
|
|
|
|
|
GetWindowRect(client, &rc);
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("MDI client %p window size = (%d x %d)\n", client, rc.right-rc.left, rc.bottom-rc.top);
|
2004-05-07 02:41:32 +02:00
|
|
|
GetClientRect(client, &rc);
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("MDI client %p client size = (%d x %d)\n", client, rc.right, rc.bottom);
|
2004-05-07 02:41:32 +02:00
|
|
|
trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN),
|
|
|
|
GetSystemMetrics(SM_CYSCREEN));
|
|
|
|
|
|
|
|
GetClientRect(client, &rc);
|
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION)
|
|
|
|
style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
|
|
|
|
AdjustWindowRectEx(&rc, style, 0, exstyle);
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("MDI child: calculated max window size = (%d x %d)\n", rc.right-rc.left, rc.bottom-rc.top);
|
2008-06-04 12:34:53 +02:00
|
|
|
dump_minmax_info( minmax );
|
2004-05-07 02:41:32 +02:00
|
|
|
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %d != %d\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
minmax->ptMaxSize.x, rc.right - rc.left);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %d != %d\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
minmax->ptMaxSize.y, rc.bottom - rc.top);
|
|
|
|
|
|
|
|
DefMDIChildProcA(hwnd, msg, wparam, lparam);
|
|
|
|
|
2008-06-04 12:34:53 +02:00
|
|
|
trace("DefMDIChildProc returned:\n");
|
|
|
|
dump_minmax_info( minmax );
|
2004-05-07 02:41:32 +02:00
|
|
|
|
|
|
|
MDI_ChildGetMinMaxInfo(client, hwnd, &my_minmax);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(minmax->ptMaxSize.x == my_minmax.ptMaxSize.x, "default width of maximized child %d != %d\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
minmax->ptMaxSize.x, my_minmax.ptMaxSize.x);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(minmax->ptMaxSize.y == my_minmax.ptMaxSize.y, "default height of maximized child %d != %d\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
minmax->ptMaxSize.y, my_minmax.ptMaxSize.y);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2004-10-11 21:55:28 +02:00
|
|
|
|
|
|
|
case WM_MDIACTIVATE:
|
|
|
|
{
|
|
|
|
HWND active, client = GetParent(hwnd);
|
|
|
|
/*trace("%p WM_MDIACTIVATE %08x %08lx\n", hwnd, wparam, lparam);*/
|
|
|
|
active = (HWND)SendMessageA(client, WM_MDIGETACTIVE, 0, 0);
|
|
|
|
if (hwnd == (HWND)lparam) /* if we are being activated */
|
|
|
|
ok (active == (HWND)lparam, "new active %p != active %p\n", (HWND)lparam, active);
|
|
|
|
else
|
|
|
|
ok (active == (HWND)wparam, "old active %p != active %p\n", (HWND)wparam, active);
|
|
|
|
break;
|
|
|
|
}
|
2003-12-30 22:54:54 +01:00
|
|
|
}
|
|
|
|
return DefMDIChildProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI mdi_child_wnd_proc_2(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
2004-01-20 05:29:20 +01:00
|
|
|
case WM_NCCREATE:
|
2003-12-30 22:54:54 +01:00
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
CREATESTRUCTA *cs = (CREATESTRUCTA *)lparam;
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("%s: x %d, y %d, cx %d, cy %d\n", (msg == WM_NCCREATE) ? "WM_NCCREATE" : "WM_CREATE",
|
|
|
|
cs->x, cs->y, cs->cx, cs->cy);
|
2004-05-07 02:41:32 +02:00
|
|
|
|
2003-12-30 22:54:54 +01:00
|
|
|
ok(!(cs->dwExStyle & WS_EX_MDICHILD), "WS_EX_MDICHILD should not be set\n");
|
|
|
|
ok(cs->lpCreateParams == mdi_lParam_test_message, "wrong cs->lpCreateParams\n");
|
2004-01-20 05:29:20 +01:00
|
|
|
|
|
|
|
ok(!lstrcmpA(cs->lpszClass, "MDI_child_Class_2"), "wrong class name\n");
|
|
|
|
ok(!lstrcmpA(cs->lpszName, "MDI child"), "wrong title\n");
|
|
|
|
|
|
|
|
/* CREATESTRUCT should have fixed values */
|
|
|
|
/* For some reason Win9x doesn't translate cs->x from CW_USEDEFAULT,
|
|
|
|
while NT does. */
|
|
|
|
/*ok(cs->x != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->x);*/
|
|
|
|
ok(cs->y != CW_USEDEFAULT, "%d == CW_USEDEFAULT\n", cs->y);
|
|
|
|
|
|
|
|
/* cx/cy == CW_USEDEFAULT are translated to 0 */
|
2004-06-18 01:00:40 +02:00
|
|
|
/* For some reason Win98 doesn't translate cs->cx from CW_USEDEFAULT,
|
|
|
|
while Win95, Win2k, WinXP do. */
|
|
|
|
/*ok(cs->cx == 0, "%d != 0\n", cs->cx);*/
|
2004-01-20 05:29:20 +01:00
|
|
|
ok(cs->cy == 0, "%d != 0\n", cs->cy);
|
2003-12-30 22:54:54 +01:00
|
|
|
break;
|
|
|
|
}
|
2004-05-07 02:41:32 +02:00
|
|
|
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
HWND parent = GetParent(hwnd);
|
|
|
|
RECT rc;
|
|
|
|
MINMAXINFO *minmax = (MINMAXINFO *)lparam;
|
|
|
|
LONG style, exstyle;
|
|
|
|
|
|
|
|
style = GetWindowLongA(hwnd, GWL_STYLE);
|
|
|
|
exstyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
|
|
|
|
|
|
|
|
GetClientRect(parent, &rc);
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("WM_GETMINMAXINFO: parent %p client size = (%d x %d)\n", parent, rc.right, rc.bottom);
|
2004-05-07 02:41:32 +02:00
|
|
|
|
|
|
|
GetClientRect(parent, &rc);
|
|
|
|
if ((style & WS_CAPTION) == WS_CAPTION)
|
|
|
|
style &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
|
|
|
|
AdjustWindowRectEx(&rc, style, 0, exstyle);
|
2008-06-04 12:34:53 +02:00
|
|
|
dump_minmax_info( minmax );
|
2004-05-07 02:41:32 +02:00
|
|
|
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %d != %d\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
minmax->ptMaxSize.x, rc.right - rc.left);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %d != %d\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
minmax->ptMaxSize.y, rc.bottom - rc.top);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_WINDOWPOSCHANGED:
|
2004-06-15 20:27:06 +02:00
|
|
|
{
|
|
|
|
WINDOWPOS *winpos = (WINDOWPOS *)lparam;
|
|
|
|
RECT rc1, rc2;
|
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rc1);
|
|
|
|
SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
|
|
|
|
/* note: winpos coordinates are relative to parent */
|
|
|
|
MapWindowPoints(GetParent(hwnd), 0, (LPPOINT)&rc2, 2);
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match, window=(%d,%d)-(%d,%d) pos=(%d,%d)-(%d,%d)\n",
|
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom,
|
|
|
|
rc2.left, rc2.top, rc2.right, rc2.bottom);
|
2004-06-15 20:27:06 +02:00
|
|
|
GetWindowRect(hwnd, &rc1);
|
|
|
|
GetClientRect(hwnd, &rc2);
|
|
|
|
DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc1);
|
|
|
|
MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match, window=(%d,%d)-(%d,%d) client=(%d,%d)-(%d,%d)\n",
|
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom,
|
|
|
|
rc2.left, rc2.top, rc2.right, rc2.bottom);
|
2004-06-15 20:27:06 +02:00
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
case WM_WINDOWPOSCHANGING:
|
2004-05-07 02:41:32 +02:00
|
|
|
{
|
|
|
|
WINDOWPOS *winpos = (WINDOWPOS *)lparam;
|
|
|
|
WINDOWPOS my_winpos = *winpos;
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("%s: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
|
|
|
|
(msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED",
|
2004-05-07 02:41:32 +02:00
|
|
|
winpos->hwnd, winpos->hwndInsertAfter,
|
|
|
|
winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
|
|
|
|
|
|
|
|
DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
|
2009-01-25 17:29:32 +01:00
|
|
|
ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
|
|
|
|
"DefWindowProc should not change WINDOWPOS: %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
|
2004-05-07 02:41:32 +02:00
|
|
|
winpos->hwnd, winpos->hwndInsertAfter,
|
|
|
|
winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2003-12-30 22:54:54 +01:00
|
|
|
}
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI mdi_main_wnd_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
static HWND mdi_client;
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
CLIENTCREATESTRUCT client_cs;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
|
|
|
|
client_cs.hWindowMenu = 0;
|
|
|
|
client_cs.idFirstChild = 1;
|
|
|
|
|
2004-01-20 05:29:20 +01:00
|
|
|
/* MDIClient without MDIS_ALLCHILDSTYLES */
|
2003-12-30 22:54:54 +01:00
|
|
|
mdi_client = CreateWindowExA(0, "mdiclient",
|
|
|
|
NULL,
|
2004-01-20 05:29:20 +01:00
|
|
|
WS_CHILD /*| WS_VISIBLE*/,
|
|
|
|
/* tests depend on a not zero MDIClient size */
|
2003-12-30 22:54:54 +01:00
|
|
|
0, 0, rc.right, rc.bottom,
|
|
|
|
hwnd, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
&client_cs);
|
2003-12-30 22:54:54 +01:00
|
|
|
assert(mdi_client);
|
2005-02-02 10:33:58 +01:00
|
|
|
test_MDI_create(hwnd, mdi_client, client_cs.idFirstChild);
|
2004-01-20 05:29:20 +01:00
|
|
|
DestroyWindow(mdi_client);
|
2003-12-30 22:54:54 +01:00
|
|
|
|
2004-01-20 05:29:20 +01:00
|
|
|
/* MDIClient with MDIS_ALLCHILDSTYLES */
|
|
|
|
mdi_client = CreateWindowExA(0, "mdiclient",
|
|
|
|
NULL,
|
|
|
|
WS_CHILD | MDIS_ALLCHILDSTYLES /*| WS_VISIBLE*/,
|
|
|
|
/* tests depend on a not zero MDIClient size */
|
|
|
|
0, 0, rc.right, rc.bottom,
|
|
|
|
hwnd, 0, GetModuleHandle(0),
|
2009-02-05 09:53:39 +01:00
|
|
|
&client_cs);
|
2004-01-20 05:29:20 +01:00
|
|
|
assert(mdi_client);
|
2005-02-02 10:33:58 +01:00
|
|
|
test_MDI_create(hwnd, mdi_client, client_cs.idFirstChild);
|
2004-01-20 05:29:20 +01:00
|
|
|
DestroyWindow(mdi_client);
|
2003-12-30 22:54:54 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-06-15 20:27:06 +02:00
|
|
|
case WM_WINDOWPOSCHANGED:
|
|
|
|
{
|
|
|
|
WINDOWPOS *winpos = (WINDOWPOS *)lparam;
|
|
|
|
RECT rc1, rc2;
|
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rc1);
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("window: (%d,%d)-(%d,%d)\n", rc1.left, rc1.top, rc1.right, rc1.bottom);
|
2004-06-15 20:27:06 +02:00
|
|
|
SetRect(&rc2, winpos->x, winpos->y, winpos->x + winpos->cx, winpos->y + winpos->cy);
|
|
|
|
/* note: winpos coordinates are relative to parent */
|
|
|
|
MapWindowPoints(GetParent(hwnd), 0, (LPPOINT)&rc2, 2);
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("pos: (%d,%d)-(%d,%d)\n", rc2.left, rc2.top, rc2.right, rc2.bottom);
|
2004-06-15 20:27:06 +02:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match\n");
|
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rc1);
|
|
|
|
GetClientRect(hwnd, &rc2);
|
|
|
|
DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rc1);
|
|
|
|
MapWindowPoints(0, hwnd, (LPPOINT)&rc1, 2);
|
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match\n");
|
|
|
|
}
|
|
|
|
/* fall through */
|
|
|
|
case WM_WINDOWPOSCHANGING:
|
|
|
|
{
|
|
|
|
WINDOWPOS *winpos = (WINDOWPOS *)lparam;
|
|
|
|
WINDOWPOS my_winpos = *winpos;
|
|
|
|
|
|
|
|
trace("%s\n", (msg == WM_WINDOWPOSCHANGING) ? "WM_WINDOWPOSCHANGING" : "WM_WINDOWPOSCHANGED");
|
|
|
|
trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
|
|
|
|
winpos->hwnd, winpos->hwndInsertAfter,
|
|
|
|
winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
|
|
|
|
|
|
|
|
DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
|
|
|
|
trace("%p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
|
|
|
|
winpos->hwnd, winpos->hwndInsertAfter,
|
|
|
|
winpos->x, winpos->y, winpos->cx, winpos->cy, winpos->flags);
|
|
|
|
|
|
|
|
ok(!memcmp(&my_winpos, winpos, sizeof(WINDOWPOS)),
|
|
|
|
"DefWindowProc should not change WINDOWPOS values\n");
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-12-30 22:54:54 +01:00
|
|
|
case WM_CLOSE:
|
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return DefFrameProcA(hwnd, mdi_client, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL mdi_RegisterWindowClasses(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA cls;
|
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = mdi_main_wnd_procA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2003-12-30 22:54:54 +01:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "MDI_parent_Class";
|
|
|
|
if(!RegisterClassA(&cls)) return FALSE;
|
|
|
|
|
|
|
|
cls.lpfnWndProc = mdi_child_wnd_proc_1;
|
|
|
|
cls.lpszClassName = "MDI_child_Class_1";
|
|
|
|
if(!RegisterClassA(&cls)) return FALSE;
|
|
|
|
|
|
|
|
cls.lpfnWndProc = mdi_child_wnd_proc_2;
|
|
|
|
cls.lpszClassName = "MDI_child_Class_2";
|
|
|
|
if(!RegisterClassA(&cls)) return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_mdi(void)
|
|
|
|
{
|
|
|
|
HWND mdi_hwndMain;
|
|
|
|
/*MSG msg;*/
|
|
|
|
|
|
|
|
if (!mdi_RegisterWindowClasses()) assert(0);
|
|
|
|
|
|
|
|
mdi_hwndMain = CreateWindowExA(0, "MDI_parent_Class", "MDI parent window",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
|
|
|
|
WS_MAXIMIZEBOX /*| WS_VISIBLE*/,
|
|
|
|
100, 100, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
GetDesktopWindow(), 0,
|
|
|
|
GetModuleHandle(0), NULL);
|
|
|
|
assert(mdi_hwndMain);
|
|
|
|
/*
|
|
|
|
while(GetMessage(&msg, 0, 0, 0))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
*/
|
2008-02-19 13:17:13 +01:00
|
|
|
DestroyWindow(mdi_hwndMain);
|
2003-12-30 22:54:54 +01:00
|
|
|
}
|
2003-11-18 01:13:34 +01:00
|
|
|
|
2004-01-01 00:51:52 +01:00
|
|
|
static void test_icons(void)
|
|
|
|
{
|
|
|
|
WNDCLASSEXA cls;
|
|
|
|
HWND hwnd;
|
2009-01-13 10:55:46 +01:00
|
|
|
HICON icon = LoadIconA(0, IDI_APPLICATION);
|
|
|
|
HICON icon2 = LoadIconA(0, IDI_QUESTION);
|
|
|
|
HICON small_icon = LoadImageA(0, IDI_APPLICATION, IMAGE_ICON,
|
2004-01-01 00:51:52 +01:00
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED );
|
|
|
|
HICON res;
|
|
|
|
|
|
|
|
cls.cbSize = sizeof(cls);
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = DefWindowProcA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hIcon = LoadIconA(0, IDI_HAND);
|
2004-01-01 00:51:52 +01:00
|
|
|
cls.hIconSm = small_icon;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2004-01-01 00:51:52 +01:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "IconWindowClass";
|
|
|
|
|
|
|
|
RegisterClassExA(&cls);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "IconWindowClass", "icon test", 0,
|
|
|
|
100, 100, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL);
|
|
|
|
assert( hwnd );
|
|
|
|
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
|
|
|
|
ok( res == 0, "wrong big icon %p/0\n", res );
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon );
|
|
|
|
ok( res == 0, "wrong previous big icon %p/0\n", res );
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
|
|
|
|
ok( res == icon, "wrong big icon after set %p/%p\n", res, icon );
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon2 );
|
|
|
|
ok( res == icon, "wrong previous big icon %p/%p\n", res, icon );
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
|
|
|
|
ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
|
|
|
|
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
|
|
|
|
ok( res == 0, "wrong small icon %p/0\n", res );
|
2004-01-20 05:29:20 +01:00
|
|
|
/* this test is XP specific */
|
|
|
|
/*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
|
|
|
|
ok( res != 0, "wrong small icon %p\n", res );*/
|
2004-01-01 00:51:52 +01:00
|
|
|
res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)icon );
|
|
|
|
ok( res == 0, "wrong previous small icon %p/0\n", res );
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
|
|
|
|
ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );
|
2004-01-20 05:29:20 +01:00
|
|
|
/* this test is XP specific */
|
|
|
|
/*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
|
|
|
|
ok( res == icon, "wrong small icon after set %p/%p\n", res, icon );*/
|
2004-01-01 00:51:52 +01:00
|
|
|
res = (HICON)SendMessageA( hwnd, WM_SETICON, ICON_SMALL, (LPARAM)small_icon );
|
|
|
|
ok( res == icon, "wrong previous small icon %p/%p\n", res, icon );
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL, 0 );
|
|
|
|
ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );
|
2004-01-20 05:29:20 +01:00
|
|
|
/* this test is XP specific */
|
|
|
|
/*res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_SMALL2, 0 );
|
|
|
|
ok( res == small_icon, "wrong small icon after set %p/%p\n", res, small_icon );*/
|
2004-01-01 00:51:52 +01:00
|
|
|
|
|
|
|
/* make sure the big icon hasn't changed */
|
|
|
|
res = (HICON)SendMessageA( hwnd, WM_GETICON, ICON_BIG, 0 );
|
|
|
|
ok( res == icon2, "wrong big icon after set %p/%p\n", res, icon2 );
|
2008-02-19 13:17:13 +01:00
|
|
|
|
|
|
|
DestroyWindow( hwnd );
|
2004-01-01 00:51:52 +01:00
|
|
|
}
|
|
|
|
|
2005-02-22 20:41:43 +01:00
|
|
|
static LRESULT WINAPI nccalcsize_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
if (msg == WM_NCCALCSIZE)
|
|
|
|
{
|
|
|
|
RECT *rect = (RECT *)lparam;
|
|
|
|
/* first time around increase the rectangle, next time decrease it */
|
|
|
|
if (rect->left == 100) InflateRect( rect, 10, 10 );
|
|
|
|
else InflateRect( rect, -10, -10 );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc( hwnd, msg, wparam, lparam );
|
|
|
|
}
|
|
|
|
|
2004-03-11 04:51:46 +01:00
|
|
|
static void test_SetWindowPos(HWND hwnd)
|
|
|
|
{
|
2005-02-22 20:41:43 +01:00
|
|
|
RECT orig_win_rc, rect;
|
|
|
|
LONG_PTR old_proc;
|
2005-02-24 18:03:01 +01:00
|
|
|
BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
|
|
|
|
|
|
|
|
SetRect(&rect, 111, 222, 333, 444);
|
|
|
|
ok(!GetWindowRect(0, &rect), "GetWindowRect succeeded\n");
|
|
|
|
ok(rect.left == 111 && rect.top == 222 && rect.right == 333 && rect.bottom == 444,
|
2006-10-07 21:45:11 +02:00
|
|
|
"wrong window rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
2005-02-24 18:03:01 +01:00
|
|
|
|
|
|
|
SetRect(&rect, 111, 222, 333, 444);
|
|
|
|
ok(!GetClientRect(0, &rect), "GetClientRect succeeded\n");
|
|
|
|
ok(rect.left == 111 && rect.top == 222 && rect.right == 333 && rect.bottom == 444,
|
2006-10-07 21:45:11 +02:00
|
|
|
"wrong window rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
2004-06-15 20:27:06 +02:00
|
|
|
|
2004-09-16 21:09:44 +02:00
|
|
|
GetWindowRect(hwnd, &orig_win_rc);
|
|
|
|
|
2005-02-22 20:41:43 +01:00
|
|
|
old_proc = SetWindowLongPtr( hwnd, GWLP_WNDPROC, (ULONG_PTR)nccalcsize_proc );
|
|
|
|
SetWindowPos(hwnd, 0, 100, 100, 0, 0, SWP_NOZORDER|SWP_FRAMECHANGED);
|
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
ok( rect.left == 100 && rect.top == 100 && rect.right == 100 && rect.bottom == 100,
|
2006-10-07 21:45:11 +02:00
|
|
|
"invalid window rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
2005-02-22 20:41:43 +01:00
|
|
|
GetClientRect( hwnd, &rect );
|
|
|
|
MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 );
|
|
|
|
ok( rect.left == 90 && rect.top == 90 && rect.right == 110 && rect.bottom == 110,
|
2006-10-07 21:45:11 +02:00
|
|
|
"invalid client rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
2005-02-22 20:41:43 +01:00
|
|
|
|
|
|
|
SetWindowPos(hwnd, 0, 200, 200, 0, 0, SWP_NOZORDER|SWP_FRAMECHANGED);
|
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
ok( rect.left == 200 && rect.top == 200 && rect.right == 200 && rect.bottom == 200,
|
2006-10-07 21:45:11 +02:00
|
|
|
"invalid window rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
2005-02-22 20:41:43 +01:00
|
|
|
GetClientRect( hwnd, &rect );
|
|
|
|
MapWindowPoints( hwnd, 0, (POINT *)&rect, 2 );
|
|
|
|
ok( rect.left == 210 && rect.top == 210 && rect.right == 190 && rect.bottom == 190,
|
2006-10-07 21:45:11 +02:00
|
|
|
"invalid client rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
2004-03-11 04:51:46 +01:00
|
|
|
|
2005-02-22 20:41:43 +01:00
|
|
|
SetWindowPos(hwnd, 0, orig_win_rc.left, orig_win_rc.top,
|
|
|
|
orig_win_rc.right, orig_win_rc.bottom, 0);
|
|
|
|
SetWindowLongPtr( hwnd, GWLP_WNDPROC, old_proc );
|
|
|
|
|
|
|
|
/* Win9x truncates coordinates to 16-bit irrespectively */
|
|
|
|
if (!is_win9x)
|
|
|
|
{
|
|
|
|
SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOMOVE);
|
|
|
|
SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOMOVE);
|
|
|
|
|
|
|
|
SetWindowPos(hwnd, 0, -32769, -40000, -32769, -90000, SWP_NOSIZE);
|
|
|
|
SetWindowPos(hwnd, 0, 32768, 40000, 32768, 40000, SWP_NOSIZE);
|
|
|
|
}
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
SetWindowPos(hwnd, 0, orig_win_rc.left, orig_win_rc.top,
|
|
|
|
orig_win_rc.right, orig_win_rc.bottom, 0);
|
2008-02-07 16:03:39 +01:00
|
|
|
|
|
|
|
ok(!(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n");
|
|
|
|
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
ok(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n");
|
|
|
|
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
ok(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST, "WS_EX_TOPMOST should be set\n");
|
|
|
|
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
ok(!(GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST), "WS_EX_TOPMOST should not be set\n");
|
2004-03-11 04:51:46 +01:00
|
|
|
}
|
|
|
|
|
2004-03-19 20:14:45 +01:00
|
|
|
static void test_SetMenu(HWND parent)
|
|
|
|
{
|
|
|
|
HWND child;
|
|
|
|
HMENU hMenu, ret;
|
2005-02-24 18:03:01 +01:00
|
|
|
BOOL is_win9x = GetWindowLongPtrW(parent, GWLP_WNDPROC) == 0;
|
2004-12-27 18:26:37 +01:00
|
|
|
BOOL retok;
|
2005-03-25 21:47:32 +01:00
|
|
|
DWORD style;
|
2004-03-19 20:14:45 +01:00
|
|
|
|
|
|
|
hMenu = CreateMenu();
|
|
|
|
assert(hMenu);
|
|
|
|
|
2004-06-01 21:46:23 +02:00
|
|
|
ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
|
2006-12-14 18:10:47 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2005-05-24 11:51:20 +02:00
|
|
|
/* fails on (at least) Wine, NT4, XP SP2 */
|
|
|
|
test_nonclient_area(parent);
|
2006-12-14 18:10:47 +01:00
|
|
|
}
|
2004-06-01 21:46:23 +02:00
|
|
|
ret = GetMenu(parent);
|
2004-06-15 20:27:06 +02:00
|
|
|
ok(ret == hMenu, "unexpected menu id %p\n", ret);
|
2004-06-01 21:46:23 +02:00
|
|
|
/* test whether we can destroy a menu assigned to a window */
|
2004-12-27 18:26:37 +01:00
|
|
|
retok = DestroyMenu(hMenu);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( retok, "DestroyMenu error %d\n", GetLastError());
|
2008-11-20 11:57:32 +01:00
|
|
|
retok = IsMenu(hMenu);
|
|
|
|
ok(!retok || broken(retok) /* nt4 */, "menu handle should be not valid after DestroyMenu\n");
|
2004-06-01 21:46:23 +02:00
|
|
|
ret = GetMenu(parent);
|
2004-06-15 20:27:06 +02:00
|
|
|
/* This test fails on Win9x */
|
|
|
|
if (!is_win9x)
|
|
|
|
ok(ret == hMenu, "unexpected menu id %p\n", ret);
|
2004-06-01 21:46:23 +02:00
|
|
|
ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
|
2004-06-15 20:27:06 +02:00
|
|
|
test_nonclient_area(parent);
|
2004-06-01 21:46:23 +02:00
|
|
|
|
|
|
|
hMenu = CreateMenu();
|
|
|
|
assert(hMenu);
|
|
|
|
|
2004-03-19 20:14:45 +01:00
|
|
|
/* parent */
|
|
|
|
ret = GetMenu(parent);
|
|
|
|
ok(ret == 0, "unexpected menu id %p\n", ret);
|
|
|
|
|
|
|
|
ok(!SetMenu(parent, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
|
2004-06-15 20:27:06 +02:00
|
|
|
test_nonclient_area(parent);
|
2004-03-19 20:14:45 +01:00
|
|
|
ret = GetMenu(parent);
|
|
|
|
ok(ret == 0, "unexpected menu id %p\n", ret);
|
|
|
|
|
|
|
|
ok(SetMenu(parent, hMenu), "SetMenu on a top level window should not fail\n");
|
2006-12-14 18:10:47 +01:00
|
|
|
if (0)
|
|
|
|
{
|
2005-05-24 11:51:20 +02:00
|
|
|
/* fails on (at least) Wine, NT4, XP SP2 */
|
2004-06-15 20:27:06 +02:00
|
|
|
test_nonclient_area(parent);
|
2006-12-14 18:10:47 +01:00
|
|
|
}
|
2004-03-19 20:14:45 +01:00
|
|
|
ret = GetMenu(parent);
|
2004-06-15 20:27:06 +02:00
|
|
|
ok(ret == hMenu, "unexpected menu id %p\n", ret);
|
2004-03-19 20:14:45 +01:00
|
|
|
|
|
|
|
ok(SetMenu(parent, 0), "SetMenu(0) on a top level window should not fail\n");
|
2004-06-15 20:27:06 +02:00
|
|
|
test_nonclient_area(parent);
|
2004-03-19 20:14:45 +01:00
|
|
|
ret = GetMenu(parent);
|
|
|
|
ok(ret == 0, "unexpected menu id %p\n", ret);
|
|
|
|
|
|
|
|
/* child */
|
|
|
|
child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, parent, (HMENU)10, 0, NULL);
|
|
|
|
assert(child);
|
|
|
|
|
|
|
|
ret = GetMenu(child);
|
|
|
|
ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
|
|
|
|
|
|
|
|
ok(!SetMenu(child, (HMENU)20), "SetMenu with invalid menu handle should fail\n");
|
2004-06-15 20:27:06 +02:00
|
|
|
test_nonclient_area(child);
|
2004-03-19 20:14:45 +01:00
|
|
|
ret = GetMenu(child);
|
|
|
|
ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
|
|
|
|
|
|
|
|
ok(!SetMenu(child, hMenu), "SetMenu on a child window should fail\n");
|
2004-06-15 20:27:06 +02:00
|
|
|
test_nonclient_area(child);
|
2004-03-19 20:14:45 +01:00
|
|
|
ret = GetMenu(child);
|
|
|
|
ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
|
|
|
|
|
|
|
|
ok(!SetMenu(child, 0), "SetMenu(0) on a child window should fail\n");
|
2004-06-15 20:27:06 +02:00
|
|
|
test_nonclient_area(child);
|
2004-03-19 20:14:45 +01:00
|
|
|
ret = GetMenu(child);
|
|
|
|
ok(ret == (HMENU)10, "unexpected menu id %p\n", ret);
|
|
|
|
|
2005-03-25 21:47:32 +01:00
|
|
|
style = GetWindowLong(child, GWL_STYLE);
|
|
|
|
SetWindowLong(child, GWL_STYLE, style | WS_POPUP);
|
|
|
|
ok(SetMenu(child, hMenu), "SetMenu on a popup child window should not fail\n");
|
|
|
|
ok(SetMenu(child, 0), "SetMenu on a popup child window should not fail\n");
|
|
|
|
SetWindowLong(child, GWL_STYLE, style);
|
|
|
|
|
|
|
|
SetWindowLong(child, GWL_STYLE, style | WS_OVERLAPPED);
|
|
|
|
ok(!SetMenu(child, hMenu), "SetMenu on a overlapped child window should fail\n");
|
|
|
|
SetWindowLong(child, GWL_STYLE, style);
|
|
|
|
|
2004-03-19 20:14:45 +01:00
|
|
|
DestroyWindow(child);
|
|
|
|
DestroyMenu(hMenu);
|
|
|
|
}
|
|
|
|
|
2004-04-13 00:05:53 +02:00
|
|
|
static void test_window_tree(HWND parent, const DWORD *style, const int *order, int total)
|
|
|
|
{
|
|
|
|
HWND child[5], hwnd;
|
2009-01-08 13:18:01 +01:00
|
|
|
INT_PTR i;
|
2004-04-13 00:05:53 +02:00
|
|
|
|
|
|
|
assert(total <= 5);
|
|
|
|
|
|
|
|
hwnd = GetWindow(parent, GW_CHILD);
|
|
|
|
ok(!hwnd, "have to start without children to perform the test\n");
|
|
|
|
|
|
|
|
for (i = 0; i < total; i++)
|
|
|
|
{
|
2005-11-18 13:07:19 +01:00
|
|
|
if (style[i] & DS_CONTROL)
|
|
|
|
{
|
2006-11-08 01:19:02 +01:00
|
|
|
child[i] = CreateWindowExA(0, MAKEINTATOM(32770), "", style[i] & ~WS_VISIBLE,
|
2005-11-18 13:07:19 +01:00
|
|
|
0,0,0,0, parent, (HMENU)i, 0, NULL);
|
|
|
|
if (style[i] & WS_VISIBLE)
|
|
|
|
ShowWindow(child[i], SW_SHOW);
|
|
|
|
|
|
|
|
SetWindowPos(child[i], HWND_BOTTOM, 0,0,10,10, SWP_NOACTIVATE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
child[i] = CreateWindowExA(0, "static", "", style[i], 0,0,10,10,
|
|
|
|
parent, (HMENU)i, 0, NULL);
|
2009-01-08 13:18:01 +01:00
|
|
|
trace("child[%ld] = %p\n", i, child[i]);
|
2004-04-13 00:05:53 +02:00
|
|
|
ok(child[i] != 0, "CreateWindowEx failed to create child window\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
hwnd = GetWindow(parent, GW_CHILD);
|
|
|
|
ok(hwnd != 0, "GetWindow(GW_CHILD) failed\n");
|
|
|
|
ok(hwnd == GetWindow(child[total - 1], GW_HWNDFIRST), "GW_HWNDFIRST is wrong\n");
|
2004-04-13 23:15:51 +02:00
|
|
|
ok(child[order[total - 1]] == GetWindow(child[0], GW_HWNDLAST), "GW_HWNDLAST is wrong\n");
|
2004-04-13 00:05:53 +02:00
|
|
|
|
|
|
|
for (i = 0; i < total; i++)
|
|
|
|
{
|
2009-01-08 13:18:01 +01:00
|
|
|
trace("hwnd[%ld] = %p\n", i, hwnd);
|
|
|
|
ok(child[order[i]] == hwnd, "Z order of child #%ld is wrong\n", i);
|
2004-04-13 00:05:53 +02:00
|
|
|
|
|
|
|
hwnd = GetWindow(hwnd, GW_HWNDNEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < total; i++)
|
|
|
|
ok(DestroyWindow(child[i]), "DestroyWindow failed\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_children_zorder(HWND parent)
|
|
|
|
{
|
|
|
|
const DWORD simple_style[5] = { WS_CHILD, WS_CHILD, WS_CHILD, WS_CHILD,
|
|
|
|
WS_CHILD };
|
|
|
|
const int simple_order[5] = { 0, 1, 2, 3, 4 };
|
|
|
|
|
|
|
|
const DWORD complex_style[5] = { WS_CHILD, WS_CHILD | WS_MAXIMIZE,
|
|
|
|
WS_CHILD | WS_VISIBLE, WS_CHILD,
|
|
|
|
WS_CHILD | WS_MAXIMIZE | WS_VISIBLE };
|
|
|
|
const int complex_order_1[1] = { 0 };
|
|
|
|
const int complex_order_2[2] = { 1, 0 };
|
|
|
|
const int complex_order_3[3] = { 1, 0, 2 };
|
|
|
|
const int complex_order_4[4] = { 1, 0, 2, 3 };
|
|
|
|
const int complex_order_5[5] = { 4, 1, 0, 2, 3 };
|
2005-11-18 13:07:19 +01:00
|
|
|
const DWORD complex_style_6[3] = { WS_CHILD | WS_VISIBLE,
|
|
|
|
WS_CHILD | WS_CLIPSIBLINGS | DS_CONTROL | WS_VISIBLE,
|
|
|
|
WS_CHILD | WS_VISIBLE };
|
|
|
|
const int complex_order_6[3] = { 0, 1, 2 };
|
2004-04-13 00:05:53 +02:00
|
|
|
|
|
|
|
/* simple WS_CHILD */
|
|
|
|
test_window_tree(parent, simple_style, simple_order, 5);
|
|
|
|
|
|
|
|
/* complex children styles */
|
|
|
|
test_window_tree(parent, complex_style, complex_order_1, 1);
|
|
|
|
test_window_tree(parent, complex_style, complex_order_2, 2);
|
|
|
|
test_window_tree(parent, complex_style, complex_order_3, 3);
|
|
|
|
test_window_tree(parent, complex_style, complex_order_4, 4);
|
|
|
|
test_window_tree(parent, complex_style, complex_order_5, 5);
|
2005-11-18 13:07:19 +01:00
|
|
|
|
|
|
|
/* another set of complex children styles */
|
|
|
|
test_window_tree(parent, complex_style_6, complex_order_6, 3);
|
2004-04-13 00:05:53 +02:00
|
|
|
}
|
|
|
|
|
2008-02-19 13:17:13 +01:00
|
|
|
#define check_z_order(hwnd, next, prev, owner, topmost) \
|
|
|
|
check_z_order_debug((hwnd), (next), (prev), (owner), (topmost), \
|
|
|
|
__FILE__, __LINE__)
|
|
|
|
|
|
|
|
static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner,
|
|
|
|
BOOL topmost, const char *file, int line)
|
|
|
|
{
|
|
|
|
HWND test;
|
|
|
|
DWORD ex_style;
|
|
|
|
|
|
|
|
test = GetWindow(hwnd, GW_HWNDNEXT);
|
|
|
|
/* skip foreign windows */
|
2009-02-12 17:32:15 +01:00
|
|
|
while (test && test != next &&
|
|
|
|
(GetWindowThreadProcessId(test, NULL) != our_pid ||
|
|
|
|
UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)) != GetModuleHandle(0) ||
|
|
|
|
GetWindow(test, GW_OWNER) == next))
|
2008-02-19 13:17:13 +01:00
|
|
|
{
|
|
|
|
/*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
|
|
|
|
test = GetWindow(test, GW_HWNDNEXT);
|
|
|
|
}
|
|
|
|
ok_(file, line)(next == test, "expected next %p, got %p\n", next, test);
|
|
|
|
|
|
|
|
test = GetWindow(hwnd, GW_HWNDPREV);
|
|
|
|
/* skip foreign windows */
|
2009-02-12 17:32:15 +01:00
|
|
|
while (test && test != prev &&
|
|
|
|
(GetWindowThreadProcessId(test, NULL) != our_pid ||
|
|
|
|
UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)) != GetModuleHandle(0) ||
|
|
|
|
GetWindow(test, GW_OWNER) == hwnd))
|
2008-02-19 13:17:13 +01:00
|
|
|
{
|
|
|
|
/*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
|
|
|
|
test = GetWindow(test, GW_HWNDPREV);
|
|
|
|
}
|
|
|
|
ok_(file, line)(prev == test, "expected prev %p, got %p\n", prev, test);
|
|
|
|
|
|
|
|
test = GetWindow(hwnd, GW_OWNER);
|
|
|
|
ok_(file, line)(owner == test, "expected owner %p, got %p\n", owner, test);
|
|
|
|
|
|
|
|
ex_style = GetWindowLong(hwnd, GWL_EXSTYLE);
|
|
|
|
ok_(file, line)(!(ex_style & WS_EX_TOPMOST) == !topmost, "expected %stopmost\n", topmost ? "" : "NOT ");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E)
|
|
|
|
{
|
|
|
|
HWND hwnd_A, hwnd_B, hwnd_C, hwnd_F;
|
|
|
|
|
|
|
|
trace("hwnd_D %p, hwnd_E %p\n", hwnd_D, hwnd_E);
|
|
|
|
|
|
|
|
SetWindowPos(hwnd_E, hwnd_D, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
|
|
|
|
|
|
|
|
check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE);
|
|
|
|
check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
|
|
|
|
|
|
|
|
hwnd_F = CreateWindowEx(0, "MainWindowClass", "Owner window",
|
|
|
|
WS_OVERLAPPED | WS_CAPTION,
|
|
|
|
100, 100, 100, 100,
|
|
|
|
0, 0, GetModuleHandle(0), NULL);
|
|
|
|
trace("hwnd_F %p\n", hwnd_F);
|
|
|
|
check_z_order(hwnd_F, hwnd_D, 0, 0, FALSE);
|
|
|
|
|
|
|
|
SetWindowPos(hwnd_F, hwnd_E, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
|
|
|
|
check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
|
|
|
|
check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
|
|
|
|
check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE);
|
|
|
|
|
|
|
|
hwnd_C = CreateWindowEx(0, "MainWindowClass", NULL,
|
|
|
|
WS_POPUP,
|
|
|
|
100, 100, 100, 100,
|
|
|
|
hwnd_F, 0, GetModuleHandle(0), NULL);
|
|
|
|
trace("hwnd_C %p\n", hwnd_C);
|
|
|
|
check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
|
|
|
|
check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
|
|
|
|
check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
|
|
|
|
check_z_order(hwnd_C, hwnd_D, 0, hwnd_F, FALSE);
|
|
|
|
|
|
|
|
hwnd_B = CreateWindowEx(WS_EX_TOPMOST, "MainWindowClass", NULL,
|
|
|
|
WS_POPUP,
|
|
|
|
100, 100, 100, 100,
|
|
|
|
hwnd_F, 0, GetModuleHandle(0), NULL);
|
|
|
|
trace("hwnd_B %p\n", hwnd_B);
|
|
|
|
check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
|
|
|
|
check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
|
|
|
|
check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
|
|
|
|
check_z_order(hwnd_C, hwnd_D, hwnd_B, hwnd_F, FALSE);
|
|
|
|
check_z_order(hwnd_B, hwnd_C, 0, hwnd_F, TRUE);
|
|
|
|
|
|
|
|
hwnd_A = CreateWindowEx(WS_EX_TOPMOST, "MainWindowClass", NULL,
|
|
|
|
WS_POPUP,
|
|
|
|
100, 100, 100, 100,
|
|
|
|
0, 0, GetModuleHandle(0), NULL);
|
|
|
|
trace("hwnd_A %p\n", hwnd_A);
|
|
|
|
check_z_order(hwnd_F, 0, hwnd_E, 0, FALSE);
|
|
|
|
check_z_order(hwnd_E, hwnd_F, hwnd_D, 0, FALSE);
|
|
|
|
check_z_order(hwnd_D, hwnd_E, hwnd_C, 0, FALSE);
|
|
|
|
check_z_order(hwnd_C, hwnd_D, hwnd_B, hwnd_F, FALSE);
|
|
|
|
check_z_order(hwnd_B, hwnd_C, hwnd_A, hwnd_F, TRUE);
|
|
|
|
check_z_order(hwnd_A, hwnd_B, 0, 0, TRUE);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* move hwnd_F and its popups up */
|
|
|
|
SetWindowPos(hwnd_F, HWND_TOP, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
|
|
|
|
check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
|
|
|
|
check_z_order(hwnd_D, hwnd_E, hwnd_F, 0, FALSE);
|
|
|
|
check_z_order(hwnd_F, hwnd_D, hwnd_C, 0, FALSE);
|
|
|
|
check_z_order(hwnd_C, hwnd_F, hwnd_B, hwnd_F, FALSE);
|
|
|
|
check_z_order(hwnd_B, hwnd_C, hwnd_A, hwnd_F, TRUE);
|
|
|
|
check_z_order(hwnd_A, hwnd_B, 0, 0, TRUE);
|
|
|
|
|
|
|
|
/* move hwnd_F and its popups down */
|
|
|
|
#if 0 /* enable once Wine is fixed to pass this test */
|
|
|
|
SetWindowPos(hwnd_F, HWND_BOTTOM, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE);
|
|
|
|
check_z_order(hwnd_F, 0, hwnd_C, 0, FALSE);
|
|
|
|
check_z_order(hwnd_C, hwnd_F, hwnd_B, hwnd_F, FALSE);
|
|
|
|
check_z_order(hwnd_B, hwnd_C, hwnd_E, hwnd_F, FALSE);
|
|
|
|
check_z_order(hwnd_E, hwnd_B, hwnd_D, 0, FALSE);
|
|
|
|
check_z_order(hwnd_D, hwnd_E, hwnd_A, 0, FALSE);
|
|
|
|
check_z_order(hwnd_A, hwnd_D, 0, 0, TRUE);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DestroyWindow(hwnd_A);
|
|
|
|
DestroyWindow(hwnd_B);
|
|
|
|
DestroyWindow(hwnd_C);
|
|
|
|
DestroyWindow(hwnd_F);
|
|
|
|
}
|
|
|
|
|
2005-09-26 18:46:31 +02:00
|
|
|
static void test_vis_rgn( HWND hwnd )
|
|
|
|
{
|
|
|
|
RECT win_rect, rgn_rect;
|
|
|
|
HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
ShowWindow(hwnd,SW_SHOW);
|
|
|
|
hdc = GetDC( hwnd );
|
|
|
|
ok( GetRandomRgn( hdc, hrgn, SYSRGN ) != 0, "GetRandomRgn failed\n" );
|
|
|
|
GetWindowRect( hwnd, &win_rect );
|
|
|
|
GetRgnBox( hrgn, &rgn_rect );
|
|
|
|
if (GetVersion() & 0x80000000)
|
|
|
|
{
|
|
|
|
trace("win9x, mapping to screen coords\n");
|
|
|
|
MapWindowPoints( hwnd, 0, (POINT *)&rgn_rect, 2 );
|
|
|
|
}
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("win: %d,%d-%d,%d\n", win_rect.left, win_rect.top, win_rect.right, win_rect.bottom );
|
|
|
|
trace("rgn: %d,%d-%d,%d\n", rgn_rect.left, rgn_rect.top, rgn_rect.right, rgn_rect.bottom );
|
|
|
|
ok( win_rect.left <= rgn_rect.left, "rgn left %d not inside win rect %d\n",
|
2005-09-26 18:46:31 +02:00
|
|
|
rgn_rect.left, win_rect.left );
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( win_rect.top <= rgn_rect.top, "rgn top %d not inside win rect %d\n",
|
2005-09-26 18:46:31 +02:00
|
|
|
rgn_rect.top, win_rect.top );
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( win_rect.right >= rgn_rect.right, "rgn right %d not inside win rect %d\n",
|
2005-09-26 18:46:31 +02:00
|
|
|
rgn_rect.right, win_rect.right );
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( win_rect.bottom >= rgn_rect.bottom, "rgn bottom %d not inside win rect %d\n",
|
2005-09-26 18:46:31 +02:00
|
|
|
rgn_rect.bottom, win_rect.bottom );
|
|
|
|
ReleaseDC( hwnd, hdc );
|
|
|
|
}
|
|
|
|
|
2008-06-27 12:05:16 +02:00
|
|
|
static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
|
|
|
{
|
|
|
|
if (msg == WM_ACTIVATE && LOWORD(wp) == WA_ACTIVE)
|
|
|
|
{
|
|
|
|
HWND child = GetWindow(hwnd, GW_CHILD);
|
|
|
|
ok(child != 0, "couldn't find child window\n");
|
|
|
|
SetFocus(child);
|
|
|
|
ok(GetFocus() == child, "Focus should be on child %p\n", child);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
}
|
|
|
|
|
2004-04-28 05:52:27 +02:00
|
|
|
static void test_SetFocus(HWND hwnd)
|
|
|
|
{
|
2009-11-04 13:49:11 +01:00
|
|
|
HWND child, child2;
|
2008-06-27 12:05:16 +02:00
|
|
|
WNDPROC old_wnd_proc;
|
2004-04-28 05:52:27 +02:00
|
|
|
|
|
|
|
/* check if we can set focus to non-visible windows */
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
SetFocus(0);
|
|
|
|
SetFocus(hwnd);
|
|
|
|
ok( GetFocus() == hwnd, "Failed to set focus to visible window %p\n", hwnd );
|
|
|
|
ok( GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE, "Window %p not visible\n", hwnd );
|
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
SetFocus(0);
|
|
|
|
SetFocus(hwnd);
|
|
|
|
ok( GetFocus() == hwnd, "Failed to set focus to invisible window %p\n", hwnd );
|
|
|
|
ok( !(GetWindowLong(hwnd,GWL_STYLE) & WS_VISIBLE), "Window %p still visible\n", hwnd );
|
|
|
|
child = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, NULL);
|
|
|
|
assert(child);
|
|
|
|
SetFocus(child);
|
|
|
|
ok( GetFocus() == child, "Failed to set focus to invisible child %p\n", child );
|
|
|
|
ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
|
2004-05-04 06:18:29 +02:00
|
|
|
ShowWindow(child, SW_SHOW);
|
|
|
|
ok( GetWindowLong(child,GWL_STYLE) & WS_VISIBLE, "Child %p is not visible\n", child );
|
|
|
|
ok( GetFocus() == child, "Focus no longer on child %p\n", child );
|
|
|
|
ShowWindow(child, SW_HIDE);
|
|
|
|
ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
|
|
|
|
ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
|
|
|
|
ShowWindow(child, SW_SHOW);
|
2009-11-04 13:49:11 +01:00
|
|
|
child2 = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 0, 0, child, 0, 0, NULL);
|
|
|
|
assert(child2);
|
|
|
|
ShowWindow(child2, SW_SHOW);
|
|
|
|
SetFocus(child2);
|
|
|
|
ShowWindow(child, SW_HIDE);
|
|
|
|
ok( !(GetWindowLong(child,GWL_STYLE) & WS_VISIBLE), "Child %p is visible\n", child );
|
|
|
|
ok( GetFocus() == child2, "Focus should be on %p, not %p\n", child2, GetFocus() );
|
|
|
|
ShowWindow(child, SW_SHOW);
|
2004-05-04 06:18:29 +02:00
|
|
|
SetFocus(child);
|
|
|
|
ok( GetFocus() == child, "Focus should be on child %p\n", child );
|
|
|
|
SetWindowPos(child,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW);
|
|
|
|
ok( GetFocus() == child, "Focus should still be on child %p\n", child );
|
2004-05-24 21:08:41 +02:00
|
|
|
|
|
|
|
ShowWindow(child, SW_HIDE);
|
|
|
|
SetFocus(hwnd);
|
|
|
|
ok( GetFocus() == hwnd, "Focus should be on parent %p, not %p\n", hwnd, GetFocus() );
|
|
|
|
SetWindowPos(child,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);
|
|
|
|
ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
|
|
|
|
ShowWindow(child, SW_HIDE);
|
|
|
|
ok( GetFocus() == hwnd, "Focus should still be on parent %p, not %p\n", hwnd, GetFocus() );
|
|
|
|
|
2004-06-03 02:08:55 +02:00
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
ShowWindow(child, SW_SHOW);
|
|
|
|
SetFocus(child);
|
|
|
|
ok( GetFocus() == child, "Focus should be on child %p\n", child );
|
|
|
|
EnableWindow(hwnd, FALSE);
|
|
|
|
ok( GetFocus() == child, "Focus should still be on child %p\n", child );
|
|
|
|
EnableWindow(hwnd, TRUE);
|
|
|
|
|
2008-06-27 12:05:16 +02:00
|
|
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
|
|
|
ShowWindow(hwnd, SW_SHOWMINIMIZED);
|
|
|
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
|
|
|
todo_wine
|
|
|
|
ok( GetFocus() != child, "Focus should not be on child %p\n", child );
|
|
|
|
ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd );
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
|
|
|
ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd );
|
|
|
|
ShowWindow(hwnd, SW_SHOWMINIMIZED);
|
|
|
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
|
|
|
ok( GetFocus() != child, "Focus should not be on child %p\n", child );
|
|
|
|
todo_wine
|
|
|
|
ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd );
|
|
|
|
old_wnd_proc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)set_focus_on_activate_proc);
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd);
|
|
|
|
todo_wine
|
|
|
|
ok( GetFocus() == child, "Focus should be on child %p, not %p\n", child, GetFocus() );
|
|
|
|
|
|
|
|
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc);
|
|
|
|
|
2009-11-04 13:49:11 +01:00
|
|
|
DestroyWindow( child2 );
|
2004-04-28 05:52:27 +02:00
|
|
|
DestroyWindow( child );
|
|
|
|
}
|
|
|
|
|
2008-11-12 16:40:27 +01:00
|
|
|
#define check_wnd_state(a,b,c,d) check_wnd_state_(__FILE__,__LINE__,a,b,c,d)
|
|
|
|
static void check_wnd_state_(const char *file, int line,
|
|
|
|
HWND active, HWND foreground, HWND focus, HWND capture)
|
2006-07-07 16:01:51 +02:00
|
|
|
{
|
2008-11-12 16:40:27 +01:00
|
|
|
ok_(file, line)(active == GetActiveWindow(), "GetActiveWindow() = %p\n", GetActiveWindow());
|
2009-06-02 11:56:58 +02:00
|
|
|
/* only check foreground if it belongs to the current thread */
|
|
|
|
/* foreground can be moved to a different app pretty much at any time */
|
|
|
|
if (foreground && GetForegroundWindow() &&
|
|
|
|
GetWindowThreadProcessId(GetForegroundWindow(), NULL) == GetCurrentThreadId())
|
2008-11-12 16:40:27 +01:00
|
|
|
ok_(file, line)(foreground == GetForegroundWindow(), "GetForegroundWindow() = %p\n", GetForegroundWindow());
|
|
|
|
ok_(file, line)(focus == GetFocus(), "GetFocus() = %p\n", GetFocus());
|
|
|
|
ok_(file, line)(capture == GetCapture(), "GetCapture() = %p\n", GetCapture());
|
2006-07-07 16:01:51 +02:00
|
|
|
}
|
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
static void test_SetActiveWindow(HWND hwnd)
|
|
|
|
{
|
|
|
|
HWND hwnd2;
|
|
|
|
|
2008-08-04 23:07:10 +02:00
|
|
|
flush_events( TRUE );
|
2006-07-07 16:01:51 +02:00
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
SetFocus(0);
|
2004-05-18 02:48:09 +02:00
|
|
|
SetActiveWindow(0);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(0, 0, 0, 0);
|
|
|
|
|
|
|
|
/*trace("testing SetActiveWindow %p\n", hwnd);*/
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
hwnd2 = SetActiveWindow(0);
|
|
|
|
ok(hwnd2 == hwnd, "SetActiveWindow returned %p instead of %p\n", hwnd2, hwnd);
|
2008-11-26 12:04:51 +01:00
|
|
|
if (!GetActiveWindow()) /* doesn't always work on vista */
|
|
|
|
{
|
|
|
|
check_wnd_state(0, 0, 0, 0);
|
|
|
|
hwnd2 = SetActiveWindow(hwnd);
|
|
|
|
ok(hwnd2 == 0, "SetActiveWindow returned %p instead of 0\n", hwnd2);
|
|
|
|
}
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(0, 0, 0, 0);
|
2004-12-21 15:36:32 +01:00
|
|
|
|
2006-07-07 16:01:51 +02:00
|
|
|
/*trace("testing SetActiveWindow on an invisible window %p\n", hwnd);*/
|
2004-12-21 15:36:32 +01:00
|
|
|
SetActiveWindow(hwnd);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
2004-12-21 15:36:32 +01:00
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
2004-05-18 02:48:09 +02:00
|
|
|
|
|
|
|
hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
|
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
DestroyWindow(hwnd2);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
2004-05-18 02:48:09 +02:00
|
|
|
|
|
|
|
hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
|
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
SetWindowPos(hwnd2,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
|
|
|
|
|
2004-05-18 02:48:09 +02:00
|
|
|
DestroyWindow(hwnd2);
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
2004-05-18 02:48:09 +02:00
|
|
|
}
|
|
|
|
|
2006-07-07 16:01:51 +02:00
|
|
|
static void test_SetForegroundWindow(HWND hwnd)
|
2004-08-26 20:33:40 +02:00
|
|
|
{
|
2006-07-07 16:01:51 +02:00
|
|
|
BOOL ret;
|
|
|
|
HWND hwnd2;
|
|
|
|
|
2008-08-04 23:07:10 +02:00
|
|
|
flush_events( TRUE );
|
2006-07-07 16:01:51 +02:00
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
SetFocus(0);
|
|
|
|
SetActiveWindow(0);
|
|
|
|
check_wnd_state(0, 0, 0, 0);
|
|
|
|
|
|
|
|
/*trace("testing SetForegroundWindow %p\n", hwnd);*/
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
hwnd2 = SetActiveWindow(0);
|
|
|
|
ok(hwnd2 == hwnd, "SetActiveWindow(0) returned %p instead of %p\n", hwnd2, hwnd);
|
2008-11-26 12:04:51 +01:00
|
|
|
if (GetActiveWindow() == hwnd) /* doesn't always work on vista */
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
else
|
|
|
|
check_wnd_state(0, 0, 0, 0);
|
2006-07-07 16:01:51 +02:00
|
|
|
|
|
|
|
ret = SetForegroundWindow(hwnd);
|
2009-02-16 11:52:38 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
skip( "SetForegroundWindow not working\n" );
|
|
|
|
return;
|
|
|
|
}
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = SetForegroundWindow(0);
|
|
|
|
ok(!ret, "SetForegroundWindow returned TRUE instead of FALSE\n");
|
2008-11-26 12:04:51 +01:00
|
|
|
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE ||
|
|
|
|
broken(GetLastError() == 0xdeadbeef), /* win9x */
|
|
|
|
"got error %d expected ERROR_INVALID_WINDOW_HANDLE\n", GetLastError());
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
SetWindowPos(hwnd,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_SHOWWINDOW);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
2007-07-20 15:15:36 +02:00
|
|
|
hwnd2 = GetForegroundWindow();
|
|
|
|
ok(hwnd2 == hwnd, "Wrong foreground window %p\n", hwnd2);
|
|
|
|
ok(SetForegroundWindow( GetDesktopWindow() ), "SetForegroundWindow(desktop) error: %d\n", GetLastError());
|
|
|
|
hwnd2 = GetForegroundWindow();
|
|
|
|
ok(hwnd2 != hwnd, "Wrong foreground window %p\n", hwnd2);
|
|
|
|
|
2006-07-07 16:01:51 +02:00
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
|
|
|
check_wnd_state(0, 0, 0, 0);
|
|
|
|
|
|
|
|
/*trace("testing SetForegroundWindow on an invisible window %p\n", hwnd);*/
|
|
|
|
ret = SetForegroundWindow(hwnd);
|
2009-03-11 11:42:01 +01:00
|
|
|
ok(ret || broken(!ret), /* win98 */ "SetForegroundWindow returned FALSE instead of TRUE\n");
|
2006-07-07 16:01:51 +02:00
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
2009-03-11 11:42:01 +01:00
|
|
|
|
2006-07-07 16:01:51 +02:00
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
|
|
|
|
check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd2);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
hwnd2 = CreateWindowExA(0, "static", NULL, WS_POPUP|WS_VISIBLE, 0, 0, 0, 0, hwnd, 0, 0, NULL);
|
|
|
|
check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
|
|
|
|
|
|
|
|
SetWindowPos(hwnd2,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|SWP_HIDEWINDOW);
|
|
|
|
check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd2);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
2004-08-26 20:33:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static WNDPROC old_button_proc;
|
|
|
|
|
|
|
|
static LRESULT WINAPI button_hook_proc(HWND button, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
LRESULT ret;
|
|
|
|
USHORT key_state;
|
|
|
|
|
|
|
|
key_state = GetKeyState(VK_LBUTTON);
|
|
|
|
ok(!(key_state & 0x8000), "VK_LBUTTON should not be pressed, state %04x\n", key_state);
|
|
|
|
|
|
|
|
ret = CallWindowProcA(old_button_proc, button, msg, wparam, lparam);
|
|
|
|
|
|
|
|
if (msg == WM_LBUTTONDOWN)
|
|
|
|
{
|
|
|
|
HWND hwnd, capture;
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
trace("hwnd %p\n", hwnd);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
trace("hwnd %p\n", hwnd);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
/* button wnd proc should release capture on WM_KILLFOCUS if it does
|
|
|
|
* match internal button state.
|
|
|
|
*/
|
|
|
|
SendMessage(button, WM_KILLFOCUS, 0, 0);
|
|
|
|
check_wnd_state(button, button, button, 0);
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, 0);
|
|
|
|
|
|
|
|
capture = SetCapture(hwnd);
|
|
|
|
ok(capture == 0, "SetCapture() = %p\n", capture);
|
|
|
|
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, hwnd);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
check_wnd_state(button, 0, button, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_capture_1(void)
|
|
|
|
{
|
2008-11-19 11:06:59 +01:00
|
|
|
HWND button, capture, oldFocus, oldActive;
|
|
|
|
|
|
|
|
oldFocus = GetFocus();
|
|
|
|
oldActive = GetActiveWindow();
|
2004-08-26 20:33:40 +02:00
|
|
|
|
|
|
|
capture = GetCapture();
|
|
|
|
ok(capture == 0, "GetCapture() = %p\n", capture);
|
|
|
|
|
|
|
|
button = CreateWindowExA(0, "button", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
|
|
|
|
assert(button);
|
|
|
|
trace("button %p\n", button);
|
|
|
|
|
|
|
|
old_button_proc = (WNDPROC)SetWindowLongPtrA(button, GWLP_WNDPROC, (LONG_PTR)button_hook_proc);
|
|
|
|
|
|
|
|
SendMessageA(button, WM_LBUTTONDOWN, 0, 0);
|
|
|
|
|
2005-03-14 18:15:33 +01:00
|
|
|
capture = SetCapture(button);
|
|
|
|
ok(capture == 0, "SetCapture() = %p\n", capture);
|
|
|
|
check_wnd_state(button, 0, button, button);
|
|
|
|
|
2004-08-26 20:33:40 +02:00
|
|
|
DestroyWindow(button);
|
2008-11-19 11:06:59 +01:00
|
|
|
check_wnd_state(oldActive, 0, oldFocus, 0);
|
2004-08-26 20:33:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_capture_2(void)
|
|
|
|
{
|
2008-11-19 11:06:59 +01:00
|
|
|
HWND button, hwnd, capture, oldFocus, oldActive;
|
2004-08-26 20:33:40 +02:00
|
|
|
|
2008-11-19 11:06:59 +01:00
|
|
|
oldFocus = GetFocus();
|
|
|
|
oldActive = GetActiveWindow();
|
|
|
|
check_wnd_state(oldActive, 0, oldFocus, 0);
|
2004-08-26 20:33:40 +02:00
|
|
|
|
|
|
|
button = CreateWindowExA(0, "button", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 10, 10, 0, 0, 0, NULL);
|
|
|
|
assert(button);
|
|
|
|
trace("button %p\n", button);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, 0);
|
|
|
|
|
|
|
|
capture = SetCapture(button);
|
|
|
|
ok(capture == 0, "SetCapture() = %p\n", capture);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
/* button wnd proc should ignore WM_KILLFOCUS if it doesn't match
|
|
|
|
* internal button state.
|
|
|
|
*/
|
|
|
|
SendMessage(button, WM_KILLFOCUS, 0, 0);
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
trace("hwnd %p\n", hwnd);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 10, 10, 0, 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
trace("hwnd %p\n", hwnd);
|
|
|
|
|
|
|
|
check_wnd_state(button, button, button, button);
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, button);
|
|
|
|
|
|
|
|
capture = SetCapture(hwnd);
|
|
|
|
ok(capture == button, "SetCapture() = %p\n", capture);
|
|
|
|
|
|
|
|
check_wnd_state(hwnd, hwnd, hwnd, hwnd);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
check_wnd_state(button, button, button, 0);
|
|
|
|
|
|
|
|
DestroyWindow(button);
|
2008-11-19 11:06:59 +01:00
|
|
|
check_wnd_state(oldActive, 0, oldFocus, 0);
|
2004-08-26 20:33:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void test_capture_3(HWND hwnd1, HWND hwnd2)
|
|
|
|
{
|
2005-10-03 13:06:14 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2004-08-26 20:33:40 +02:00
|
|
|
ShowWindow(hwnd1, SW_HIDE);
|
|
|
|
ShowWindow(hwnd2, SW_HIDE);
|
|
|
|
|
|
|
|
ok(!IsWindowVisible(hwnd1), "%p should be invisible\n", hwnd1);
|
|
|
|
ok(!IsWindowVisible(hwnd2), "%p should be invisible\n", hwnd2);
|
|
|
|
|
|
|
|
SetCapture(hwnd1);
|
|
|
|
check_wnd_state(0, 0, 0, hwnd1);
|
|
|
|
|
|
|
|
SetCapture(hwnd2);
|
|
|
|
check_wnd_state(0, 0, 0, hwnd2);
|
|
|
|
|
|
|
|
ShowWindow(hwnd1, SW_SHOW);
|
|
|
|
check_wnd_state(hwnd1, hwnd1, hwnd1, hwnd2);
|
2004-09-16 21:09:44 +02:00
|
|
|
|
2005-10-03 13:06:14 +02:00
|
|
|
ret = ReleaseCapture();
|
|
|
|
ok (ret, "releasecapture did not return TRUE.\n");
|
|
|
|
ret = ReleaseCapture();
|
|
|
|
ok (ret, "releasecapture did not return TRUE after second try.\n");
|
2004-09-16 21:09:44 +02:00
|
|
|
}
|
|
|
|
|
2009-06-04 11:45:33 +02:00
|
|
|
/* PeekMessage wrapper that ignores the messages we don't care about */
|
|
|
|
static BOOL peek_message( MSG *msg )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ret = PeekMessageA(msg, 0, 0, 0, PM_REMOVE);
|
|
|
|
} while (ret && (msg->message == WM_TIMER || ignore_message(msg->message)));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-09-16 21:09:44 +02:00
|
|
|
static void test_keyboard_input(HWND hwnd)
|
|
|
|
{
|
|
|
|
MSG msg;
|
2004-12-27 18:26:37 +01:00
|
|
|
BOOL ret;
|
2004-09-16 21:09:44 +02:00
|
|
|
|
2008-08-04 23:07:10 +02:00
|
|
|
flush_events( TRUE );
|
2008-11-11 23:00:10 +01:00
|
|
|
SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_SHOWWINDOW);
|
2004-09-16 21:09:44 +02:00
|
|
|
UpdateWindow(hwnd);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
ok(GetActiveWindow() == hwnd, "wrong active window %p\n", GetActiveWindow());
|
|
|
|
|
|
|
|
SetFocus(hwnd);
|
|
|
|
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
|
|
|
|
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
PostMessageA(hwnd, WM_KEYDOWN, 0, 0);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
|
|
|
ok( ret, "no message available\n");
|
2004-09-16 21:09:44 +02:00
|
|
|
ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
|
|
|
|
|
|
|
|
PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN, 0, 0);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
|
|
|
ok(ret, "no message available\n");
|
2004-09-16 21:09:44 +02:00
|
|
|
ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
ok(GetFocus() == hwnd, "wrong focus window %p\n", GetFocus());
|
|
|
|
|
2004-09-24 00:52:26 +02:00
|
|
|
keybd_event(VK_SPACE, 0, 0, 0);
|
2009-06-04 11:45:33 +02:00
|
|
|
if (!peek_message(&msg))
|
2009-02-13 13:03:26 +01:00
|
|
|
{
|
|
|
|
skip( "keybd_event didn't work, skipping keyboard test\n" );
|
|
|
|
return;
|
|
|
|
}
|
2004-09-24 00:52:26 +02:00
|
|
|
ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
SetFocus(0);
|
|
|
|
ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
|
|
|
|
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
PostMessageA(hwnd, WM_KEYDOWN, 0, 0);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
|
|
|
ok(ret, "no message available\n");
|
2004-09-16 21:09:44 +02:00
|
|
|
ok(msg.hwnd == hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
|
|
|
|
|
|
|
|
PostThreadMessageA(GetCurrentThreadId(), WM_KEYDOWN, 0, 0);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
|
|
|
ok(ret, "no message available\n");
|
2004-09-16 21:09:44 +02:00
|
|
|
ok(!msg.hwnd && msg.message == WM_KEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2004-09-16 21:09:44 +02:00
|
|
|
|
|
|
|
ok(GetFocus() == 0, "wrong focus window %p\n", GetFocus());
|
|
|
|
|
2004-09-24 00:52:26 +02:00
|
|
|
keybd_event(VK_SPACE, 0, 0, 0);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
|
|
|
ok(ret, "no message available\n");
|
2004-09-24 00:52:26 +02:00
|
|
|
ok(msg.hwnd == hwnd && msg.message == WM_SYSKEYDOWN, "hwnd %p message %04x\n", msg.hwnd, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2004-08-26 20:33:40 +02:00
|
|
|
}
|
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
static BOOL wait_for_message( MSG *msg )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(msg);
|
2009-01-22 13:12:09 +01:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
if (msg->message == WM_PAINT) DispatchMessage(msg);
|
2009-06-04 11:45:33 +02:00
|
|
|
else break;
|
2009-01-22 13:12:09 +01:00
|
|
|
}
|
|
|
|
else if (MsgWaitForMultipleObjects( 0, NULL, FALSE, 100, QS_ALLINPUT ) == WAIT_TIMEOUT) break;
|
|
|
|
}
|
|
|
|
if (!ret) msg->message = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-12-17 19:49:24 +01:00
|
|
|
static void test_mouse_input(HWND hwnd)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
POINT pt;
|
|
|
|
int x, y;
|
|
|
|
HWND popup;
|
|
|
|
MSG msg;
|
2004-12-27 18:26:37 +01:00
|
|
|
BOOL ret;
|
2005-09-29 15:36:14 +02:00
|
|
|
LRESULT res;
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
UpdateWindow(hwnd);
|
2009-01-22 13:12:09 +01:00
|
|
|
SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("main window %p: (%d,%d)-(%d,%d)\n", hwnd, rc.left, rc.top, rc.right, rc.bottom);
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
popup = CreateWindowExA(0, "MainWindowClass", NULL, WS_POPUP,
|
|
|
|
rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
|
|
|
|
hwnd, 0, 0, NULL);
|
|
|
|
assert(popup != 0);
|
|
|
|
ShowWindow(popup, SW_SHOW);
|
|
|
|
UpdateWindow(popup);
|
2009-01-22 13:12:09 +01:00
|
|
|
SetWindowPos( popup, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
GetWindowRect(popup, &rc);
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("popup window %p: (%d,%d)-(%d,%d)\n", popup, rc.left, rc.top, rc.right, rc.bottom);
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
x = rc.left + (rc.right - rc.left) / 2;
|
|
|
|
y = rc.top + (rc.bottom - rc.top) / 2;
|
|
|
|
trace("setting cursor to (%d,%d)\n", x, y);
|
|
|
|
|
|
|
|
SetCursorPos(x, y);
|
|
|
|
GetCursorPos(&pt);
|
2009-02-13 13:03:26 +01:00
|
|
|
if (x != pt.x || y != pt.y)
|
|
|
|
{
|
|
|
|
skip( "failed to set mouse position, skipping mouse input tests\n" );
|
|
|
|
goto done;
|
|
|
|
}
|
2004-12-17 19:49:24 +01:00
|
|
|
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2006-12-18 21:26:35 +01:00
|
|
|
|
2008-11-20 11:57:32 +01:00
|
|
|
/* Check that setting the same position may generate WM_MOUSEMOVE */
|
2006-12-18 21:26:35 +01:00
|
|
|
SetCursorPos(x, y);
|
|
|
|
msg.message = 0;
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2008-11-20 11:57:32 +01:00
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n",
|
|
|
|
msg.hwnd, msg.message);
|
|
|
|
ok(msg.pt.x == x && msg.pt.y == y, "wrong message coords (%d,%d)/(%d,%d)\n",
|
|
|
|
x, y, msg.pt.x, msg.pt.y);
|
|
|
|
}
|
2006-12-18 21:26:35 +01:00
|
|
|
|
2004-12-17 19:49:24 +01:00
|
|
|
/* force the system to update its internal queue mouse position,
|
|
|
|
* otherwise it won't generate relative mouse movements below.
|
|
|
|
*/
|
|
|
|
mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
msg.message = 0;
|
|
|
|
mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
|
2009-01-22 13:12:09 +01:00
|
|
|
flush_events( FALSE );
|
2004-12-17 19:49:24 +01:00
|
|
|
/* FIXME: SetCursorPos in Wine generates additional WM_MOUSEMOVE message */
|
2008-11-20 11:57:32 +01:00
|
|
|
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE))
|
|
|
|
{
|
2009-06-04 11:45:33 +02:00
|
|
|
if (msg.message == WM_TIMER || ignore_message(msg.message)) continue;
|
2008-11-20 11:57:32 +01:00
|
|
|
ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE,
|
|
|
|
"hwnd %p message %04x\n", msg.hwnd, msg.message);
|
|
|
|
}
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
mouse_event(MOUSEEVENTF_MOVE, -1, -1, 0, 0);
|
|
|
|
ShowWindow(popup, SW_HIDE);
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
if (ret)
|
|
|
|
ok(msg.hwnd == hwnd && msg.message == WM_MOUSEMOVE, "hwnd %p message %04x\n", msg.hwnd, msg.message);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2004-12-17 19:49:24 +01:00
|
|
|
|
|
|
|
mouse_event(MOUSEEVENTF_MOVE, 1, 1, 0, 0);
|
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
2004-12-27 18:26:37 +01:00
|
|
|
ok( !ret, "message %04x available\n", msg.message);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2004-12-17 19:49:24 +01:00
|
|
|
|
2005-03-07 18:13:07 +01:00
|
|
|
/* test mouse clicks */
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
2009-02-09 14:20:17 +01:00
|
|
|
SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-03-07 18:13:07 +01:00
|
|
|
ShowWindow(popup, SW_SHOW);
|
2009-02-09 14:20:17 +01:00
|
|
|
SetWindowPos( popup, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-03-07 18:13:07 +01:00
|
|
|
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
2009-02-13 13:03:26 +01:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
skip( "simulating mouse click doesn't work, skipping mouse button tests\n" );
|
|
|
|
goto done;
|
|
|
|
}
|
2009-01-23 13:13:54 +01:00
|
|
|
if (msg.message == WM_MOUSEMOVE) /* win2k has an extra WM_MOUSEMOVE here */
|
|
|
|
{
|
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
ok(ret, "no message available\n");
|
|
|
|
}
|
|
|
|
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == popup && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, popup, msg.message);
|
2005-06-15 20:07:33 +02:00
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
ok(ret, "no message available\n");
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, popup, msg.message);
|
2005-06-15 20:07:33 +02:00
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
ok(ret, "no message available\n");
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == popup && msg.message == WM_LBUTTONDBLCLK, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, popup, msg.message);
|
2005-06-15 20:07:33 +02:00
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
ok(ret, "no message available\n");
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, popup, msg.message);
|
2005-03-07 18:13:07 +01:00
|
|
|
|
2009-06-04 11:45:33 +02:00
|
|
|
ret = peek_message(&msg);
|
2005-03-07 18:13:07 +01:00
|
|
|
ok(!ret, "message %04x available\n", msg.message);
|
|
|
|
|
|
|
|
ShowWindow(popup, SW_HIDE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-03-07 18:13:07 +01:00
|
|
|
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
|
|
|
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
|
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
ok(ret, "no message available\n");
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == hwnd && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, hwnd, msg.message);
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
ok(ret, "no message available\n");
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == hwnd && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, hwnd, msg.message);
|
2005-03-07 18:13:07 +01:00
|
|
|
|
|
|
|
test_lbuttondown_flag = TRUE;
|
|
|
|
SendMessageA(hwnd, WM_COMMAND, (WPARAM)popup, 0);
|
|
|
|
test_lbuttondown_flag = FALSE;
|
|
|
|
|
2009-01-22 13:12:09 +01:00
|
|
|
ret = wait_for_message( &msg );
|
|
|
|
ok(ret, "no message available\n");
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == popup && msg.message == WM_LBUTTONDOWN, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, popup, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ok(peek_message(&msg), "no message available\n");
|
2008-02-28 19:56:38 +01:00
|
|
|
ok(msg.hwnd == popup && msg.message == WM_LBUTTONUP, "hwnd %p/%p message %04x\n",
|
|
|
|
msg.hwnd, popup, msg.message);
|
2009-06-04 11:45:33 +02:00
|
|
|
ok(peek_message(&msg), "no message available\n");
|
2005-03-07 18:13:07 +01:00
|
|
|
|
2005-09-29 15:36:14 +02:00
|
|
|
/* Test WM_MOUSEACTIVATE */
|
|
|
|
#define TEST_MOUSEACTIVATE(A,B) \
|
|
|
|
res = SendMessageA(hwnd, WM_MOUSEACTIVATE, (WPARAM)hwnd, (LPARAM)MAKELRESULT(A,0)); \
|
|
|
|
ok(res == B, "WM_MOUSEACTIVATE for %s returned %ld\n", #A, res);
|
|
|
|
|
|
|
|
TEST_MOUSEACTIVATE(HTERROR,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTTRANSPARENT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTNOWHERE,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTCLIENT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTCAPTION,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTSYSMENU,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTSIZE,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTMENU,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTHSCROLL,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTVSCROLL,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTMINBUTTON,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTMAXBUTTON,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTLEFT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTRIGHT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTTOP,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTTOPLEFT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTTOPRIGHT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTBOTTOM,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTBOTTOMLEFT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTBOTTOMRIGHT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTBORDER,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTOBJECT,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTCLOSE,MA_ACTIVATE);
|
|
|
|
TEST_MOUSEACTIVATE(HTHELP,MA_ACTIVATE);
|
|
|
|
|
2009-02-13 13:03:26 +01:00
|
|
|
done:
|
2005-09-29 15:36:14 +02:00
|
|
|
/* Clear any messages left behind by WM_MOUSEACTIVATE tests */
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-09-29 15:36:14 +02:00
|
|
|
|
2004-12-17 19:49:24 +01:00
|
|
|
DestroyWindow(popup);
|
|
|
|
}
|
|
|
|
|
2005-02-16 18:52:01 +01:00
|
|
|
static void test_validatergn(HWND hwnd)
|
|
|
|
{
|
|
|
|
HWND child;
|
|
|
|
RECT rc, rc2;
|
|
|
|
HRGN rgn;
|
|
|
|
int ret;
|
|
|
|
child = CreateWindowExA(0, "static", NULL, WS_CHILD| WS_VISIBLE, 10, 10, 10, 10, hwnd, 0, 0, NULL);
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
UpdateWindow( hwnd);
|
|
|
|
/* test that ValidateRect validates children*/
|
|
|
|
InvalidateRect( child, NULL, 1);
|
|
|
|
GetWindowRect( child, &rc);
|
|
|
|
MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
|
|
|
|
ret = GetUpdateRect( child, &rc2, 0);
|
|
|
|
ok( rc2.right > rc2.left && rc2.bottom > rc2.top,
|
|
|
|
"Update rectangle is empty!\n");
|
|
|
|
ValidateRect( hwnd, &rc);
|
|
|
|
ret = GetUpdateRect( child, &rc2, 0);
|
|
|
|
ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
|
2006-10-07 21:45:11 +02:00
|
|
|
"Update rectangle %d,%d-%d,%d is not empty!\n", rc2.left, rc2.top,
|
2005-02-16 18:52:01 +01:00
|
|
|
rc2.right, rc2.bottom);
|
|
|
|
|
|
|
|
/* now test ValidateRgn */
|
|
|
|
InvalidateRect( child, NULL, 1);
|
|
|
|
GetWindowRect( child, &rc);
|
|
|
|
MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
|
|
|
|
rgn = CreateRectRgnIndirect( &rc);
|
|
|
|
ValidateRgn( hwnd, rgn);
|
|
|
|
ret = GetUpdateRect( child, &rc2, 0);
|
|
|
|
ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
|
2006-10-07 21:45:11 +02:00
|
|
|
"Update rectangle %d,%d-%d,%d is not empty!\n", rc2.left, rc2.top,
|
2005-02-16 18:52:01 +01:00
|
|
|
rc2.right, rc2.bottom);
|
|
|
|
|
|
|
|
DeleteObject( rgn);
|
|
|
|
DestroyWindow( child );
|
|
|
|
}
|
|
|
|
|
2005-03-02 11:11:06 +01:00
|
|
|
static void nccalchelper(HWND hwnd, INT x, INT y, RECT *prc)
|
2005-02-22 16:46:36 +01:00
|
|
|
{
|
2009-01-25 17:29:32 +01:00
|
|
|
RECT rc;
|
2005-02-22 16:46:36 +01:00
|
|
|
MoveWindow( hwnd, 0, 0, x, y, 0);
|
|
|
|
GetWindowRect( hwnd, prc);
|
2009-01-25 17:29:32 +01:00
|
|
|
rc = *prc;
|
2005-02-22 16:46:36 +01:00
|
|
|
DefWindowProcA(hwnd, WM_NCCALCSIZE, 0, (LPARAM)prc);
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("window rect is %d,%d - %d,%d, nccalc rect is %d,%d - %d,%d\n",
|
|
|
|
rc.left,rc.top,rc.right,rc.bottom, prc->left,prc->top,prc->right,prc->bottom);
|
2005-02-22 16:46:36 +01:00
|
|
|
}
|
|
|
|
|
2005-03-02 11:11:06 +01:00
|
|
|
static void test_nccalcscroll(HWND parent)
|
2005-02-22 16:46:36 +01:00
|
|
|
{
|
|
|
|
RECT rc1;
|
|
|
|
INT sbheight = GetSystemMetrics( SM_CYHSCROLL);
|
|
|
|
INT sbwidth = GetSystemMetrics( SM_CXVSCROLL);
|
|
|
|
HWND hwnd = CreateWindowExA(0, "static", NULL,
|
|
|
|
WS_CHILD| WS_VISIBLE | WS_VSCROLL | WS_HSCROLL ,
|
|
|
|
10, 10, 200, 200, parent, 0, 0, NULL);
|
|
|
|
ShowWindow( parent, SW_SHOW);
|
|
|
|
UpdateWindow( parent);
|
|
|
|
|
|
|
|
/* test window too low for a horizontal scroll bar */
|
|
|
|
nccalchelper( hwnd, 100, sbheight, &rc1);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( rc1.bottom - rc1.top == sbheight, "Height should be %d size is %d,%d - %d,%d\n",
|
2005-02-22 16:46:36 +01:00
|
|
|
sbheight, rc1.left, rc1.top, rc1.right, rc1.bottom);
|
|
|
|
|
|
|
|
/* test window just high enough for a horizontal scroll bar */
|
|
|
|
nccalchelper( hwnd, 100, sbheight + 1, &rc1);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( rc1.bottom - rc1.top == 1, "Height should be %d size is %d,%d - %d,%d\n",
|
2005-02-22 16:46:36 +01:00
|
|
|
1, rc1.left, rc1.top, rc1.right, rc1.bottom);
|
|
|
|
|
|
|
|
/* test window too narrow for a vertical scroll bar */
|
|
|
|
nccalchelper( hwnd, sbwidth - 1, 100, &rc1);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( rc1.right - rc1.left == sbwidth - 1 , "Width should be %d size is %d,%d - %d,%d\n",
|
2005-02-22 16:46:36 +01:00
|
|
|
sbwidth - 1, rc1.left, rc1.top, rc1.right, rc1.bottom);
|
|
|
|
|
|
|
|
/* test window just wide enough for a vertical scroll bar */
|
|
|
|
nccalchelper( hwnd, sbwidth, 100, &rc1);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( rc1.right - rc1.left == 0, "Width should be %d size is %d,%d - %d,%d\n",
|
2005-02-22 16:46:36 +01:00
|
|
|
0, rc1.left, rc1.top, rc1.right, rc1.bottom);
|
|
|
|
|
|
|
|
/* same test, but with client edge: not enough width */
|
|
|
|
SetWindowLong( hwnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE | GetWindowLong( hwnd, GWL_EXSTYLE));
|
|
|
|
nccalchelper( hwnd, sbwidth, 100, &rc1);
|
|
|
|
ok( rc1.right - rc1.left == sbwidth - 2 * GetSystemMetrics(SM_CXEDGE),
|
2006-10-07 21:45:11 +02:00
|
|
|
"Width should be %d size is %d,%d - %d,%d\n",
|
2005-02-22 16:46:36 +01:00
|
|
|
sbwidth - 2 * GetSystemMetrics(SM_CXEDGE), rc1.left, rc1.top, rc1.right, rc1.bottom);
|
|
|
|
|
|
|
|
DestroyWindow( hwnd);
|
|
|
|
}
|
2005-03-02 11:11:06 +01:00
|
|
|
|
|
|
|
static void test_SetParent(void)
|
|
|
|
{
|
2005-03-31 21:07:08 +02:00
|
|
|
BOOL ret;
|
2005-03-02 11:11:06 +01:00
|
|
|
HWND desktop = GetDesktopWindow();
|
2005-04-26 10:16:17 +02:00
|
|
|
HMENU hMenu;
|
2005-03-02 11:11:06 +01:00
|
|
|
BOOL is_win9x = GetWindowLongPtrW(desktop, GWLP_WNDPROC) == 0;
|
2005-04-26 10:16:17 +02:00
|
|
|
HWND parent, child1, child2, child3, child4, sibling;
|
2005-03-02 11:11:06 +01:00
|
|
|
|
|
|
|
parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
|
|
|
|
100, 100, 200, 200, 0, 0, 0, NULL);
|
|
|
|
assert(parent != 0);
|
|
|
|
child1 = CreateWindowExA(0, "static", NULL, WS_CHILD,
|
|
|
|
0, 0, 50, 50, parent, 0, 0, NULL);
|
|
|
|
assert(child1 != 0);
|
|
|
|
child2 = CreateWindowExA(0, "static", NULL, WS_POPUP,
|
|
|
|
0, 0, 50, 50, child1, 0, 0, NULL);
|
|
|
|
assert(child2 != 0);
|
|
|
|
child3 = CreateWindowExA(0, "static", NULL, WS_CHILD,
|
|
|
|
0, 0, 50, 50, child2, 0, 0, NULL);
|
|
|
|
assert(child3 != 0);
|
|
|
|
child4 = CreateWindowExA(0, "static", NULL, WS_POPUP,
|
|
|
|
0, 0, 50, 50, child3, 0, 0, NULL);
|
|
|
|
assert(child4 != 0);
|
|
|
|
|
|
|
|
trace("parent %p, child1 %p, child2 %p, child3 %p, child4 %p\n",
|
|
|
|
parent, child1, child2, child3, child4);
|
|
|
|
|
|
|
|
check_parents(parent, desktop, 0, 0, 0, parent, parent);
|
|
|
|
check_parents(child1, parent, parent, parent, 0, parent, parent);
|
|
|
|
check_parents(child2, desktop, parent, parent, parent, child2, parent);
|
|
|
|
check_parents(child3, child2, child2, child2, 0, child2, parent);
|
|
|
|
check_parents(child4, desktop, child2, child2, child2, child4, parent);
|
|
|
|
|
|
|
|
ok(!IsChild(desktop, parent), "wrong parent/child %p/%p\n", desktop, parent);
|
|
|
|
ok(!IsChild(desktop, child1), "wrong parent/child %p/%p\n", desktop, child1);
|
|
|
|
ok(!IsChild(desktop, child2), "wrong parent/child %p/%p\n", desktop, child2);
|
|
|
|
ok(!IsChild(desktop, child3), "wrong parent/child %p/%p\n", desktop, child3);
|
|
|
|
ok(!IsChild(desktop, child4), "wrong parent/child %p/%p\n", desktop, child4);
|
|
|
|
|
|
|
|
ok(IsChild(parent, child1), "wrong parent/child %p/%p\n", parent, child1);
|
|
|
|
ok(!IsChild(desktop, child2), "wrong parent/child %p/%p\n", desktop, child2);
|
|
|
|
ok(!IsChild(parent, child2), "wrong parent/child %p/%p\n", parent, child2);
|
|
|
|
ok(!IsChild(child1, child2), "wrong parent/child %p/%p\n", child1, child2);
|
|
|
|
ok(!IsChild(parent, child3), "wrong parent/child %p/%p\n", parent, child3);
|
|
|
|
ok(IsChild(child2, child3), "wrong parent/child %p/%p\n", child2, child3);
|
|
|
|
ok(!IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
|
|
|
|
ok(!IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
|
|
|
|
ok(!IsChild(desktop, child4), "wrong parent/child %p/%p\n", desktop, child4);
|
|
|
|
|
|
|
|
if (!is_win9x) /* Win9x doesn't survive this test */
|
|
|
|
{
|
|
|
|
ok(!SetParent(parent, child1), "SetParent should fail\n");
|
|
|
|
ok(!SetParent(child2, child3), "SetParent should fail\n");
|
|
|
|
ok(SetParent(child1, parent) != 0, "SetParent should not fail\n");
|
|
|
|
ok(SetParent(parent, child2) != 0, "SetParent should not fail\n");
|
|
|
|
ok(SetParent(parent, child3) != 0, "SetParent should not fail\n");
|
|
|
|
ok(!SetParent(child2, parent), "SetParent should fail\n");
|
|
|
|
ok(SetParent(parent, child4) != 0, "SetParent should not fail\n");
|
|
|
|
|
|
|
|
check_parents(parent, child4, child4, 0, 0, child4, parent);
|
|
|
|
check_parents(child1, parent, parent, parent, 0, child4, parent);
|
|
|
|
check_parents(child2, desktop, parent, parent, parent, child2, parent);
|
|
|
|
check_parents(child3, child2, child2, child2, 0, child2, parent);
|
|
|
|
check_parents(child4, desktop, child2, child2, child2, child4, parent);
|
|
|
|
}
|
|
|
|
|
2005-04-26 10:16:17 +02:00
|
|
|
hMenu = CreateMenu();
|
|
|
|
sibling = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
|
|
|
|
100, 100, 200, 200, 0, hMenu, 0, NULL);
|
|
|
|
assert(sibling != 0);
|
|
|
|
|
|
|
|
ok(SetParent(sibling, parent) != 0, "SetParent should not fail\n");
|
|
|
|
ok(GetMenu(sibling) == hMenu, "SetParent should not remove menu\n");
|
|
|
|
|
2005-03-31 21:07:08 +02:00
|
|
|
ret = DestroyWindow(parent);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok( ret, "DestroyWindow() error %d\n", GetLastError());
|
2005-03-02 11:11:06 +01:00
|
|
|
|
|
|
|
ok(!IsWindow(parent), "parent still exists\n");
|
2005-04-26 10:16:17 +02:00
|
|
|
ok(!IsWindow(sibling), "sibling still exists\n");
|
2005-03-02 11:11:06 +01:00
|
|
|
ok(!IsWindow(child1), "child1 still exists\n");
|
|
|
|
ok(!IsWindow(child2), "child2 still exists\n");
|
|
|
|
ok(!IsWindow(child3), "child3 still exists\n");
|
|
|
|
ok(!IsWindow(child4), "child4 still exists\n");
|
|
|
|
}
|
|
|
|
|
2005-03-23 11:26:15 +01:00
|
|
|
static LRESULT WINAPI StyleCheckProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
LPCREATESTRUCT lpcs;
|
|
|
|
LPSTYLESTRUCT lpss;
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_NCCREATE:
|
|
|
|
case WM_CREATE:
|
|
|
|
lpcs = (LPCREATESTRUCT)lparam;
|
2009-02-05 09:53:39 +01:00
|
|
|
lpss = lpcs->lpCreateParams;
|
2005-03-23 11:26:15 +01:00
|
|
|
if (lpss)
|
|
|
|
{
|
|
|
|
if ((lpcs->dwExStyle & WS_EX_DLGMODALFRAME) ||
|
|
|
|
((!(lpcs->dwExStyle & WS_EX_STATICEDGE)) &&
|
|
|
|
(lpcs->style & (WS_DLGFRAME | WS_THICKFRAME))))
|
|
|
|
ok(lpcs->dwExStyle & WS_EX_WINDOWEDGE, "Window should have WS_EX_WINDOWEDGE style\n");
|
|
|
|
else
|
|
|
|
ok(!(lpcs->dwExStyle & WS_EX_WINDOWEDGE), "Window shouldn't have WS_EX_WINDOWEDGE style\n");
|
|
|
|
|
|
|
|
ok((lpss->styleOld & ~WS_EX_WINDOWEDGE) == (lpcs->dwExStyle & ~WS_EX_WINDOWEDGE),
|
|
|
|
"Ex style (0x%08lx) should match what the caller passed to CreateWindowEx (0x%08lx)\n",
|
|
|
|
(lpss->styleOld & ~WS_EX_WINDOWEDGE), (lpcs->dwExStyle & ~WS_EX_WINDOWEDGE));
|
|
|
|
|
|
|
|
ok(lpss->styleNew == lpcs->style,
|
2006-10-07 21:45:11 +02:00
|
|
|
"Style (0x%08x) should match what the caller passed to CreateWindowEx (0x%08x)\n",
|
2005-03-23 11:26:15 +01:00
|
|
|
lpss->styleNew, lpcs->style);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ATOM atomStyleCheckClass;
|
|
|
|
|
|
|
|
static void register_style_check_class(void)
|
|
|
|
{
|
|
|
|
WNDCLASS wc =
|
|
|
|
{
|
|
|
|
0,
|
|
|
|
StyleCheckProc,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
GetModuleHandle(NULL),
|
|
|
|
NULL,
|
|
|
|
LoadCursor(NULL, IDC_ARROW),
|
|
|
|
(HBRUSH)(COLOR_BTNFACE+1),
|
|
|
|
NULL,
|
|
|
|
TEXT("WineStyleCheck"),
|
|
|
|
};
|
|
|
|
|
|
|
|
atomStyleCheckClass = RegisterClass(&wc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_window_style(DWORD dwStyleIn, DWORD dwExStyleIn, DWORD dwStyleOut, DWORD dwExStyleOut)
|
|
|
|
{
|
|
|
|
DWORD dwActualStyle;
|
|
|
|
DWORD dwActualExStyle;
|
|
|
|
STYLESTRUCT ss;
|
|
|
|
HWND hwnd;
|
|
|
|
HWND hwndParent = NULL;
|
|
|
|
|
|
|
|
ss.styleNew = dwStyleIn;
|
|
|
|
ss.styleOld = dwExStyleIn;
|
|
|
|
|
|
|
|
if (dwStyleIn & WS_CHILD)
|
|
|
|
{
|
|
|
|
hwndParent = CreateWindowEx(0, MAKEINTATOM(atomStyleCheckClass), NULL,
|
|
|
|
WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
hwnd = CreateWindowEx(dwExStyleIn, MAKEINTATOM(atomStyleCheckClass), NULL,
|
|
|
|
dwStyleIn, 0, 0, 0, 0, hwndParent, NULL, NULL, &ss);
|
|
|
|
assert(hwnd);
|
|
|
|
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-03-23 11:26:15 +01:00
|
|
|
|
|
|
|
dwActualStyle = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
dwActualExStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
|
|
|
|
ok((dwActualStyle == dwStyleOut) && (dwActualExStyle == dwExStyleOut),
|
2006-10-07 21:45:11 +02:00
|
|
|
"Style (0x%08x) should really be 0x%08x and/or Ex style (0x%08x) should really be 0x%08x\n",
|
2005-03-23 11:26:15 +01:00
|
|
|
dwActualStyle, dwStyleOut, dwActualExStyle, dwExStyleOut);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
if (hwndParent) DestroyWindow(hwndParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tests what window styles the window manager automatically adds */
|
2005-06-17 12:11:37 +02:00
|
|
|
static void test_window_styles(void)
|
2005-03-23 11:26:15 +01:00
|
|
|
{
|
|
|
|
register_style_check_class();
|
|
|
|
|
|
|
|
check_window_style(0, 0, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE);
|
|
|
|
check_window_style(WS_OVERLAPPEDWINDOW, 0, WS_CLIPSIBLINGS|WS_OVERLAPPEDWINDOW, WS_EX_WINDOWEDGE);
|
|
|
|
check_window_style(WS_CHILD, 0, WS_CHILD, 0);
|
|
|
|
check_window_style(WS_CHILD, WS_EX_WINDOWEDGE, WS_CHILD, 0);
|
|
|
|
check_window_style(0, WS_EX_TOOLWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_WINDOWEDGE|WS_EX_TOOLWINDOW);
|
|
|
|
check_window_style(WS_POPUP, 0, WS_POPUP|WS_CLIPSIBLINGS, 0);
|
|
|
|
check_window_style(WS_POPUP, WS_EX_WINDOWEDGE, WS_POPUP|WS_CLIPSIBLINGS, 0);
|
|
|
|
check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME, WS_CHILD, WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME);
|
|
|
|
check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME|WS_EX_STATICEDGE, WS_CHILD, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME);
|
|
|
|
check_window_style(WS_CAPTION, WS_EX_STATICEDGE, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE);
|
|
|
|
check_window_style(0, WS_EX_APPWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE);
|
|
|
|
}
|
|
|
|
|
2009-09-24 11:17:26 +02:00
|
|
|
static void test_scrollwindow( HWND hwnd)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
RECT rc, rc2, rc3;
|
|
|
|
COLORREF colr;
|
|
|
|
|
|
|
|
ShowWindow( hwnd, SW_SHOW);
|
|
|
|
UpdateWindow( hwnd);
|
2009-09-25 16:08:50 +02:00
|
|
|
flush_events( TRUE );
|
2009-09-24 11:17:26 +02:00
|
|
|
GetClientRect( hwnd, &rc);
|
|
|
|
hdc = GetDC( hwnd);
|
|
|
|
/* test ScrollWindow(Ex) with no clip rectangle */
|
|
|
|
/* paint the lower half of the window black */
|
|
|
|
rc2 = rc;
|
|
|
|
rc2.top = ( rc2.top + rc2.bottom) / 2;
|
|
|
|
FillRect( hdc, &rc2, GetStockObject(BLACK_BRUSH));
|
|
|
|
/* paint the upper half of the window white */
|
|
|
|
rc2.bottom = rc2.top;
|
|
|
|
rc2.top =0;
|
|
|
|
FillRect( hdc, &rc2, GetStockObject(WHITE_BRUSH));
|
|
|
|
/* scroll lower half up */
|
|
|
|
rc2 = rc;
|
|
|
|
rc2.top = ( rc2.top + rc2.bottom) / 2;
|
|
|
|
ScrollWindowEx( hwnd, 0, - rc2.top, &rc2, NULL, NULL, NULL, SW_ERASE);
|
2009-10-06 13:35:56 +02:00
|
|
|
flush_events(FALSE);
|
2009-09-24 11:17:26 +02:00
|
|
|
/* expected: black should have scrolled to the upper half */
|
|
|
|
colr = GetPixel( hdc, (rc2.left+rc2.right)/ 2, rc2.bottom / 4 );
|
|
|
|
ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
|
|
|
|
/* Repeat that test of ScrollWindow(Ex) now with clip rectangle */
|
|
|
|
/* paint the lower half of the window black */
|
|
|
|
rc2 = rc;
|
|
|
|
rc2.top = ( rc2.top + rc2.bottom) / 2;
|
|
|
|
FillRect( hdc, &rc2, GetStockObject(BLACK_BRUSH));
|
|
|
|
/* paint the upper half of the window white */
|
|
|
|
rc2.bottom = rc2.top;
|
|
|
|
rc2.top =0;
|
|
|
|
FillRect( hdc, &rc2, GetStockObject(WHITE_BRUSH));
|
|
|
|
/* scroll lower half up */
|
|
|
|
rc2 = rc;
|
|
|
|
rc2.top = ( rc2.top + rc2.bottom) / 2;
|
|
|
|
rc3 = rc;
|
|
|
|
rc3.left = rc3.right / 4;
|
|
|
|
rc3.right -= rc3.right / 4;
|
|
|
|
ScrollWindowEx( hwnd, 0, - rc2.top, &rc2, &rc3, NULL, NULL, SW_ERASE);
|
2009-10-06 13:35:56 +02:00
|
|
|
flush_events(FALSE);
|
2009-09-24 11:17:26 +02:00
|
|
|
/* expected: black should have scrolled to the upper half */
|
|
|
|
colr = GetPixel( hdc, (rc2.left+rc2.right)/ 2, rc2.bottom / 4 );
|
|
|
|
ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
|
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
ReleaseDC( hwnd, hdc);
|
|
|
|
}
|
|
|
|
|
2005-06-15 12:20:53 +02:00
|
|
|
static void test_scrollvalidate( HWND parent)
|
2005-03-25 18:11:04 +01:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HRGN hrgn=CreateRectRgn(0,0,0,0);
|
|
|
|
HRGN exprgn, tmprgn, clipping;
|
|
|
|
RECT rc, rcu, cliprc;
|
|
|
|
/* create two overlapping child windows. The visual region
|
|
|
|
* of hwnd1 is clipped by the overlapping part of
|
|
|
|
* hwnd2 because of the WS_CLIPSIBLING style */
|
2005-03-31 17:30:25 +02:00
|
|
|
HWND hwnd1, hwnd2;
|
|
|
|
|
2005-12-19 17:43:34 +01:00
|
|
|
clipping = CreateRectRgn(0,0,0,0);
|
|
|
|
tmprgn = CreateRectRgn(0,0,0,0);
|
|
|
|
exprgn = CreateRectRgn(0,0,0,0);
|
2005-03-31 17:30:25 +02:00
|
|
|
hwnd2 = CreateWindowExA(0, "static", NULL,
|
|
|
|
WS_CHILD| WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER ,
|
|
|
|
75, 30, 100, 100, parent, 0, 0, NULL);
|
|
|
|
hwnd1 = CreateWindowExA(0, "static", NULL,
|
|
|
|
WS_CHILD| WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER ,
|
|
|
|
25, 50, 100, 100, parent, 0, 0, NULL);
|
2005-03-25 18:11:04 +01:00
|
|
|
ShowWindow( parent, SW_SHOW);
|
|
|
|
UpdateWindow( parent);
|
|
|
|
GetClientRect( hwnd1, &rc);
|
|
|
|
cliprc=rc;
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( clipping, 10, 10, 90, 90);
|
2005-03-25 18:11:04 +01:00
|
|
|
hdc = GetDC( hwnd1);
|
|
|
|
/* for a visual touch */
|
|
|
|
TextOut( hdc, 0,10, "0123456789", 10);
|
|
|
|
ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
|
|
|
/* create a region with what is expected */
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( exprgn, 39,0,49,74);
|
|
|
|
SetRectRgn( tmprgn, 88,79,98,93);
|
2005-03-25 18:11:04 +01:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( tmprgn, 0,93,98,98);
|
2005-03-25 18:11:04 +01:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("update rect is %d,%d - %d,%d\n",
|
2005-03-25 18:11:04 +01:00
|
|
|
rcu.left,rcu.top,rcu.right,rcu.bottom);
|
|
|
|
/* now with clipping region */
|
|
|
|
SelectClipRgn( hdc, clipping);
|
|
|
|
ScrollDC( hdc, -10, -5, &rc, &cliprc, hrgn, &rcu);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
|
|
|
/* create a region with what is expected */
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( exprgn, 39,10,49,74);
|
|
|
|
SetRectRgn( tmprgn, 80,79,90,85);
|
2005-03-25 18:11:04 +01:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( tmprgn, 10,85,90,90);
|
2005-03-25 18:11:04 +01:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("update rect is %d,%d - %d,%d\n",
|
2005-03-25 18:11:04 +01:00
|
|
|
rcu.left,rcu.top,rcu.right,rcu.bottom);
|
|
|
|
ReleaseDC( hwnd1, hdc);
|
2005-03-31 17:30:25 +02:00
|
|
|
|
2005-04-11 14:47:01 +02:00
|
|
|
/* test scrolling a window with an update region */
|
|
|
|
DestroyWindow( hwnd2);
|
|
|
|
ValidateRect( hwnd1, NULL);
|
|
|
|
SetRect( &rc, 40,40, 50,50);
|
|
|
|
InvalidateRect( hwnd1, &rc, 1);
|
|
|
|
GetClientRect( hwnd1, &rc);
|
|
|
|
cliprc=rc;
|
|
|
|
ScrollWindowEx( hwnd1, -10, 0, &rc, &cliprc, hrgn, &rcu,
|
|
|
|
SW_SCROLLCHILDREN | SW_INVALIDATE);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( exprgn, 88,0,98,98);
|
|
|
|
SetRectRgn( tmprgn, 30, 40, 50, 50);
|
2005-04-11 14:47:01 +02:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
|
|
|
|
|
2007-03-06 06:12:19 +01:00
|
|
|
/* clear an update region */
|
|
|
|
UpdateWindow( hwnd1 );
|
|
|
|
|
2007-02-13 14:38:06 +01:00
|
|
|
SetRect( &rc, 0,40, 100,60);
|
|
|
|
SetRect( &cliprc, 0,0, 100,100);
|
|
|
|
ScrollWindowEx( hwnd1, 0, -25, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
|
2007-03-06 06:12:19 +01:00
|
|
|
if (winetest_debug > 0) dump_region( hrgn );
|
|
|
|
SetRectRgn( exprgn, 0, 40, 98, 60 );
|
2007-02-13 14:38:06 +01:00
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region in excessive scroll\n");
|
|
|
|
|
2005-03-31 17:30:25 +02:00
|
|
|
/* now test ScrollWindowEx with a combination of
|
|
|
|
* WS_CLIPCHILDREN style and SW_SCROLLCHILDREN flag */
|
|
|
|
/* make hwnd2 the child of hwnd1 */
|
|
|
|
hwnd2 = CreateWindowExA(0, "static", NULL,
|
|
|
|
WS_CHILD| WS_VISIBLE | WS_BORDER ,
|
|
|
|
50, 50, 100, 100, hwnd1, 0, 0, NULL);
|
|
|
|
SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) & ~WS_CLIPSIBLINGS);
|
|
|
|
GetClientRect( hwnd1, &rc);
|
|
|
|
cliprc=rc;
|
|
|
|
|
|
|
|
/* WS_CLIPCHILDREN and SW_SCROLLCHILDREN */
|
|
|
|
SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) | WS_CLIPCHILDREN );
|
|
|
|
ValidateRect( hwnd1, NULL);
|
|
|
|
ValidateRect( hwnd2, NULL);
|
|
|
|
ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu,
|
|
|
|
SW_SCROLLCHILDREN | SW_INVALIDATE);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( exprgn, 88,0,98,88);
|
|
|
|
SetRectRgn( tmprgn, 0,88,98,98);
|
2005-03-31 17:30:25 +02:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
|
|
|
|
|
|
|
|
/* SW_SCROLLCHILDREN */
|
|
|
|
SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) & ~WS_CLIPCHILDREN );
|
|
|
|
ValidateRect( hwnd1, NULL);
|
|
|
|
ValidateRect( hwnd2, NULL);
|
|
|
|
ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_SCROLLCHILDREN | SW_INVALIDATE);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
|
|
|
/* expected region is the same as in previous test */
|
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
|
|
|
|
|
|
|
|
/* no SW_SCROLLCHILDREN */
|
|
|
|
SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) & ~WS_CLIPCHILDREN );
|
|
|
|
ValidateRect( hwnd1, NULL);
|
|
|
|
ValidateRect( hwnd2, NULL);
|
|
|
|
ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
|
|
|
/* expected region is the same as in previous test */
|
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
|
|
|
|
|
|
|
|
/* WS_CLIPCHILDREN and no SW_SCROLLCHILDREN */
|
|
|
|
SetWindowLong( hwnd1, GWL_STYLE, GetWindowLong( hwnd1, GWL_STYLE) | WS_CLIPCHILDREN );
|
|
|
|
ValidateRect( hwnd1, NULL);
|
|
|
|
ValidateRect( hwnd2, NULL);
|
|
|
|
ScrollWindowEx( hwnd1, -10, -10, &rc, &cliprc, hrgn, &rcu, SW_INVALIDATE);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( exprgn, 88,0,98,20);
|
|
|
|
SetRectRgn( tmprgn, 20,20,98,30);
|
2005-03-31 17:30:25 +02:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( tmprgn, 20,30,30,88);
|
2005-03-31 17:30:25 +02:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( tmprgn, 0,88,30,98);
|
2005-03-31 17:30:25 +02:00
|
|
|
CombineRgn( exprgn, exprgn, tmprgn, RGN_OR);
|
|
|
|
ok( EqualRgn( exprgn, hrgn), "wrong update region\n");
|
|
|
|
|
2005-03-25 18:11:04 +01:00
|
|
|
/* clean up */
|
|
|
|
DeleteObject( hrgn);
|
|
|
|
DeleteObject( exprgn);
|
|
|
|
DeleteObject( tmprgn);
|
|
|
|
DestroyWindow( hwnd1);
|
|
|
|
DestroyWindow( hwnd2);
|
|
|
|
}
|
|
|
|
|
2005-03-29 13:29:50 +02:00
|
|
|
/* couple of tests of return values of scrollbar functions
|
|
|
|
* called on a scrollbarless window */
|
2005-06-15 12:20:53 +02:00
|
|
|
static void test_scroll(void)
|
2005-03-29 13:29:50 +02:00
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
INT min, max;
|
|
|
|
SCROLLINFO si;
|
|
|
|
HWND hwnd = CreateWindowExA(0, "Static", "Wine test window",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_POPUP,
|
|
|
|
100, 100, 200, 200, 0, 0, 0, NULL);
|
|
|
|
/* horizontal */
|
|
|
|
ret = GetScrollRange( hwnd, SB_HORZ, &min, &max);
|
2008-11-26 12:04:51 +01:00
|
|
|
if (!ret) /* win9x */
|
|
|
|
{
|
|
|
|
win_skip( "GetScrollRange doesn't work\n" );
|
|
|
|
DestroyWindow( hwnd);
|
|
|
|
return;
|
|
|
|
}
|
2005-03-29 13:29:50 +02:00
|
|
|
ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
|
|
|
|
ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
|
|
|
|
si.cbSize = sizeof( si);
|
|
|
|
si.fMask = SIF_PAGE;
|
|
|
|
si.nPage = 0xdeadbeef;
|
|
|
|
ret = GetScrollInfo( hwnd, SB_HORZ, &si);
|
|
|
|
ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
|
|
|
|
ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
|
|
|
|
/* vertical */
|
|
|
|
ret = GetScrollRange( hwnd, SB_VERT, &min, &max);
|
|
|
|
ok( ret, "GetScrollRange returns FALSE\n");
|
|
|
|
ok( min == 0, "minimum scroll pos is %d (should be zero)\n", min);
|
|
|
|
ok( max == 0, "maximum scroll pos is %d (should be zero)\n", min);
|
|
|
|
si.cbSize = sizeof( si);
|
|
|
|
si.fMask = SIF_PAGE;
|
|
|
|
si.nPage = 0xdeadbeef;
|
|
|
|
ret = GetScrollInfo( hwnd, SB_VERT, &si);
|
|
|
|
ok( !ret, "GetScrollInfo returns %d (should be zero)\n", ret);
|
|
|
|
ok( si.nPage == 0xdeadbeef, "unexpected value for nPage is %d\n", si.nPage);
|
|
|
|
/* clean up */
|
|
|
|
DestroyWindow( hwnd);
|
|
|
|
}
|
|
|
|
|
2005-12-17 12:24:37 +01:00
|
|
|
static void test_scrolldc( HWND parent)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HRGN exprgn, tmprgn, hrgn;
|
|
|
|
RECT rc, rc2, rcu, cliprc;
|
|
|
|
HWND hwnd1;
|
|
|
|
COLORREF colr;
|
|
|
|
|
|
|
|
hrgn = CreateRectRgn(0,0,0,0);
|
2005-12-19 17:43:34 +01:00
|
|
|
tmprgn = CreateRectRgn(0,0,0,0);
|
|
|
|
exprgn = CreateRectRgn(0,0,0,0);
|
2005-12-17 12:24:37 +01:00
|
|
|
|
|
|
|
hwnd1 = CreateWindowExA(0, "static", NULL,
|
|
|
|
WS_CHILD| WS_VISIBLE,
|
|
|
|
25, 50, 100, 100, parent, 0, 0, NULL);
|
|
|
|
ShowWindow( parent, SW_SHOW);
|
|
|
|
UpdateWindow( parent);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-12-17 12:24:37 +01:00
|
|
|
GetClientRect( hwnd1, &rc);
|
|
|
|
hdc = GetDC( hwnd1);
|
|
|
|
/* paint the upper half of the window black */
|
|
|
|
rc2 = rc;
|
|
|
|
rc2.bottom = ( rc.top + rc.bottom) /2;
|
|
|
|
FillRect( hdc, &rc2, GetStockObject(BLACK_BRUSH));
|
|
|
|
/* clip region is the lower half */
|
|
|
|
cliprc=rc;
|
|
|
|
cliprc.top = (rc.top + rc.bottom) /2;
|
|
|
|
/* test whether scrolled pixels are properly clipped */
|
|
|
|
colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
|
2005-12-17 12:24:37 +01:00
|
|
|
/* this scroll should not cause any visible changes */
|
|
|
|
ScrollDC( hdc, 5, -20, &rc, &cliprc, hrgn, &rcu);
|
|
|
|
colr = GetPixel( hdc, (rc.left+rc.right)/2, ( rc.top + rc.bottom) /2 - 1);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok ( colr == 0, "pixel should be black, color is %08x\n", colr);
|
2005-12-19 09:53:04 +01:00
|
|
|
/* test with NULL clip rect */
|
2005-12-17 12:24:37 +01:00
|
|
|
ScrollDC( hdc, 20, -20, &rc, NULL, hrgn, &rcu);
|
|
|
|
/*FillRgn(hdc, hrgn, GetStockObject(WHITE_BRUSH));*/
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("update rect: %d,%d - %d,%d\n",
|
2005-12-17 12:24:37 +01:00
|
|
|
rcu.left, rcu.top, rcu.right, rcu.bottom);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
|
|
|
SetRect(&rc2, 0, 0, 100, 100);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(EqualRect(&rcu, &rc2), "rects do not match (%d,%d-%d,%d) / (%d,%d-%d,%d)\n",
|
2005-12-17 12:24:37 +01:00
|
|
|
rcu.left, rcu.top, rcu.right, rcu.bottom, rc2.left, rc2.top, rc2.right, rc2.bottom);
|
|
|
|
|
2005-12-19 17:43:34 +01:00
|
|
|
SetRectRgn( exprgn, 0, 0, 20, 80);
|
|
|
|
SetRectRgn( tmprgn, 0, 80, 100, 100);
|
2005-12-17 12:24:37 +01:00
|
|
|
CombineRgn(exprgn, exprgn, tmprgn, RGN_OR);
|
|
|
|
if (winetest_debug > 0) dump_region(exprgn);
|
|
|
|
ok(EqualRgn(exprgn, hrgn), "wrong update region\n");
|
2005-12-19 09:53:04 +01:00
|
|
|
/* test clip rect > scroll rect */
|
|
|
|
FillRect( hdc, &rc, GetStockObject(WHITE_BRUSH));
|
|
|
|
rc2=rc;
|
|
|
|
InflateRect( &rc2, -(rc.right-rc.left)/4, -(rc.bottom-rc.top)/4);
|
|
|
|
FillRect( hdc, &rc2, GetStockObject(BLACK_BRUSH));
|
|
|
|
ScrollDC( hdc, 10, 10, &rc2, &rc, hrgn, &rcu);
|
|
|
|
SetRectRgn( exprgn, 25, 25, 75, 35);
|
|
|
|
SetRectRgn( tmprgn, 25, 35, 35, 75);
|
|
|
|
CombineRgn(exprgn, exprgn, tmprgn, RGN_OR);
|
|
|
|
ok(EqualRgn(exprgn, hrgn), "wrong update region\n");
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("update rect: %d,%d - %d,%d\n",
|
2005-12-19 09:53:04 +01:00
|
|
|
rcu.left, rcu.top, rcu.right, rcu.bottom);
|
|
|
|
if (winetest_debug > 0) dump_region(hrgn);
|
2005-12-17 12:24:37 +01:00
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
DeleteObject(hrgn);
|
|
|
|
DeleteObject(exprgn);
|
|
|
|
DeleteObject(tmprgn);
|
|
|
|
DestroyWindow(hwnd1);
|
|
|
|
}
|
|
|
|
|
2005-06-15 12:20:53 +02:00
|
|
|
static void test_params(void)
|
2005-05-14 20:49:19 +02:00
|
|
|
{
|
2005-08-08 14:13:08 +02:00
|
|
|
HWND hwnd;
|
2005-05-14 20:49:19 +02:00
|
|
|
INT rc;
|
|
|
|
|
|
|
|
/* Just a param check */
|
2008-11-20 11:42:35 +01:00
|
|
|
if (pGetMonitorInfoA)
|
|
|
|
{
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
rc = GetWindowText(hwndMain2, NULL, 1024);
|
|
|
|
ok( rc==0, "GetWindowText: rc=%d err=%d\n",rc,GetLastError());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Skips actually on Win95 and NT4 */
|
|
|
|
win_skip("Test would crash on Win95\n");
|
|
|
|
}
|
2005-08-08 14:13:08 +02:00
|
|
|
|
2005-08-09 12:22:45 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2005-08-08 14:13:08 +02:00
|
|
|
hwnd=CreateWindow("LISTBOX", "TestList",
|
|
|
|
(LBS_STANDARD & ~LBS_SORT),
|
|
|
|
0, 0, 100, 100,
|
|
|
|
NULL, (HMENU)1, NULL, 0);
|
2005-08-09 12:22:45 +02:00
|
|
|
|
2009-02-09 14:20:17 +01:00
|
|
|
ok(!hwnd || broken(hwnd != NULL), /* w2k3 sp2 */
|
|
|
|
"CreateWindow with invalid menu handle should fail\n");
|
|
|
|
if (!hwnd)
|
|
|
|
ok(GetLastError() == ERROR_INVALID_MENU_HANDLE || /* NT */
|
|
|
|
GetLastError() == 0xdeadbeef, /* Win9x */
|
|
|
|
"wrong last error value %d\n", GetLastError());
|
2005-05-14 20:49:19 +02:00
|
|
|
}
|
2005-03-29 13:29:50 +02:00
|
|
|
|
2005-05-24 11:51:20 +02:00
|
|
|
static void test_AWRwindow(LPCSTR class, LONG style, LONG exStyle, BOOL menu)
|
|
|
|
{
|
|
|
|
HWND hwnd = 0;
|
|
|
|
|
|
|
|
hwnd = CreateWindowEx(exStyle, class, class, style,
|
|
|
|
110, 100,
|
|
|
|
225, 200,
|
|
|
|
0,
|
|
|
|
menu ? hmenu : 0,
|
|
|
|
0, 0);
|
|
|
|
if (!hwnd) {
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("Failed to create window class=%s, style=0x%08x, exStyle=0x%08x\n", class, style, exStyle);
|
2005-05-24 11:51:20 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
|
|
|
|
test_nonclient_area(hwnd);
|
|
|
|
|
|
|
|
SetMenu(hwnd, 0);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL AWR_init(void)
|
|
|
|
{
|
|
|
|
WNDCLASS class;
|
|
|
|
|
|
|
|
class.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
class.lpfnWndProc = DefWindowProcA;
|
|
|
|
class.cbClsExtra = 0;
|
|
|
|
class.cbWndExtra = 0;
|
|
|
|
class.hInstance = 0;
|
|
|
|
class.hIcon = LoadIcon (0, IDI_APPLICATION);
|
|
|
|
class.hCursor = LoadCursor (0, IDC_ARROW);
|
|
|
|
class.hbrBackground = 0;
|
|
|
|
class.lpszMenuName = 0;
|
|
|
|
class.lpszClassName = szAWRClass;
|
|
|
|
|
|
|
|
if (!RegisterClass (&class)) {
|
|
|
|
ok(FALSE, "RegisterClass failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
if (!hmenu)
|
|
|
|
return FALSE;
|
|
|
|
ok(hmenu != 0, "Failed to create menu\n");
|
|
|
|
ok(AppendMenu(hmenu, MF_STRING, 1, "Test!"), "Failed to create menu item\n");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_AWR_window_size(BOOL menu)
|
|
|
|
{
|
|
|
|
LONG styles[] = {
|
|
|
|
WS_POPUP,
|
|
|
|
WS_MAXIMIZE, WS_BORDER, WS_DLGFRAME,
|
|
|
|
WS_SYSMENU,
|
|
|
|
WS_THICKFRAME,
|
|
|
|
WS_MINIMIZEBOX, WS_MAXIMIZEBOX,
|
|
|
|
WS_HSCROLL, WS_VSCROLL
|
|
|
|
};
|
|
|
|
LONG exStyles[] = {
|
|
|
|
WS_EX_CLIENTEDGE,
|
|
|
|
WS_EX_TOOLWINDOW, WS_EX_WINDOWEDGE,
|
|
|
|
WS_EX_APPWINDOW,
|
|
|
|
#if 0
|
|
|
|
/* These styles have problems on (at least) WinXP (SP2) and Wine */
|
|
|
|
WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_STATICEDGE,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* A exhaustive check of all the styles takes too long
|
|
|
|
* so just do a (hopefully representative) sample
|
|
|
|
*/
|
|
|
|
for (i = 0; i < COUNTOF(styles); ++i)
|
|
|
|
test_AWRwindow(szAWRClass, styles[i], 0, menu);
|
|
|
|
for (i = 0; i < COUNTOF(exStyles); ++i) {
|
|
|
|
test_AWRwindow(szAWRClass, WS_POPUP, exStyles[i], menu);
|
|
|
|
test_AWRwindow(szAWRClass, WS_THICKFRAME, exStyles[i], menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#undef COUNTOF
|
|
|
|
|
|
|
|
#define SHOWSYSMETRIC(SM) trace(#SM "=%d\n", GetSystemMetrics(SM))
|
|
|
|
|
2005-06-17 12:11:37 +02:00
|
|
|
static void test_AdjustWindowRect(void)
|
2005-05-24 11:51:20 +02:00
|
|
|
{
|
|
|
|
if (!AWR_init())
|
|
|
|
return;
|
|
|
|
|
|
|
|
SHOWSYSMETRIC(SM_CYCAPTION);
|
|
|
|
SHOWSYSMETRIC(SM_CYSMCAPTION);
|
|
|
|
SHOWSYSMETRIC(SM_CYMENU);
|
|
|
|
SHOWSYSMETRIC(SM_CXEDGE);
|
|
|
|
SHOWSYSMETRIC(SM_CYEDGE);
|
|
|
|
SHOWSYSMETRIC(SM_CXVSCROLL);
|
|
|
|
SHOWSYSMETRIC(SM_CYHSCROLL);
|
|
|
|
SHOWSYSMETRIC(SM_CXFRAME);
|
|
|
|
SHOWSYSMETRIC(SM_CYFRAME);
|
|
|
|
SHOWSYSMETRIC(SM_CXDLGFRAME);
|
|
|
|
SHOWSYSMETRIC(SM_CYDLGFRAME);
|
|
|
|
SHOWSYSMETRIC(SM_CXBORDER);
|
|
|
|
SHOWSYSMETRIC(SM_CYBORDER);
|
|
|
|
|
|
|
|
test_AWR_window_size(FALSE);
|
|
|
|
test_AWR_window_size(TRUE);
|
|
|
|
|
|
|
|
DestroyMenu(hmenu);
|
|
|
|
}
|
|
|
|
#undef SHOWSYSMETRIC
|
|
|
|
|
2005-05-31 15:39:24 +02:00
|
|
|
|
|
|
|
/* Global variables to trigger exit from loop */
|
|
|
|
static int redrawComplete, WMPAINT_count;
|
|
|
|
|
|
|
|
static LRESULT WINAPI redraw_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_PAINT:
|
|
|
|
trace("doing WM_PAINT %d\n", WMPAINT_count);
|
|
|
|
WMPAINT_count++;
|
|
|
|
if (WMPAINT_count > 10 && redrawComplete == 0) {
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
BeginPaint(hwnd, &ps);
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure we exit from RedrawNow regardless of invalidated area */
|
2005-07-05 12:59:46 +02:00
|
|
|
static void test_redrawnow(void)
|
|
|
|
{
|
2005-05-31 15:39:24 +02:00
|
|
|
WNDCLASSA cls;
|
|
|
|
HWND hwndMain;
|
|
|
|
|
|
|
|
cls.style = CS_DBLCLKS;
|
|
|
|
cls.lpfnWndProc = redraw_window_procA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2005-05-31 15:39:24 +02:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "RedrawWindowClass";
|
|
|
|
|
|
|
|
if(!RegisterClassA(&cls)) {
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("Register failed %d\n", GetLastError());
|
2005-05-31 15:39:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hwndMain = CreateWindowA("RedrawWindowClass", "Main Window", WS_OVERLAPPEDWINDOW,
|
|
|
|
CW_USEDEFAULT, 0, 100, 100, NULL, NULL, 0, NULL);
|
|
|
|
|
|
|
|
ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
|
|
|
|
ShowWindow(hwndMain, SW_SHOW);
|
|
|
|
ok( WMPAINT_count == 0, "Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
|
|
|
|
RedrawWindow(hwndMain, NULL,NULL,RDW_UPDATENOW | RDW_ALLCHILDREN);
|
2009-02-20 16:56:27 +01:00
|
|
|
ok( WMPAINT_count == 1 || broken(WMPAINT_count == 0), /* sometimes on win9x */
|
|
|
|
"Multiple unexpected WM_PAINT calls %d\n", WMPAINT_count);
|
2005-05-31 15:39:24 +02:00
|
|
|
redrawComplete = TRUE;
|
|
|
|
ok( WMPAINT_count < 10, "RedrawWindow (RDW_UPDATENOW) never completed (%d)\n", WMPAINT_count);
|
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
DestroyWindow( hwndMain);
|
|
|
|
}
|
|
|
|
|
2005-08-02 11:56:25 +02:00
|
|
|
struct parentdc_stat {
|
|
|
|
RECT client;
|
|
|
|
RECT clip;
|
|
|
|
RECT paint;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct parentdc_test {
|
|
|
|
struct parentdc_stat main, main_todo;
|
|
|
|
struct parentdc_stat child1, child1_todo;
|
|
|
|
struct parentdc_stat child2, child2_todo;
|
|
|
|
};
|
|
|
|
|
|
|
|
static LRESULT WINAPI parentdc_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
2005-09-09 17:20:04 +02:00
|
|
|
struct parentdc_stat *t = (struct parentdc_stat *)GetWindowLongPtrA(hwnd, GWLP_USERDATA);
|
2005-08-02 11:56:25 +02:00
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_PAINT:
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
CopyRect(&t->client, &rc);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("WM_PAINT: hwnd %p, client rect (%d,%d)-(%d,%d), window rect (%d,%d)-(%d,%d)\n", hwnd,
|
|
|
|
t->client.left, t->client.top, t->client.right, t->client.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2005-08-02 11:56:25 +02:00
|
|
|
BeginPaint(hwnd, &ps);
|
|
|
|
CopyRect(&t->paint, &ps.rcPaint);
|
|
|
|
GetClipBox(ps.hdc, &rc);
|
|
|
|
CopyRect(&t->clip, &rc);
|
2009-01-25 17:29:32 +01:00
|
|
|
trace("clip rect (%d,%d)-(%d,%d), paint rect (%d,%d)-(%d,%d)\n",
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom,
|
|
|
|
ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
|
2005-08-02 11:56:25 +02:00
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zero_parentdc_stat(struct parentdc_stat *t)
|
|
|
|
{
|
|
|
|
SetRectEmpty(&t->client);
|
|
|
|
SetRectEmpty(&t->clip);
|
|
|
|
SetRectEmpty(&t->paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void zero_parentdc_test(struct parentdc_test *t)
|
|
|
|
{
|
|
|
|
zero_parentdc_stat(&t->main);
|
|
|
|
zero_parentdc_stat(&t->child1);
|
|
|
|
zero_parentdc_stat(&t->child2);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define parentdc_field_ok(t, w, r, f, got) \
|
|
|
|
ok (t.w.r.f==got.w.r.f, "window " #w ", rect " #r ", field " #f \
|
2006-10-07 21:45:11 +02:00
|
|
|
": expected %d, got %d\n", \
|
2005-08-02 11:56:25 +02:00
|
|
|
t.w.r.f, got.w.r.f)
|
|
|
|
|
|
|
|
#define parentdc_todo_field_ok(t, w, r, f, got) \
|
|
|
|
if (t.w##_todo.r.f) todo_wine { parentdc_field_ok(t, w, r, f, got); } \
|
|
|
|
else parentdc_field_ok(t, w, r, f, got)
|
|
|
|
|
|
|
|
#define parentdc_rect_ok(t, w, r, got) \
|
|
|
|
parentdc_todo_field_ok(t, w, r, left, got); \
|
|
|
|
parentdc_todo_field_ok(t, w, r, top, got); \
|
|
|
|
parentdc_todo_field_ok(t, w, r, right, got); \
|
|
|
|
parentdc_todo_field_ok(t, w, r, bottom, got);
|
|
|
|
|
|
|
|
#define parentdc_win_ok(t, w, got) \
|
|
|
|
parentdc_rect_ok(t, w, client, got); \
|
|
|
|
parentdc_rect_ok(t, w, clip, got); \
|
|
|
|
parentdc_rect_ok(t, w, paint, got);
|
|
|
|
|
|
|
|
#define parentdc_ok(t, got) \
|
|
|
|
parentdc_win_ok(t, main, got); \
|
|
|
|
parentdc_win_ok(t, child1, got); \
|
|
|
|
parentdc_win_ok(t, child2, got);
|
|
|
|
|
|
|
|
static void test_csparentdc(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA clsMain, cls;
|
|
|
|
HWND hwndMain, hwnd1, hwnd2;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
struct parentdc_test test_answer;
|
|
|
|
|
|
|
|
#define nothing_todo {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
|
|
|
|
const struct parentdc_test test1 =
|
|
|
|
{
|
|
|
|
{{0, 0, 150, 150}, {0, 0, 150, 150}, {0, 0, 150, 150}}, nothing_todo,
|
|
|
|
{{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
|
|
|
|
{{0, 0, 40, 40}, {-40, -40, 110, 110}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct parentdc_test test2 =
|
|
|
|
{
|
|
|
|
{{0, 0, 150, 150}, {0, 0, 50, 50}, {0, 0, 50, 50}}, nothing_todo,
|
|
|
|
{{0, 0, 40, 40}, {-20, -20, 30, 30}, {0, 0, 30, 30}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
|
|
|
|
{{0, 0, 40, 40}, {-40, -40, 10, 10}, {0, 0, 10, 10}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct parentdc_test test3 =
|
|
|
|
{
|
|
|
|
{{0, 0, 150, 150}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
|
|
|
|
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
|
|
|
|
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct parentdc_test test4 =
|
|
|
|
{
|
|
|
|
{{0, 0, 150, 150}, {40, 40, 50, 50}, {40, 40, 50, 50}}, nothing_todo,
|
|
|
|
{{0, 0, 40, 40}, {20, 20, 30, 30}, {20, 20, 30, 30}}, nothing_todo,
|
|
|
|
{{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct parentdc_test test5 =
|
|
|
|
{
|
|
|
|
{{0, 0, 150, 150}, {20, 20, 60, 60}, {20, 20, 60, 60}}, nothing_todo,
|
|
|
|
{{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
|
|
|
|
{{0, 0, 40, 40}, {-20, -20, 20, 20}, {0, 0, 20, 20}}, {{0, 0, 0, 0}, {1, 1, 0, 0}, {0, 0, 0, 0}},
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct parentdc_test test6 =
|
|
|
|
{
|
|
|
|
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
|
|
|
|
{{0, 0, 40, 40}, {0, 0, 10, 10}, {0, 0, 10, 10}}, nothing_todo,
|
|
|
|
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct parentdc_test test7 =
|
|
|
|
{
|
|
|
|
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
|
|
|
|
{{0, 0, 40, 40}, {-20, -20, 130, 130}, {0, 0, 40, 40}}, {{0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
|
|
|
|
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, nothing_todo,
|
|
|
|
};
|
|
|
|
#undef nothing_todo
|
|
|
|
|
|
|
|
clsMain.style = CS_DBLCLKS;
|
|
|
|
clsMain.lpfnWndProc = parentdc_window_procA;
|
|
|
|
clsMain.cbClsExtra = 0;
|
|
|
|
clsMain.cbWndExtra = 0;
|
|
|
|
clsMain.hInstance = GetModuleHandleA(0);
|
|
|
|
clsMain.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
clsMain.hCursor = LoadCursorA(0, IDC_ARROW);
|
2005-08-02 11:56:25 +02:00
|
|
|
clsMain.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
clsMain.lpszMenuName = NULL;
|
|
|
|
clsMain.lpszClassName = "ParentDcMainWindowClass";
|
|
|
|
|
|
|
|
if(!RegisterClassA(&clsMain)) {
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("Register failed %d\n", GetLastError());
|
2005-08-02 11:56:25 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.style = CS_DBLCLKS | CS_PARENTDC;
|
|
|
|
cls.lpfnWndProc = parentdc_window_procA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2005-08-02 11:56:25 +02:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "ParentDcWindowClass";
|
|
|
|
|
|
|
|
if(!RegisterClassA(&cls)) {
|
2006-10-07 21:45:11 +02:00
|
|
|
trace("Register failed %d\n", GetLastError());
|
2005-08-02 11:56:25 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetRect(&rc, 0, 0, 150, 150);
|
|
|
|
AdjustWindowRectEx(&rc, WS_OVERLAPPEDWINDOW, FALSE, 0);
|
|
|
|
hwndMain = CreateWindowA("ParentDcMainWindowClass", "Main Window", WS_OVERLAPPEDWINDOW,
|
|
|
|
CW_USEDEFAULT, 0, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, 0, NULL);
|
2005-09-09 17:20:04 +02:00
|
|
|
SetWindowLongPtrA(hwndMain, GWLP_USERDATA, (DWORD_PTR)&test_answer.main);
|
2005-08-02 11:56:25 +02:00
|
|
|
hwnd1 = CreateWindowA("ParentDcWindowClass", "Child Window 1", WS_CHILD,
|
|
|
|
20, 20, 40, 40, hwndMain, NULL, 0, NULL);
|
2005-09-09 17:20:04 +02:00
|
|
|
SetWindowLongPtrA(hwnd1, GWLP_USERDATA, (DWORD_PTR)&test_answer.child1);
|
2005-08-02 11:56:25 +02:00
|
|
|
hwnd2 = CreateWindowA("ParentDcWindowClass", "Child Window 2", WS_CHILD,
|
|
|
|
40, 40, 40, 40, hwndMain, NULL, 0, NULL);
|
2005-09-09 17:20:04 +02:00
|
|
|
SetWindowLongPtrA(hwnd2, GWLP_USERDATA, (DWORD_PTR)&test_answer.child2);
|
2005-08-02 11:56:25 +02:00
|
|
|
ShowWindow(hwndMain, SW_SHOW);
|
|
|
|
ShowWindow(hwnd1, SW_SHOW);
|
|
|
|
ShowWindow(hwnd2, SW_SHOW);
|
2009-01-23 13:13:54 +01:00
|
|
|
SetWindowPos(hwndMain, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
|
|
|
|
zero_parentdc_test(&test_answer);
|
|
|
|
InvalidateRect(hwndMain, NULL, TRUE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
parentdc_ok(test1, test_answer);
|
|
|
|
|
|
|
|
zero_parentdc_test(&test_answer);
|
|
|
|
SetRect(&rc, 0, 0, 50, 50);
|
|
|
|
InvalidateRect(hwndMain, &rc, TRUE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
parentdc_ok(test2, test_answer);
|
|
|
|
|
|
|
|
zero_parentdc_test(&test_answer);
|
|
|
|
SetRect(&rc, 0, 0, 10, 10);
|
|
|
|
InvalidateRect(hwndMain, &rc, TRUE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
parentdc_ok(test3, test_answer);
|
|
|
|
|
|
|
|
zero_parentdc_test(&test_answer);
|
|
|
|
SetRect(&rc, 40, 40, 50, 50);
|
|
|
|
InvalidateRect(hwndMain, &rc, TRUE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
parentdc_ok(test4, test_answer);
|
|
|
|
|
|
|
|
zero_parentdc_test(&test_answer);
|
|
|
|
SetRect(&rc, 20, 20, 60, 60);
|
|
|
|
InvalidateRect(hwndMain, &rc, TRUE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
parentdc_ok(test5, test_answer);
|
|
|
|
|
|
|
|
zero_parentdc_test(&test_answer);
|
|
|
|
SetRect(&rc, 0, 0, 10, 10);
|
|
|
|
InvalidateRect(hwnd1, &rc, TRUE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
parentdc_ok(test6, test_answer);
|
|
|
|
|
|
|
|
zero_parentdc_test(&test_answer);
|
|
|
|
SetRect(&rc, -5, -5, 65, 65);
|
|
|
|
InvalidateRect(hwnd1, &rc, TRUE);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2005-08-02 11:56:25 +02:00
|
|
|
parentdc_ok(test7, test_answer);
|
|
|
|
|
|
|
|
DestroyWindow(hwndMain);
|
|
|
|
DestroyWindow(hwnd1);
|
|
|
|
DestroyWindow(hwnd2);
|
|
|
|
}
|
|
|
|
|
2008-02-14 09:35:03 +01:00
|
|
|
static LRESULT WINAPI def_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT WINAPI def_window_procW(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
return DefWindowProcW(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
2005-07-05 12:59:46 +02:00
|
|
|
static void test_IsWindowUnicode(void)
|
|
|
|
{
|
|
|
|
static const char ansi_class_nameA[] = "ansi class name";
|
|
|
|
static const WCHAR ansi_class_nameW[] = {'a','n','s','i',' ','c','l','a','s','s',' ','n','a','m','e',0};
|
|
|
|
static const char unicode_class_nameA[] = "unicode class name";
|
|
|
|
static const WCHAR unicode_class_nameW[] = {'u','n','i','c','o','d','e',' ','c','l','a','s','s',' ','n','a','m','e',0};
|
|
|
|
WNDCLASSA classA;
|
|
|
|
WNDCLASSW classW;
|
|
|
|
HWND hwnd;
|
|
|
|
|
|
|
|
memset(&classW, 0, sizeof(classW));
|
|
|
|
classW.hInstance = GetModuleHandleA(0);
|
2008-02-14 09:35:03 +01:00
|
|
|
classW.lpfnWndProc = def_window_procW;
|
2005-07-05 12:59:46 +02:00
|
|
|
classW.lpszClassName = unicode_class_nameW;
|
2008-02-14 09:35:03 +01:00
|
|
|
if (!RegisterClassW(&classW)) return; /* this catches Win9x as well */
|
2005-07-05 12:59:46 +02:00
|
|
|
|
|
|
|
memset(&classA, 0, sizeof(classA));
|
|
|
|
classA.hInstance = GetModuleHandleA(0);
|
2008-02-14 09:35:03 +01:00
|
|
|
classA.lpfnWndProc = def_window_procA;
|
2005-07-05 12:59:46 +02:00
|
|
|
classA.lpszClassName = ansi_class_nameA;
|
|
|
|
assert(RegisterClassA(&classA));
|
|
|
|
|
|
|
|
/* unicode class: window proc */
|
|
|
|
hwnd = CreateWindowExW(0, unicode_class_nameW, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procA);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procW);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, unicode_class_nameA, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procA);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procW);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
/* ansi class: window proc */
|
|
|
|
hwnd = CreateWindowExW(0, ansi_class_nameW, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procW);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procA);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, ansi_class_nameA, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procW);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetWindowLongPtrA(hwnd, GWLP_WNDPROC, (ULONG_PTR)def_window_procA);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
/* unicode class: class proc */
|
|
|
|
hwnd = CreateWindowExW(0, unicode_class_nameW, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetClassLongPtrA(hwnd, GCLP_WNDPROC, (ULONG_PTR)def_window_procA);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
|
|
|
/* do not restore class window proc back to unicode */
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, unicode_class_nameA, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetClassLongPtrW(hwnd, GCLP_WNDPROC, (ULONG_PTR)def_window_procW);
|
2005-07-06 17:46:47 +02:00
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
2005-07-05 12:59:46 +02:00
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
/* ansi class: class proc */
|
|
|
|
hwnd = CreateWindowExW(0, ansi_class_nameW, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetClassLongPtrW(hwnd, GCLP_WNDPROC, (ULONG_PTR)def_window_procW);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(!IsWindowUnicode(hwnd), "IsWindowUnicode expected to return FALSE\n");
|
|
|
|
/* do not restore class window proc back to ansi */
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, ansi_class_nameA, NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, GetDesktopWindow(), 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
2008-02-14 09:35:03 +01:00
|
|
|
SetClassLongPtrA(hwnd, GCLP_WNDPROC, (ULONG_PTR)def_window_procA);
|
2005-07-05 12:59:46 +02:00
|
|
|
ok(IsWindowUnicode(hwnd), "IsWindowUnicode expected to return TRUE\n");
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
2005-05-31 15:39:24 +02:00
|
|
|
|
2007-04-08 12:28:05 +02:00
|
|
|
static LRESULT CALLBACK minmax_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
|
|
|
{
|
|
|
|
MINMAXINFO *minmax;
|
|
|
|
|
|
|
|
if (msg != WM_GETMINMAXINFO)
|
|
|
|
return DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
|
|
|
|
minmax = (MINMAXINFO *)lp;
|
|
|
|
|
|
|
|
if ((GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD))
|
|
|
|
{
|
|
|
|
minmax->ptReserved.x = 0;
|
|
|
|
minmax->ptReserved.y = 0;
|
|
|
|
minmax->ptMaxSize.x = 400;
|
|
|
|
minmax->ptMaxSize.y = 400;
|
|
|
|
minmax->ptMaxPosition.x = 300;
|
|
|
|
minmax->ptMaxPosition.y = 300;
|
|
|
|
minmax->ptMaxTrackSize.x = 200;
|
|
|
|
minmax->ptMaxTrackSize.y = 200;
|
|
|
|
minmax->ptMinTrackSize.x = 100;
|
|
|
|
minmax->ptMinTrackSize.y = 100;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-01-22 10:16:19 +01:00
|
|
|
static int expected_cx, expected_cy;
|
2008-09-17 14:05:06 +02:00
|
|
|
static RECT expected_rect, broken_rect;
|
2008-01-22 10:16:19 +01:00
|
|
|
|
|
|
|
static LRESULT CALLBACK winsizes_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
|
|
|
{
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
ok( !rect.left && !rect.top && !rect.right && !rect.bottom,
|
|
|
|
"wrong rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
|
|
|
return DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
}
|
|
|
|
case WM_NCCREATE:
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
CREATESTRUCTA *cs = (CREATESTRUCTA *)lp;
|
|
|
|
RECT rect;
|
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
trace( "hwnd %p msg %x size %dx%d rect %d,%d-%d,%d\n",
|
|
|
|
hwnd, msg, cs->cx, cs->cy, rect.left, rect.top, rect.right, rect.bottom );
|
2008-11-26 12:04:51 +01:00
|
|
|
ok( cs->cx == expected_cx || broken(cs->cx == (short)expected_cx),
|
|
|
|
"wrong x size %d/%d\n", cs->cx, expected_cx );
|
|
|
|
ok( cs->cy == expected_cy || broken(cs->cy == (short)expected_cy),
|
|
|
|
"wrong y size %d/%d\n", cs->cy, expected_cy );
|
2008-09-17 14:05:06 +02:00
|
|
|
ok( (rect.right - rect.left == expected_rect.right - expected_rect.left &&
|
|
|
|
rect.bottom - rect.top == expected_rect.bottom - expected_rect.top) ||
|
|
|
|
broken( rect.right - rect.left == broken_rect.right - broken_rect.left &&
|
2008-11-26 12:04:51 +01:00
|
|
|
rect.bottom - rect.top == broken_rect.bottom - broken_rect.top) ||
|
|
|
|
broken( rect.right - rect.left == (short)broken_rect.right - (short)broken_rect.left &&
|
|
|
|
rect.bottom - rect.top == (short)broken_rect.bottom - (short)broken_rect.top),
|
2008-01-22 10:16:19 +01:00
|
|
|
"wrong rect %d,%d-%d,%d / %d,%d-%d,%d\n",
|
|
|
|
rect.left, rect.top, rect.right, rect.bottom,
|
|
|
|
expected_rect.left, expected_rect.top, expected_rect.right, expected_rect.bottom );
|
|
|
|
return DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
}
|
2008-05-08 11:12:03 +02:00
|
|
|
case WM_NCCALCSIZE:
|
|
|
|
{
|
|
|
|
RECT rect, *r = (RECT *)lp;
|
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
ok( !memcmp( &rect, r, sizeof(rect) ),
|
|
|
|
"passed rect %d,%d-%d,%d doesn't match window rect %d,%d-%d,%d\n",
|
|
|
|
r->left, r->top, r->right, r->bottom, rect.left, rect.top, rect.right, rect.bottom );
|
|
|
|
return DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
}
|
2008-01-22 10:16:19 +01:00
|
|
|
default:
|
|
|
|
return DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-09 16:13:50 +02:00
|
|
|
static void test_CreateWindow(void)
|
|
|
|
{
|
2007-04-08 12:28:05 +02:00
|
|
|
WNDCLASS cls;
|
2006-06-09 16:13:50 +02:00
|
|
|
HWND hwnd, parent;
|
|
|
|
HMENU hmenu;
|
2007-01-27 13:50:09 +01:00
|
|
|
RECT rc, rc_minmax;
|
|
|
|
MINMAXINFO minmax;
|
2006-06-09 16:13:50 +02:00
|
|
|
|
|
|
|
#define expect_menu(window, menu) \
|
|
|
|
SetLastError(0xdeadbeef); \
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(GetMenu(window) == (HMENU)menu, "GetMenu error %d\n", GetLastError())
|
2006-06-09 16:13:50 +02:00
|
|
|
|
|
|
|
#define expect_style(window, style)\
|
2009-01-03 20:16:33 +01:00
|
|
|
ok((ULONG)GetWindowLong(window, GWL_STYLE) == (style), "expected style %x != %x\n", (LONG)(style), GetWindowLong(window, GWL_STYLE))
|
2006-06-09 16:13:50 +02:00
|
|
|
|
|
|
|
#define expect_ex_style(window, ex_style)\
|
2009-01-03 20:16:33 +01:00
|
|
|
ok((ULONG)GetWindowLong(window, GWL_EXSTYLE) == (ex_style), "expected ex_style %x != %x\n", (LONG)(ex_style), GetWindowLong(window, GWL_EXSTYLE))
|
2006-06-09 16:13:50 +02:00
|
|
|
|
2008-11-21 08:59:09 +01:00
|
|
|
#define expect_gle_broken_9x(gle)\
|
|
|
|
ok(GetLastError() == gle ||\
|
|
|
|
broken(GetLastError() == 0xdeadbeef),\
|
|
|
|
"IsMenu set error %d\n", GetLastError())
|
|
|
|
|
2006-06-09 16:13:50 +02:00
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
parent = GetDesktopWindow();
|
|
|
|
assert(parent != 0);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(IsMenu(hmenu), "IsMenu error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
|
2006-10-30 09:41:24 +01:00
|
|
|
/* WS_CHILD */
|
2006-06-09 16:13:50 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, 1);
|
|
|
|
expect_style(hwnd, WS_CHILD);
|
|
|
|
expect_ex_style(hwnd, WS_EX_APPWINDOW);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, 1);
|
|
|
|
expect_style(hwnd, WS_CHILD | WS_CAPTION);
|
|
|
|
expect_ex_style(hwnd, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, 1);
|
|
|
|
expect_style(hwnd, WS_CHILD);
|
|
|
|
expect_ex_style(hwnd, 0);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, 1);
|
|
|
|
expect_style(hwnd, WS_CHILD | WS_CAPTION);
|
|
|
|
expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
2006-10-30 09:41:24 +01:00
|
|
|
/* WS_POPUP */
|
2006-06-09 16:13:50 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP,
|
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, hmenu);
|
|
|
|
expect_style(hwnd, WS_POPUP | WS_CLIPSIBLINGS);
|
|
|
|
expect_ex_style(hwnd, WS_EX_APPWINDOW);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-06-09 16:13:50 +02:00
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_POPUP | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, hmenu);
|
|
|
|
expect_style(hwnd, WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS);
|
|
|
|
expect_ex_style(hwnd, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-06-09 16:13:50 +02:00
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-10-30 09:41:24 +01:00
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP,
|
2006-06-09 16:13:50 +02:00
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, hmenu);
|
|
|
|
expect_style(hwnd, WS_POPUP | WS_CLIPSIBLINGS);
|
2006-10-30 09:41:24 +01:00
|
|
|
expect_ex_style(hwnd, 0);
|
2006-06-09 16:13:50 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-06-09 16:13:50 +02:00
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_POPUP | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, hmenu);
|
|
|
|
expect_style(hwnd, WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS);
|
|
|
|
expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-06-09 16:13:50 +02:00
|
|
|
|
2006-10-30 09:41:24 +01:00
|
|
|
/* WS_CHILD | WS_POPUP */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2008-11-21 08:59:09 +01:00
|
|
|
ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
|
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
|
|
|
if (hwnd)
|
|
|
|
DestroyWindow(hwnd);
|
2006-10-30 09:41:24 +01:00
|
|
|
|
2006-06-09 16:13:50 +02:00
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
SetLastError(0xdeadbeef);
|
2006-10-30 09:41:24 +01:00
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP,
|
2006-06-09 16:13:50 +02:00
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_menu(hwnd, hmenu);
|
2006-10-30 09:41:24 +01:00
|
|
|
expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CLIPSIBLINGS);
|
|
|
|
expect_ex_style(hwnd, WS_EX_APPWINDOW);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-10-30 09:41:24 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2008-11-21 08:59:09 +01:00
|
|
|
ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
|
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
|
|
|
if (hwnd)
|
|
|
|
DestroyWindow(hwnd);
|
2006-10-30 09:41:24 +01:00
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(WS_EX_APPWINDOW, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
|
|
|
expect_menu(hwnd, hmenu);
|
|
|
|
expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS);
|
|
|
|
expect_ex_style(hwnd, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-10-30 09:41:24 +01:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2008-11-21 08:59:09 +01:00
|
|
|
ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
|
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
|
|
|
if (hwnd)
|
|
|
|
DestroyWindow(hwnd);
|
2006-10-30 09:41:24 +01:00
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP,
|
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
|
|
|
expect_menu(hwnd, hmenu);
|
|
|
|
expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CLIPSIBLINGS);
|
2006-06-09 16:13:50 +02:00
|
|
|
expect_ex_style(hwnd, 0);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-06-09 16:13:50 +02:00
|
|
|
|
2006-10-30 09:41:24 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, (HMENU)1, 0, NULL);
|
2008-11-21 08:59:09 +01:00
|
|
|
ok(!hwnd || broken(hwnd != 0 /* Win9x */), "CreateWindowEx should fail\n");
|
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
|
|
|
if (hwnd)
|
|
|
|
DestroyWindow(hwnd);
|
2006-10-30 09:41:24 +01:00
|
|
|
|
|
|
|
hmenu = CreateMenu();
|
|
|
|
assert(hmenu != 0);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_POPUP | WS_CAPTION,
|
|
|
|
0, 0, 100, 100, parent, hmenu, 0, NULL);
|
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
|
|
|
expect_menu(hwnd, hmenu);
|
|
|
|
expect_style(hwnd, WS_CHILD | WS_POPUP | WS_CAPTION | WS_CLIPSIBLINGS);
|
|
|
|
expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(!IsMenu(hmenu), "IsMenu should fail\n");
|
2008-11-21 08:59:09 +01:00
|
|
|
expect_gle_broken_9x(ERROR_INVALID_MENU_HANDLE);
|
2006-10-30 09:41:24 +01:00
|
|
|
|
2007-01-27 13:50:09 +01:00
|
|
|
/* test child window sizing */
|
2007-04-08 12:28:05 +02:00
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = minmax_wnd_proc;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandle(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2007-04-08 12:28:05 +02:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "MinMax_WndClass";
|
|
|
|
RegisterClass(&cls);
|
|
|
|
|
2007-01-27 13:50:09 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
2007-04-08 12:28:05 +02:00
|
|
|
parent = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
|
2007-01-27 13:50:09 +01:00
|
|
|
0, 0, 100, 100, 0, 0, 0, NULL);
|
|
|
|
ok(parent != 0, "CreateWindowEx error %d\n", GetLastError());
|
|
|
|
expect_menu(parent, 0);
|
|
|
|
expect_style(parent, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPSIBLINGS);
|
|
|
|
expect_ex_style(parent, WS_EX_WINDOWEDGE);
|
|
|
|
|
|
|
|
memset(&minmax, 0, sizeof(minmax));
|
|
|
|
SendMessage(parent, WM_GETMINMAXINFO, 0, (LPARAM)&minmax);
|
|
|
|
SetRect(&rc_minmax, 0, 0, minmax.ptMaxSize.x, minmax.ptMaxSize.y);
|
2007-04-08 12:28:05 +02:00
|
|
|
ok(IsRectEmpty(&rc_minmax), "ptMaxSize is not empty\n");
|
|
|
|
SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
|
|
|
|
ok(IsRectEmpty(&rc_minmax), "ptMaxTrackSize is not empty\n");
|
2007-01-27 13:50:09 +01:00
|
|
|
|
2007-04-08 12:28:05 +02:00
|
|
|
GetWindowRect(parent, &rc);
|
|
|
|
ok(!IsRectEmpty(&rc), "parent window rect is empty\n");
|
2007-01-27 13:50:09 +01:00
|
|
|
GetClientRect(parent, &rc);
|
2007-04-08 12:28:05 +02:00
|
|
|
ok(!IsRectEmpty(&rc), "parent client rect is empty\n");
|
|
|
|
|
2007-01-27 13:50:09 +01:00
|
|
|
InflateRect(&rc, 200, 200);
|
|
|
|
trace("creating child with rect (%d,%d-%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2007-04-08 12:28:05 +02:00
|
|
|
hwnd = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
|
2007-01-27 13:50:09 +01:00
|
|
|
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
|
|
|
parent, (HMENU)1, 0, NULL);
|
|
|
|
ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
|
|
|
|
expect_menu(hwnd, 1);
|
|
|
|
expect_style(hwnd, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
|
|
|
|
expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
|
|
|
|
|
2007-04-08 12:28:05 +02:00
|
|
|
memset(&minmax, 0, sizeof(minmax));
|
|
|
|
SendMessage(hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&minmax);
|
|
|
|
SetRect(&rc_minmax, 0, 0, minmax.ptMaxTrackSize.x, minmax.ptMaxTrackSize.y);
|
2007-01-27 13:50:09 +01:00
|
|
|
|
2007-04-08 12:28:05 +02:00
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
OffsetRect(&rc, -rc.left, -rc.top);
|
2007-01-27 13:50:09 +01:00
|
|
|
ok(EqualRect(&rc, &rc_minmax), "rects don't match: (%d,%d-%d,%d) and (%d,%d-%d,%d)\n",
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom,
|
|
|
|
rc_minmax.left, rc_minmax.top, rc_minmax.right, rc_minmax.bottom);
|
2008-01-22 10:16:19 +01:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
cls.lpfnWndProc = winsizes_wnd_proc;
|
|
|
|
cls.lpszClassName = "Sizes_WndClass";
|
|
|
|
RegisterClass(&cls);
|
|
|
|
|
|
|
|
expected_cx = expected_cy = 200000;
|
|
|
|
SetRect( &expected_rect, 0, 0, 200000, 200000 );
|
2008-09-17 14:05:06 +02:00
|
|
|
broken_rect = expected_rect;
|
2008-01-22 10:16:19 +01:00
|
|
|
hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 300000, 300000, 200000, 200000, parent, 0, 0, NULL);
|
|
|
|
ok( hwnd != 0, "creation failed err %u\n", GetLastError());
|
|
|
|
GetClientRect( hwnd, &rc );
|
2008-11-26 12:04:51 +01:00
|
|
|
ok( rc.right == 200000 || broken(rc.right == (short)200000), "invalid rect right %u\n", rc.right );
|
|
|
|
ok( rc.bottom == 200000 || broken(rc.bottom == (short)200000), "invalid rect bottom %u\n", rc.bottom );
|
2008-01-22 10:16:19 +01:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
expected_cx = expected_cy = -10;
|
|
|
|
SetRect( &expected_rect, 0, 0, 0, 0 );
|
2008-11-20 11:57:32 +01:00
|
|
|
SetRect( &broken_rect, 0, 0, -10, -10 );
|
2008-01-22 10:16:19 +01:00
|
|
|
hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, -20, -20, -10, -10, parent, 0, 0, NULL);
|
|
|
|
ok( hwnd != 0, "creation failed err %u\n", GetLastError());
|
|
|
|
GetClientRect( hwnd, &rc );
|
|
|
|
ok( rc.right == 0, "invalid rect right %u\n", rc.right );
|
|
|
|
ok( rc.bottom == 0, "invalid rect bottom %u\n", rc.bottom );
|
|
|
|
DestroyWindow(hwnd);
|
2007-01-27 13:50:09 +01:00
|
|
|
|
2008-01-22 10:16:19 +01:00
|
|
|
expected_cx = expected_cy = -200000;
|
|
|
|
SetRect( &expected_rect, 0, 0, 0, 0 );
|
2008-11-20 11:57:32 +01:00
|
|
|
SetRect( &broken_rect, 0, 0, -200000, -200000 );
|
2008-01-22 10:16:19 +01:00
|
|
|
hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, -300000, -300000, -200000, -200000, parent, 0, 0, NULL);
|
|
|
|
ok( hwnd != 0, "creation failed err %u\n", GetLastError());
|
|
|
|
GetClientRect( hwnd, &rc );
|
|
|
|
ok( rc.right == 0, "invalid rect right %u\n", rc.right );
|
|
|
|
ok( rc.bottom == 0, "invalid rect bottom %u\n", rc.bottom );
|
2008-05-28 21:32:50 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
/* we need a parent at 0,0 so that child coordinates match */
|
|
|
|
DestroyWindow(parent);
|
|
|
|
parent = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL);
|
|
|
|
ok(parent != 0, "CreateWindowEx error %d\n", GetLastError());
|
|
|
|
|
|
|
|
expected_cx = 100;
|
|
|
|
expected_cy = 0x7fffffff;
|
|
|
|
SetRect( &expected_rect, 10, 10, 110, 0x7fffffff );
|
2008-09-17 14:05:06 +02:00
|
|
|
SetRect( &broken_rect, 10, 10, 110, 0x7fffffffU + 10 );
|
2008-05-28 21:32:50 +02:00
|
|
|
hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 10, 10, 100, 0x7fffffff, parent, 0, 0, NULL);
|
|
|
|
ok( hwnd != 0, "creation failed err %u\n", GetLastError());
|
|
|
|
GetClientRect( hwnd, &rc );
|
|
|
|
ok( rc.right == 100, "invalid rect right %u\n", rc.right );
|
2008-09-17 14:05:06 +02:00
|
|
|
ok( rc.bottom == 0x7fffffff - 10 || broken(rc.bottom == 0), "invalid rect bottom %u\n", rc.bottom );
|
2008-05-28 21:32:50 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
expected_cx = 0x7fffffff;
|
|
|
|
expected_cy = 0x7fffffff;
|
|
|
|
SetRect( &expected_rect, 20, 10, 0x7fffffff, 0x7fffffff );
|
2008-09-17 14:05:06 +02:00
|
|
|
SetRect( &broken_rect, 20, 10, 0x7fffffffU + 20, 0x7fffffffU + 10 );
|
2008-05-28 21:32:50 +02:00
|
|
|
hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 20, 10, 0x7fffffff, 0x7fffffff, parent, 0, 0, NULL);
|
|
|
|
ok( hwnd != 0, "creation failed err %u\n", GetLastError());
|
|
|
|
GetClientRect( hwnd, &rc );
|
2008-09-17 14:05:06 +02:00
|
|
|
ok( rc.right == 0x7fffffff - 20 || broken(rc.right == 0), "invalid rect right %u\n", rc.right );
|
|
|
|
ok( rc.bottom == 0x7fffffff - 10 || broken(rc.bottom == 0), "invalid rect bottom %u\n", rc.bottom );
|
2007-01-27 13:50:09 +01:00
|
|
|
DestroyWindow(hwnd);
|
2008-01-22 10:16:19 +01:00
|
|
|
|
|
|
|
/* top level window */
|
|
|
|
expected_cx = expected_cy = 200000;
|
|
|
|
SetRect( &expected_rect, 0, 0, GetSystemMetrics(SM_CXMAXTRACK), GetSystemMetrics(SM_CYMAXTRACK) );
|
|
|
|
hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_OVERLAPPEDWINDOW, 300000, 300000, 200000, 200000, 0, 0, 0, NULL);
|
|
|
|
ok( hwnd != 0, "creation failed err %u\n", GetLastError());
|
|
|
|
GetClientRect( hwnd, &rc );
|
|
|
|
ok( rc.right <= expected_cx, "invalid rect right %u\n", rc.right );
|
|
|
|
ok( rc.bottom <= expected_cy, "invalid rect bottom %u\n", rc.bottom );
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
2007-01-27 13:50:09 +01:00
|
|
|
DestroyWindow(parent);
|
|
|
|
|
2007-04-08 12:28:05 +02:00
|
|
|
UnregisterClass("MinMax_WndClass", GetModuleHandle(0));
|
2008-01-22 10:16:19 +01:00
|
|
|
UnregisterClass("Sizes_WndClass", GetModuleHandle(0));
|
2007-04-08 12:28:05 +02:00
|
|
|
|
2008-11-21 08:59:09 +01:00
|
|
|
#undef expect_gle_broken_9x
|
2006-06-09 16:13:50 +02:00
|
|
|
#undef expect_menu
|
|
|
|
#undef expect_style
|
|
|
|
#undef expect_ex_style
|
|
|
|
}
|
|
|
|
|
2006-07-31 17:43:35 +02:00
|
|
|
/* function that remembers whether the system the test is running on sets the
|
|
|
|
* last error for user32 functions to make the tests stricter */
|
|
|
|
static int check_error(DWORD actual, DWORD expected)
|
|
|
|
{
|
|
|
|
static int sets_last_error = -1;
|
|
|
|
if (sets_last_error == -1)
|
|
|
|
sets_last_error = (actual != 0xdeadbeef);
|
|
|
|
return (!sets_last_error && (actual == 0xdeadbeef)) || (actual == expected);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_SetWindowLong(void)
|
|
|
|
{
|
|
|
|
LONG_PTR retval;
|
2006-08-01 16:05:42 +02:00
|
|
|
WNDPROC old_window_procW;
|
2006-07-31 17:43:35 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
retval = SetWindowLongPtr(NULL, GWLP_WNDPROC, 0);
|
2007-05-24 16:41:17 +02:00
|
|
|
ok(!retval, "SetWindowLongPtr on invalid window handle should have returned 0 instead of 0x%lx\n", retval);
|
2006-07-31 17:43:35 +02:00
|
|
|
ok(check_error(GetLastError(), ERROR_INVALID_WINDOW_HANDLE),
|
2006-10-07 21:45:11 +02:00
|
|
|
"SetWindowLongPtr should have set error to ERROR_INVALID_WINDOW_HANDLE instad of %d\n", GetLastError());
|
2006-07-31 17:43:35 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
retval = SetWindowLongPtr(hwndMain, 0xdeadbeef, 0);
|
2007-05-24 16:41:17 +02:00
|
|
|
ok(!retval, "SetWindowLongPtr on invalid index should have returned 0 instead of 0x%lx\n", retval);
|
2006-07-31 17:43:35 +02:00
|
|
|
ok(check_error(GetLastError(), ERROR_INVALID_INDEX),
|
2006-10-07 21:45:11 +02:00
|
|
|
"SetWindowLongPtr should have set error to ERROR_INVALID_INDEX instad of %d\n", GetLastError());
|
2006-07-31 17:43:35 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
retval = SetWindowLongPtr(hwndMain, GWLP_WNDPROC, 0);
|
2008-11-26 12:04:51 +01:00
|
|
|
ok((WNDPROC)retval == main_window_procA || broken(!retval), /* win9x */
|
2007-05-24 16:41:17 +02:00
|
|
|
"SetWindowLongPtr on invalid window proc should have returned address of main_window_procA instead of 0x%lx\n", retval);
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
|
2006-07-31 17:43:35 +02:00
|
|
|
retval = GetWindowLongPtr(hwndMain, GWLP_WNDPROC);
|
|
|
|
ok((WNDPROC)retval == main_window_procA,
|
2007-05-24 16:41:17 +02:00
|
|
|
"SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval);
|
2006-07-31 17:43:35 +02:00
|
|
|
ok(!IsWindowUnicode(hwndMain), "hwndMain shouldn't be Unicode\n");
|
|
|
|
|
2006-08-01 16:05:42 +02:00
|
|
|
old_window_procW = (WNDPROC)GetWindowLongPtrW(hwndMain, GWLP_WNDPROC);
|
2006-07-31 17:43:35 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
retval = SetWindowLongPtrW(hwndMain, GWLP_WNDPROC, 0);
|
|
|
|
if (GetLastError() != ERROR_CALL_NOT_IMPLEMENTED)
|
|
|
|
{
|
2006-10-07 21:45:11 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef, "SetWindowLongPtr shouldn't have set the last error, instead of setting it to %d\n", GetLastError());
|
|
|
|
ok(retval != 0, "SetWindowLongPtr error %d\n", GetLastError());
|
2006-08-01 16:05:42 +02:00
|
|
|
ok((WNDPROC)retval == old_window_procW,
|
2007-05-24 16:41:17 +02:00
|
|
|
"SetWindowLongPtr on invalid window proc shouldn't have changed the value returned by GetWindowLongPtr, instead of changing it to 0x%lx\n", retval);
|
2006-07-31 17:43:35 +02:00
|
|
|
ok(IsWindowUnicode(hwndMain), "hwndMain should now be Unicode\n");
|
|
|
|
|
|
|
|
/* set it back to ANSI */
|
|
|
|
SetWindowLongPtr(hwndMain, GWLP_WNDPROC, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-04 08:06:54 +01:00
|
|
|
static void test_ShowWindow(void)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
DWORD style;
|
|
|
|
RECT rcMain, rc;
|
|
|
|
LPARAM ret;
|
|
|
|
|
|
|
|
SetRect(&rcMain, 120, 120, 210, 210);
|
|
|
|
|
|
|
|
hwnd = CreateWindowEx(0, "MainWindowClass", NULL,
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
|
|
|
|
WS_MAXIMIZEBOX | WS_POPUP,
|
|
|
|
rcMain.left, rcMain.top,
|
|
|
|
rcMain.right - rcMain.left, rcMain.bottom - rcMain.top,
|
|
|
|
0, 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(!(style & WS_DISABLED), "window should not be disabled\n");
|
|
|
|
ok(!(style & WS_VISIBLE), "window should not be visible\n");
|
|
|
|
ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2008-10-02 21:52:17 +02:00
|
|
|
ok(EqualRect(&rcMain, &rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
|
|
|
|
rcMain.left, rcMain.top, rcMain.right, rcMain.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2006-12-04 08:06:54 +01:00
|
|
|
|
|
|
|
ret = ShowWindow(hwnd, SW_SHOW);
|
|
|
|
ok(!ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(!(style & WS_DISABLED), "window should not be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2008-10-02 21:52:17 +02:00
|
|
|
ok(EqualRect(&rcMain, &rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
|
|
|
|
rcMain.left, rcMain.top, rcMain.right, rcMain.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2006-12-04 08:06:54 +01:00
|
|
|
|
|
|
|
ret = ShowWindow(hwnd, SW_MINIMIZE);
|
|
|
|
ok(ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(!(style & WS_DISABLED), "window should not be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(style & WS_MINIMIZE, "window should be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
|
|
|
|
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
ok(ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(!(style & WS_DISABLED), "window should not be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2008-10-02 21:52:17 +02:00
|
|
|
ok(EqualRect(&rcMain, &rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
|
|
|
|
rcMain.left, rcMain.top, rcMain.right, rcMain.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2006-12-04 08:06:54 +01:00
|
|
|
|
|
|
|
ret = EnableWindow(hwnd, FALSE);
|
|
|
|
ok(!ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(style & WS_DISABLED, "window should be disabled\n");
|
|
|
|
|
|
|
|
ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_MINIMIZE, 0);
|
|
|
|
ok(!ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(style & WS_DISABLED, "window should be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2008-10-02 21:52:17 +02:00
|
|
|
ok(EqualRect(&rcMain, &rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
|
|
|
|
rcMain.left, rcMain.top, rcMain.right, rcMain.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2006-12-04 08:06:54 +01:00
|
|
|
|
|
|
|
ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
|
|
|
|
ok(!ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(style & WS_DISABLED, "window should be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2008-10-02 21:52:17 +02:00
|
|
|
ok(EqualRect(&rcMain, &rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
|
|
|
|
rcMain.left, rcMain.top, rcMain.right, rcMain.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2006-12-04 08:06:54 +01:00
|
|
|
|
|
|
|
ret = ShowWindow(hwnd, SW_MINIMIZE);
|
|
|
|
ok(ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(style & WS_DISABLED, "window should be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(style & WS_MINIMIZE, "window should be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
|
|
|
|
|
|
|
|
ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_RESTORE, 0);
|
|
|
|
ok(!ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(style & WS_DISABLED, "window should be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(style & WS_MINIMIZE, "window should be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
ok(!EqualRect(&rcMain, &rc), "rects shouldn't match\n");
|
|
|
|
|
|
|
|
ret = ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
ok(ret, "not expected ret: %lu\n", ret);
|
|
|
|
style = GetWindowLong(hwnd, GWL_STYLE);
|
|
|
|
ok(style & WS_DISABLED, "window should be disabled\n");
|
|
|
|
ok(style & WS_VISIBLE, "window should be visible\n");
|
|
|
|
ok(!(style & WS_MINIMIZE), "window should not be minimized\n");
|
|
|
|
ok(!(style & WS_MAXIMIZE), "window should not be maximized\n");
|
|
|
|
GetWindowRect(hwnd, &rc);
|
2008-10-02 21:52:17 +02:00
|
|
|
ok(EqualRect(&rcMain, &rc), "expected (%d,%d)-(%d,%d), got (%d,%d)-(%d,%d)\n",
|
|
|
|
rcMain.left, rcMain.top, rcMain.right, rcMain.bottom,
|
|
|
|
rc.left, rc.top, rc.right, rc.bottom);
|
2006-12-04 08:06:54 +01:00
|
|
|
|
|
|
|
ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
|
|
|
ok(!ret, "not expected ret: %lu\n", ret);
|
|
|
|
ok(IsWindow(hwnd), "window should exist\n");
|
|
|
|
|
|
|
|
ret = EnableWindow(hwnd, TRUE);
|
|
|
|
ok(ret, "not expected ret: %lu\n", ret);
|
|
|
|
|
|
|
|
ret = DefWindowProc(hwnd, WM_SYSCOMMAND, SC_CLOSE, 0);
|
|
|
|
ok(!ret, "not expected ret: %lu\n", ret);
|
|
|
|
ok(!IsWindow(hwnd), "window should not exist\n");
|
|
|
|
}
|
|
|
|
|
2007-03-12 16:50:54 +01:00
|
|
|
static void test_gettext(void)
|
2007-01-17 11:52:08 +01:00
|
|
|
{
|
|
|
|
WNDCLASS cls;
|
|
|
|
LPCSTR clsname = "gettexttest";
|
|
|
|
HWND hwnd;
|
|
|
|
LRESULT r;
|
|
|
|
|
|
|
|
memset( &cls, 0, sizeof cls );
|
|
|
|
cls.lpfnWndProc = DefWindowProc;
|
|
|
|
cls.lpszClassName = clsname;
|
|
|
|
cls.hInstance = GetModuleHandle(NULL);
|
|
|
|
|
|
|
|
if (!RegisterClass( &cls )) return;
|
|
|
|
|
|
|
|
hwnd = CreateWindow( clsname, "test text", WS_OVERLAPPED, 0, 0, 10, 10, 0, NULL, NULL, NULL);
|
|
|
|
ok( hwnd != NULL, "window was null\n");
|
|
|
|
|
|
|
|
r = SendMessage( hwnd, WM_GETTEXT, 0x10, 0x1000);
|
|
|
|
ok( r == 0, "settext should return zero\n");
|
|
|
|
|
|
|
|
r = SendMessage( hwnd, WM_GETTEXT, 0x10000, 0);
|
|
|
|
ok( r == 0, "settext should return zero (%ld)\n", r);
|
|
|
|
|
|
|
|
r = SendMessage( hwnd, WM_GETTEXT, 0xff000000, 0x1000);
|
|
|
|
ok( r == 0, "settext should return zero (%ld)\n", r);
|
|
|
|
|
|
|
|
r = SendMessage( hwnd, WM_GETTEXT, 0x1000, 0xff000000);
|
|
|
|
ok( r == 0, "settext should return zero (%ld)\n", r);
|
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
UnregisterClass( clsname, NULL );
|
|
|
|
}
|
|
|
|
|
2007-03-02 01:34:09 +01:00
|
|
|
|
2007-02-07 07:15:09 +01:00
|
|
|
static void test_GetUpdateRect(void)
|
|
|
|
{
|
2007-09-04 09:50:16 +02:00
|
|
|
MSG msg;
|
|
|
|
BOOL ret, parent_wm_paint, grandparent_wm_paint;
|
2007-02-07 07:15:09 +01:00
|
|
|
RECT rc1, rc2;
|
|
|
|
HWND hgrandparent, hparent, hchild;
|
2007-03-02 01:34:09 +01:00
|
|
|
WNDCLASSA cls;
|
2007-09-04 09:50:16 +02:00
|
|
|
static const char classNameA[] = "GetUpdateRectClass";
|
2007-02-07 07:15:09 +01:00
|
|
|
|
|
|
|
hgrandparent = CreateWindowA("static", "grandparent", WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 100, 100, NULL, NULL, 0, NULL);
|
|
|
|
|
|
|
|
hparent = CreateWindowA("static", "parent", WS_CHILD|WS_VISIBLE,
|
|
|
|
0, 0, 100, 100, hgrandparent, NULL, 0, NULL);
|
|
|
|
|
|
|
|
hchild = CreateWindowA("static", "child", WS_CHILD|WS_VISIBLE,
|
|
|
|
10, 10, 30, 30, hparent, NULL, 0, NULL);
|
|
|
|
|
|
|
|
ShowWindow(hgrandparent, SW_SHOW);
|
|
|
|
UpdateWindow(hgrandparent);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2007-02-07 07:15:09 +01:00
|
|
|
|
2007-03-02 01:34:09 +01:00
|
|
|
ShowWindow(hchild, SW_HIDE);
|
|
|
|
SetRect(&rc2, 0, 0, 0, 0);
|
2007-09-04 09:50:16 +02:00
|
|
|
ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
|
|
|
|
ok(!ret, "GetUpdateRect returned not empty region\n");
|
2007-08-27 15:21:19 +02:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
|
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom,
|
|
|
|
rc2.left, rc2.top, rc2.right, rc2.bottom);
|
2007-03-02 01:34:09 +01:00
|
|
|
|
|
|
|
SetRect(&rc2, 10, 10, 40, 40);
|
2007-09-04 09:50:16 +02:00
|
|
|
ret = GetUpdateRect(hparent, &rc1, FALSE);
|
|
|
|
ok(ret, "GetUpdateRect returned empty region\n");
|
2007-03-02 01:34:09 +01:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
|
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom,
|
|
|
|
rc2.left, rc2.top, rc2.right, rc2.bottom);
|
|
|
|
|
2007-09-04 09:50:16 +02:00
|
|
|
parent_wm_paint = FALSE;
|
|
|
|
grandparent_wm_paint = FALSE;
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
|
|
|
{
|
|
|
|
if (msg.message == WM_PAINT)
|
|
|
|
{
|
|
|
|
if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE;
|
|
|
|
if (msg.hwnd == hparent) parent_wm_paint = TRUE;
|
|
|
|
}
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
2007-09-27 18:57:51 +02:00
|
|
|
ok(parent_wm_paint, "WM_PAINT should have been received in parent\n");
|
|
|
|
ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n");
|
2007-09-04 09:50:16 +02:00
|
|
|
|
2007-03-02 01:34:09 +01:00
|
|
|
DestroyWindow(hgrandparent);
|
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = DefWindowProcA;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2007-03-02 01:34:09 +01:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = classNameA;
|
|
|
|
|
|
|
|
if(!RegisterClassA(&cls)) {
|
|
|
|
trace("Register failed %d\n", GetLastError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-04 09:50:16 +02:00
|
|
|
hgrandparent = CreateWindowA(classNameA, "grandparent", WS_OVERLAPPEDWINDOW,
|
2007-03-02 01:34:09 +01:00
|
|
|
0, 0, 100, 100, NULL, NULL, 0, NULL);
|
|
|
|
|
|
|
|
hparent = CreateWindowA(classNameA, "parent", WS_CHILD|WS_VISIBLE,
|
|
|
|
0, 0, 100, 100, hgrandparent, NULL, 0, NULL);
|
|
|
|
|
|
|
|
hchild = CreateWindowA(classNameA, "child", WS_CHILD|WS_VISIBLE,
|
|
|
|
10, 10, 30, 30, hparent, NULL, 0, NULL);
|
|
|
|
|
|
|
|
ShowWindow(hgrandparent, SW_SHOW);
|
|
|
|
UpdateWindow(hgrandparent);
|
2008-03-21 11:29:18 +01:00
|
|
|
flush_events( TRUE );
|
2007-03-02 01:34:09 +01:00
|
|
|
|
2007-09-04 09:50:16 +02:00
|
|
|
ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
|
|
|
|
ok(!ret, "GetUpdateRect returned not empty region\n");
|
|
|
|
|
2007-02-07 07:15:09 +01:00
|
|
|
ShowWindow(hchild, SW_HIDE);
|
2007-09-04 09:50:16 +02:00
|
|
|
|
2007-02-07 07:15:09 +01:00
|
|
|
SetRect(&rc2, 0, 0, 0, 0);
|
2007-09-04 09:50:16 +02:00
|
|
|
ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
|
|
|
|
ok(!ret, "GetUpdateRect returned not empty region\n");
|
2007-08-27 15:21:19 +02:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
|
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom,
|
|
|
|
rc2.left, rc2.top, rc2.right, rc2.bottom);
|
2007-02-07 07:15:09 +01:00
|
|
|
|
|
|
|
SetRect(&rc2, 10, 10, 40, 40);
|
2007-09-04 09:50:16 +02:00
|
|
|
ret = GetUpdateRect(hparent, &rc1, FALSE);
|
|
|
|
ok(ret, "GetUpdateRect returned empty region\n");
|
2007-02-07 07:15:09 +01:00
|
|
|
ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
|
|
|
|
rc1.left, rc1.top, rc1.right, rc1.bottom,
|
|
|
|
rc2.left, rc2.top, rc2.right, rc2.bottom);
|
|
|
|
|
2007-09-04 09:50:16 +02:00
|
|
|
parent_wm_paint = FALSE;
|
|
|
|
grandparent_wm_paint = FALSE;
|
|
|
|
while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
|
|
|
|
{
|
|
|
|
if (msg.message == WM_PAINT)
|
|
|
|
{
|
|
|
|
if (msg.hwnd == hgrandparent) grandparent_wm_paint = TRUE;
|
|
|
|
if (msg.hwnd == hparent) parent_wm_paint = TRUE;
|
|
|
|
}
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
2007-09-27 18:57:51 +02:00
|
|
|
ok(parent_wm_paint, "WM_PAINT should have been received in parent\n");
|
|
|
|
ok(!grandparent_wm_paint, "WM_PAINT should NOT have been received in grandparent\n");
|
2007-09-04 09:50:16 +02:00
|
|
|
|
2007-02-07 07:15:09 +01:00
|
|
|
DestroyWindow(hgrandparent);
|
|
|
|
}
|
|
|
|
|
2008-03-15 06:59:54 +01:00
|
|
|
|
|
|
|
static LRESULT CALLBACK TestExposedRegion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if(msg == WM_PAINT)
|
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT updateRect;
|
|
|
|
DWORD waitResult;
|
|
|
|
HWND win;
|
|
|
|
const int waitTime = 2000;
|
|
|
|
|
|
|
|
BeginPaint(hwnd, &ps);
|
|
|
|
|
|
|
|
/* create and destroy window to create an exposed region on this window */
|
|
|
|
win = CreateWindowA("static", "win", WS_VISIBLE,
|
|
|
|
10,10,50,50, NULL, NULL, 0, NULL);
|
|
|
|
DestroyWindow(win);
|
|
|
|
|
2008-05-01 16:34:39 +02:00
|
|
|
waitResult = MsgWaitForMultipleObjects( 0, NULL, FALSE, waitTime, QS_PAINT );
|
2008-03-15 06:59:54 +01:00
|
|
|
|
|
|
|
ValidateRect(hwnd, NULL);
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
|
|
|
|
if(waitResult != WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
GetUpdateRect(hwnd, &updateRect, FALSE);
|
2008-09-17 14:05:06 +02:00
|
|
|
ok(IsRectEmpty(&updateRect), "Exposed rect should be empty\n");
|
2008-03-15 06:59:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_Expose(void)
|
|
|
|
{
|
|
|
|
ATOM atom;
|
|
|
|
WNDCLASSA cls;
|
|
|
|
HWND mw;
|
|
|
|
memset(&cls, 0, sizeof(WNDCLASSA));
|
|
|
|
cls.lpfnWndProc = TestExposedRegion_WndProc;
|
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszClassName = "TestExposeClass";
|
|
|
|
atom = RegisterClassA(&cls);
|
|
|
|
|
|
|
|
mw = CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE|WS_OVERLAPPEDWINDOW,
|
|
|
|
0, 0, 200, 100, NULL, NULL, 0, NULL);
|
|
|
|
|
|
|
|
UpdateWindow(mw);
|
|
|
|
DestroyWindow(mw);
|
|
|
|
}
|
|
|
|
|
2009-07-10 01:10:07 +02:00
|
|
|
static LRESULT CALLBACK TestNCRedraw_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
static UINT ncredrawflags;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
|
|
|
switch(msg)
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
ncredrawflags = *(UINT *) (((CREATESTRUCT *)lParam)->lpCreateParams);
|
|
|
|
return 0;
|
|
|
|
case WM_NCPAINT:
|
|
|
|
RedrawWindow(hwnd, NULL, NULL, ncredrawflags);
|
|
|
|
break;
|
|
|
|
case WM_PAINT:
|
|
|
|
BeginPaint(hwnd, &ps);
|
|
|
|
EndPaint(hwnd, &ps);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void run_NCRedrawLoop(UINT flags)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
MSG msg;
|
|
|
|
|
|
|
|
UINT loopcount = 0;
|
|
|
|
|
|
|
|
hwnd = CreateWindowA("TestNCRedrawClass", "MainWindow",
|
|
|
|
WS_OVERLAPPEDWINDOW, 0, 0, 200, 100,
|
|
|
|
NULL, NULL, 0, &flags);
|
|
|
|
ShowWindow(hwnd, SW_SHOW);
|
|
|
|
UpdateWindow(hwnd);
|
|
|
|
while(PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE) != 0)
|
|
|
|
{
|
|
|
|
if (msg.message == WM_PAINT) loopcount++;
|
|
|
|
if (loopcount >= 100) break;
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
MsgWaitForMultipleObjects(0, NULL, FALSE, 100, QS_ALLINPUT);
|
|
|
|
}
|
|
|
|
if (flags == (RDW_INVALIDATE | RDW_FRAME))
|
|
|
|
todo_wine ok(loopcount < 100, "Detected infinite WM_PAINT loop (%x).\n", flags);
|
|
|
|
else
|
|
|
|
ok(loopcount < 100, "Detected infinite WM_PAINT loop (%x).\n", flags);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_NCRedraw(void)
|
|
|
|
{
|
|
|
|
WNDCLASSA wndclass;
|
|
|
|
|
|
|
|
wndclass.lpszClassName = "TestNCRedrawClass";
|
|
|
|
wndclass.style = CS_HREDRAW | CS_VREDRAW;
|
|
|
|
wndclass.lpfnWndProc = TestNCRedraw_WndProc;
|
|
|
|
wndclass.cbClsExtra = 0;
|
|
|
|
wndclass.cbWndExtra = 0;
|
|
|
|
wndclass.hInstance = 0;
|
|
|
|
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
|
|
|
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
|
|
|
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
wndclass.lpszMenuName = NULL;
|
|
|
|
|
|
|
|
RegisterClassA(&wndclass);
|
|
|
|
|
|
|
|
run_NCRedrawLoop(RDW_INVALIDATE | RDW_FRAME);
|
|
|
|
run_NCRedrawLoop(RDW_INVALIDATE);
|
|
|
|
}
|
|
|
|
|
2008-05-26 08:29:44 +02:00
|
|
|
static void test_GetWindowModuleFileName(void)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
HINSTANCE hinst;
|
|
|
|
UINT ret1, ret2;
|
|
|
|
char buf1[MAX_PATH], buf2[MAX_PATH];
|
|
|
|
|
2008-05-28 13:07:55 +02:00
|
|
|
if (!pGetWindowModuleFileNameA)
|
|
|
|
{
|
2009-02-23 10:41:03 +01:00
|
|
|
win_skip("GetWindowModuleFileNameA is not available\n");
|
2008-05-28 13:07:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-05-26 08:29:44 +02:00
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0,0,0,0, 0, 0, 0, NULL);
|
|
|
|
assert(hwnd);
|
|
|
|
|
|
|
|
hinst = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
2008-11-26 12:04:51 +01:00
|
|
|
ok(hinst == 0 || broken(hinst == GetModuleHandle(0)), /* win9x */ "expected 0, got %p\n", hinst);
|
2008-05-26 08:29:44 +02:00
|
|
|
|
|
|
|
buf1[0] = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret1 = GetModuleFileName(hinst, buf1, sizeof(buf1));
|
|
|
|
ok(ret1, "GetModuleFileName error %u\n", GetLastError());
|
|
|
|
|
|
|
|
buf2[0] = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
2008-05-28 13:07:55 +02:00
|
|
|
ret2 = pGetWindowModuleFileNameA(hwnd, buf2, sizeof(buf2));
|
2009-02-09 14:20:17 +01:00
|
|
|
ok(ret2 || broken(!ret2), /* nt4 sp 3 */
|
|
|
|
"GetWindowModuleFileNameA error %u\n", GetLastError());
|
2008-05-26 08:29:44 +02:00
|
|
|
|
2009-02-09 14:20:17 +01:00
|
|
|
if (ret2)
|
|
|
|
{
|
|
|
|
ok(ret1 == ret2 || broken(ret2 == ret1 + 1), /* win98 */ "%u != %u\n", ret1, ret2);
|
|
|
|
ok(!strcmp(buf1, buf2), "%s != %s\n", buf1, buf2);
|
|
|
|
}
|
2008-05-26 08:29:44 +02:00
|
|
|
hinst = GetModuleHandle(0);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret2 = GetModuleFileName(hinst, buf2, ret1 - 2);
|
2008-11-26 12:04:51 +01:00
|
|
|
ok(ret2 == ret1 - 2 || broken(ret2 == ret1 - 3), /* win98 */
|
|
|
|
"expected %u, got %u\n", ret1 - 2, ret2);
|
2008-06-18 05:35:03 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef /* XP */ ||
|
|
|
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
|
2008-05-29 16:45:22 +02:00
|
|
|
"expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
2008-05-26 08:29:44 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret2 = GetModuleFileName(hinst, buf2, 0);
|
|
|
|
ok(!ret2, "GetModuleFileName should return 0\n");
|
2008-06-18 05:35:03 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef /* XP */ ||
|
|
|
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
|
2008-05-29 16:45:22 +02:00
|
|
|
"expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
2008-05-26 08:29:44 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2008-05-28 13:07:55 +02:00
|
|
|
ret2 = pGetWindowModuleFileNameA(hwnd, buf2, ret1 - 2);
|
2009-02-09 14:20:17 +01:00
|
|
|
ok(ret2 == ret1 - 2 || broken(ret2 == ret1 - 3) /* win98 */ || broken(!ret2), /* nt4 sp3 */
|
2008-11-26 12:04:51 +01:00
|
|
|
"expected %u, got %u\n", ret1 - 2, ret2);
|
2008-06-18 05:35:03 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef /* XP */ ||
|
|
|
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
|
2008-05-29 16:45:22 +02:00
|
|
|
"expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
2008-05-26 08:29:44 +02:00
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
2008-05-28 13:07:55 +02:00
|
|
|
ret2 = pGetWindowModuleFileNameA(hwnd, buf2, 0);
|
2008-05-26 08:29:44 +02:00
|
|
|
ok(!ret2, "expected 0, got %u\n", ret2);
|
2008-06-18 05:35:03 +02:00
|
|
|
ok(GetLastError() == 0xdeadbeef /* XP */ ||
|
|
|
|
GetLastError() == ERROR_INSUFFICIENT_BUFFER, /* win2k3, vista */
|
2008-05-29 16:45:22 +02:00
|
|
|
"expected 0xdeadbeef or ERROR_INSUFFICIENT_BUFFER, got %u\n", GetLastError());
|
2008-05-26 08:29:44 +02:00
|
|
|
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
buf2[0] = 0;
|
|
|
|
hwnd = (HWND)0xdeadbeef;
|
|
|
|
SetLastError(0xdeadbeef);
|
2008-05-28 13:07:55 +02:00
|
|
|
ret1 = pGetWindowModuleFileNameA(hwnd, buf1, sizeof(buf1));
|
2008-05-26 08:29:44 +02:00
|
|
|
ok(!ret1, "expected 0, got %u\n", ret1);
|
2008-11-26 12:04:51 +01:00
|
|
|
ok(GetLastError() == ERROR_INVALID_WINDOW_HANDLE || broken(GetLastError() == 0xdeadbeef), /* win9x */
|
|
|
|
"expected ERROR_INVALID_WINDOW_HANDLE, got %u\n", GetLastError());
|
2008-05-26 08:29:44 +02:00
|
|
|
|
|
|
|
hwnd = FindWindow("Shell_TrayWnd", NULL);
|
2009-02-12 17:32:15 +01:00
|
|
|
ok(IsWindow(hwnd) || broken(!hwnd), "got invalid tray window %p\n", hwnd);
|
2008-05-26 08:29:44 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-05-28 13:07:55 +02:00
|
|
|
ret1 = pGetWindowModuleFileNameA(hwnd, buf1, sizeof(buf1));
|
2008-11-26 12:04:51 +01:00
|
|
|
ok(!ret1 || broken(ret1), /* win98 */ "expected 0, got %u\n", ret1);
|
|
|
|
|
|
|
|
if (!ret1) /* inter-process GetWindowModuleFileName works on win9x, so don't test the desktop there */
|
|
|
|
{
|
|
|
|
ret1 = GetModuleFileName(0, buf1, sizeof(buf1));
|
|
|
|
hwnd = GetDesktopWindow();
|
|
|
|
ok(IsWindow(hwnd), "got invalid desktop window %p\n", hwnd);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret2 = pGetWindowModuleFileNameA(hwnd, buf2, sizeof(buf2));
|
2009-04-10 20:45:08 +02:00
|
|
|
ok(!ret2 ||
|
|
|
|
ret1 == ret2 || /* vista */
|
|
|
|
broken(ret2), /* some win98 return user.exe as file name */
|
|
|
|
"expected 0 or %u, got %u %s\n", ret1, ret2, buf2);
|
2008-11-26 12:04:51 +01:00
|
|
|
}
|
2008-05-26 08:29:44 +02:00
|
|
|
}
|
|
|
|
|
2008-06-25 15:24:02 +02:00
|
|
|
static void test_hwnd_message(void)
|
|
|
|
{
|
2008-10-26 23:08:50 +01:00
|
|
|
static const WCHAR mainwindowclassW[] = {'M','a','i','n','W','i','n','d','o','w','C','l','a','s','s',0};
|
|
|
|
static const WCHAR message_windowW[] = {'m','e','s','s','a','g','e',' ','w','i','n','d','o','w',0};
|
|
|
|
|
2008-06-25 15:30:22 +02:00
|
|
|
HWND parent = 0, hwnd, found;
|
2008-06-25 15:24:02 +02:00
|
|
|
RECT rect;
|
|
|
|
|
2008-10-26 23:08:50 +01:00
|
|
|
/* HWND_MESSAGE is not supported below w2k, but win9x return != 0
|
|
|
|
on CreateWindowExA and crash later in the test.
|
|
|
|
Use UNICODE here to fail on win9x */
|
|
|
|
hwnd = CreateWindowExW(0, mainwindowclassW, message_windowW, WS_CAPTION | WS_VISIBLE,
|
2008-06-25 15:24:02 +02:00
|
|
|
100, 100, 200, 200, HWND_MESSAGE, 0, 0, NULL);
|
|
|
|
if (!hwnd)
|
|
|
|
{
|
2008-10-26 23:08:50 +01:00
|
|
|
win_skip("CreateWindowExW with parent HWND_MESSAGE failed\n");
|
2008-06-25 15:24:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok( !GetParent(hwnd), "GetParent should return 0 for message only windows\n" );
|
|
|
|
if (pGetAncestor)
|
|
|
|
{
|
|
|
|
char buffer[100];
|
|
|
|
HWND root, desktop = GetDesktopWindow();
|
|
|
|
|
|
|
|
parent = pGetAncestor(hwnd, GA_PARENT);
|
|
|
|
ok(parent != 0, "GetAncestor(GA_PARENT) should not return 0 for message windows\n");
|
|
|
|
ok(parent != desktop, "GetAncestor(GA_PARENT) should not return desktop for message windows\n");
|
|
|
|
root = pGetAncestor(hwnd, GA_ROOT);
|
|
|
|
ok(root == hwnd, "GetAncestor(GA_ROOT) should return hwnd for message windows\n");
|
2009-01-22 13:12:09 +01:00
|
|
|
ok( !pGetAncestor(parent, GA_PARENT) || broken(pGetAncestor(parent, GA_PARENT) != 0), /* win2k */
|
|
|
|
"parent shouldn't have parent %p\n", pGetAncestor(parent, GA_PARENT) );
|
2008-06-25 15:24:02 +02:00
|
|
|
trace("parent %p root %p desktop %p\n", parent, root, desktop);
|
|
|
|
if (!GetClassNameA( parent, buffer, sizeof(buffer) )) buffer[0] = 0;
|
|
|
|
ok( !lstrcmpi( buffer, "Message" ), "wrong parent class '%s'\n", buffer );
|
|
|
|
GetWindowRect( parent, &rect );
|
|
|
|
ok( rect.left == 0 && rect.right == 100 && rect.top == 0 && rect.bottom == 100,
|
|
|
|
"wrong parent rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
|
|
|
}
|
|
|
|
GetWindowRect( hwnd, &rect );
|
|
|
|
ok( rect.left == 100 && rect.right == 300 && rect.top == 100 && rect.bottom == 300,
|
|
|
|
"wrong window rect %d,%d-%d,%d\n", rect.left, rect.top, rect.right, rect.bottom );
|
|
|
|
|
2008-06-25 15:30:22 +02:00
|
|
|
/* test FindWindow behavior */
|
|
|
|
|
|
|
|
found = FindWindowExA( 0, 0, 0, "message window" );
|
|
|
|
ok( found == hwnd, "didn't find message window %p/%p\n", found, hwnd );
|
2008-08-15 19:13:13 +02:00
|
|
|
SetLastError(0xdeadbeef);
|
2008-06-25 15:30:22 +02:00
|
|
|
found = FindWindowExA( GetDesktopWindow(), 0, 0, "message window" );
|
|
|
|
ok( found == 0, "found message window %p/%p\n", found, hwnd );
|
2008-09-15 11:30:13 +02:00
|
|
|
ok( GetLastError() == 0xdeadbeef, "expected deadbeef, got %d\n", GetLastError() );
|
2008-06-25 15:30:22 +02:00
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
found = FindWindowExA( parent, 0, 0, "message window" );
|
|
|
|
ok( found == hwnd, "didn't find message window %p/%p\n", found, hwnd );
|
|
|
|
}
|
|
|
|
|
2008-06-25 15:49:44 +02:00
|
|
|
/* test IsChild behavior */
|
|
|
|
|
|
|
|
if (parent) ok( !IsChild( parent, hwnd ), "HWND_MESSAGE is child of top window\n" );
|
|
|
|
|
|
|
|
/* test IsWindowVisible behavior */
|
|
|
|
|
|
|
|
ok( !IsWindowVisible( hwnd ), "HWND_MESSAGE window is visible\n" );
|
|
|
|
if (parent) ok( !IsWindowVisible( parent ), "HWND_MESSAGE parent is visible\n" );
|
|
|
|
|
2008-06-25 15:24:02 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2008-09-12 15:31:05 +02:00
|
|
|
static void test_layered_window(void)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
COLORREF key = 0;
|
|
|
|
BYTE alpha = 0;
|
|
|
|
DWORD flags = 0;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (!pGetLayeredWindowAttributes || !pSetLayeredWindowAttributes)
|
|
|
|
{
|
|
|
|
win_skip( "layered windows not supported\n" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hwnd = CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION,
|
|
|
|
100, 100, 200, 200, 0, 0, 0, NULL);
|
|
|
|
assert( hwnd );
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( !ret, "GetLayeredWindowAttributes should fail on non-layered window\n" );
|
|
|
|
ret = pSetLayeredWindowAttributes( hwnd, 0, 0, LWA_ALPHA );
|
|
|
|
ok( !ret, "SetLayeredWindowAttributes should fail on non-layered window\n" );
|
|
|
|
SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED );
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
|
|
|
|
ret = pSetLayeredWindowAttributes( hwnd, 0x123456, 44, LWA_ALPHA );
|
|
|
|
ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
|
2009-01-13 17:06:31 +01:00
|
|
|
ok( key == 0x123456 || key == 0, "wrong color key %x\n", key );
|
2008-09-12 15:31:05 +02:00
|
|
|
ok( alpha == 44, "wrong alpha %u\n", alpha );
|
|
|
|
ok( flags == LWA_ALPHA, "wrong flags %x\n", flags );
|
|
|
|
|
|
|
|
/* clearing WS_EX_LAYERED resets attributes */
|
|
|
|
SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED );
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( !ret, "GetLayeredWindowAttributes should fail on no longer layered window\n" );
|
|
|
|
SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED );
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( !ret, "GetLayeredWindowAttributes should fail on layered but not initialized window\n" );
|
|
|
|
ret = pSetLayeredWindowAttributes( hwnd, 0x654321, 22, LWA_COLORKEY | LWA_ALPHA );
|
|
|
|
ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
|
|
|
|
ok( key == 0x654321, "wrong color key %x\n", key );
|
|
|
|
ok( alpha == 22, "wrong alpha %u\n", alpha );
|
|
|
|
ok( flags == (LWA_COLORKEY | LWA_ALPHA), "wrong flags %x\n", flags );
|
|
|
|
|
|
|
|
ret = pSetLayeredWindowAttributes( hwnd, 0x888888, 33, LWA_COLORKEY );
|
|
|
|
ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
|
|
|
|
alpha = 0;
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
|
|
|
|
ok( key == 0x888888, "wrong color key %x\n", key );
|
2008-09-17 14:05:06 +02:00
|
|
|
/* alpha not changed on vista if LWA_ALPHA is not set */
|
|
|
|
ok( alpha == 22 || alpha == 33, "wrong alpha %u\n", alpha );
|
2008-09-12 15:31:05 +02:00
|
|
|
ok( flags == LWA_COLORKEY, "wrong flags %x\n", flags );
|
|
|
|
|
2009-01-13 17:06:31 +01:00
|
|
|
/* color key may or may not be changed without LWA_COLORKEY */
|
2008-09-12 15:31:05 +02:00
|
|
|
ret = pSetLayeredWindowAttributes( hwnd, 0x999999, 44, 0 );
|
|
|
|
ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
|
|
|
|
alpha = 0;
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
|
2009-01-13 17:06:31 +01:00
|
|
|
ok( key == 0x888888 || key == 0x999999, "wrong color key %x\n", key );
|
2008-09-17 14:05:06 +02:00
|
|
|
ok( alpha == 22 || alpha == 44, "wrong alpha %u\n", alpha );
|
2008-09-12 15:31:05 +02:00
|
|
|
ok( flags == 0, "wrong flags %x\n", flags );
|
|
|
|
|
2009-01-13 17:06:31 +01:00
|
|
|
/* default alpha and color key is 0 */
|
2008-09-12 15:31:05 +02:00
|
|
|
SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED );
|
|
|
|
SetWindowLong( hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED );
|
|
|
|
ret = pSetLayeredWindowAttributes( hwnd, 0x222222, 55, 0 );
|
|
|
|
ok( ret, "SetLayeredWindowAttributes should succeed on layered window\n" );
|
|
|
|
ret = pGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags );
|
|
|
|
ok( ret, "GetLayeredWindowAttributes should succeed on layered window\n" );
|
2009-01-13 17:06:31 +01:00
|
|
|
ok( key == 0 || key == 0x222222, "wrong color key %x\n", key );
|
2008-09-17 14:05:06 +02:00
|
|
|
ok( alpha == 0 || alpha == 55, "wrong alpha %u\n", alpha );
|
2008-09-12 15:31:05 +02:00
|
|
|
ok( flags == 0, "wrong flags %x\n", flags );
|
|
|
|
|
|
|
|
DestroyWindow( hwnd );
|
|
|
|
}
|
|
|
|
|
2008-10-16 12:58:56 +02:00
|
|
|
static MONITORINFO mi;
|
|
|
|
|
|
|
|
static LRESULT CALLBACK fullscreen_wnd_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_NCCREATE:
|
|
|
|
{
|
|
|
|
CREATESTRUCTA *cs = (CREATESTRUCTA *)lp;
|
|
|
|
trace("WM_NCCREATE: rect %d,%d-%d,%d\n", cs->x, cs->y, cs->cx, cs->cy);
|
|
|
|
ok(cs->x == mi.rcMonitor.left && cs->y == mi.rcMonitor.top &&
|
|
|
|
cs->cx == mi.rcMonitor.right && cs->cy == mi.rcMonitor.bottom,
|
|
|
|
"expected %d,%d-%d,%d, got %d,%d-%d,%d\n",
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
cs->x, cs->y, cs->cx, cs->cy);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
MINMAXINFO *minmax = (MINMAXINFO *)lp;
|
|
|
|
dump_minmax_info(minmax);
|
|
|
|
ok(minmax->ptMaxPosition.x <= mi.rcMonitor.left, "%d <= %d\n", minmax->ptMaxPosition.x, mi.rcMonitor.left);
|
|
|
|
ok(minmax->ptMaxPosition.y <= mi.rcMonitor.top, "%d <= %d\n", minmax->ptMaxPosition.y, mi.rcMonitor.top);
|
|
|
|
ok(minmax->ptMaxSize.x >= mi.rcMonitor.right, "%d >= %d\n", minmax->ptMaxSize.x, mi.rcMonitor.right);
|
|
|
|
ok(minmax->ptMaxSize.y >= mi.rcMonitor.bottom, "%d >= %d\n", minmax->ptMaxSize.y, mi.rcMonitor.bottom);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DefWindowProc(hwnd, msg, wp, lp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_fullscreen(void)
|
|
|
|
{
|
|
|
|
static const DWORD t_style[] = {
|
|
|
|
WS_OVERLAPPED, WS_POPUP, WS_CHILD, WS_THICKFRAME, WS_DLGFRAME
|
|
|
|
};
|
|
|
|
static const DWORD t_ex_style[] = {
|
|
|
|
0, WS_EX_APPWINDOW, WS_EX_TOOLWINDOW
|
|
|
|
};
|
|
|
|
WNDCLASS cls;
|
|
|
|
HWND hwnd;
|
|
|
|
int i, j;
|
|
|
|
POINT pt;
|
|
|
|
RECT rc;
|
|
|
|
HMONITOR hmon;
|
|
|
|
LRESULT ret;
|
|
|
|
|
|
|
|
if (!pGetMonitorInfoA || !pMonitorFromPoint)
|
|
|
|
{
|
|
|
|
win_skip("GetMonitorInfoA or MonitorFromPoint are not available on this platform\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pt.x = pt.y = 0;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
hmon = pMonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY);
|
|
|
|
ok(hmon != 0, "MonitorFromPoint error %u\n", GetLastError());
|
|
|
|
|
|
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pGetMonitorInfoA(hmon, &mi);
|
|
|
|
ok(ret, "GetMonitorInfo error %u\n", GetLastError());
|
|
|
|
trace("monitor (%d,%d-%d,%d), work (%d,%d-%d,%d)\n",
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
mi.rcWork.left, mi.rcWork.top, mi.rcWork.right, mi.rcWork.bottom);
|
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = fullscreen_wnd_proc;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandle(0);
|
|
|
|
cls.hIcon = 0;
|
2009-01-13 10:55:46 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2008-10-16 12:58:56 +02:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = "fullscreen_class";
|
|
|
|
RegisterClass(&cls);
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof(t_style)/sizeof(t_style[0]); i++)
|
|
|
|
{
|
|
|
|
DWORD style, ex_style;
|
|
|
|
|
|
|
|
/* avoid a WM interaction */
|
|
|
|
assert(!(t_style[i] & WS_VISIBLE));
|
|
|
|
|
|
|
|
for (j = 0; j < sizeof(t_ex_style)/sizeof(t_ex_style[0]); j++)
|
|
|
|
{
|
|
|
|
int fixup;
|
|
|
|
|
|
|
|
style = t_style[i];
|
|
|
|
ex_style = t_ex_style[j];
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
|
|
|
|
ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
|
|
|
|
rc.right >= mi.rcMonitor.right && rc.bottom >= mi.rcMonitor.bottom,
|
|
|
|
"%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
style = t_style[i] | WS_MAXIMIZE;
|
|
|
|
hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
|
|
|
|
ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
|
|
|
|
rc.right >= mi.rcMonitor.right && rc.bottom >= mi.rcMonitor.bottom,
|
|
|
|
"%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
style = t_style[i] | WS_MAXIMIZE | WS_CAPTION;
|
|
|
|
hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
|
|
|
|
ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
|
|
|
|
rc.right >= mi.rcMonitor.right && rc.bottom >= mi.rcMonitor.bottom,
|
|
|
|
"%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
style = t_style[i] | WS_CAPTION | WS_MAXIMIZEBOX;
|
|
|
|
hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
|
|
|
|
ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
|
|
|
|
rc.right >= mi.rcMonitor.right && rc.bottom >= mi.rcMonitor.bottom,
|
|
|
|
"%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
style = t_style[i] | WS_MAXIMIZE | WS_CAPTION | WS_MAXIMIZEBOX;
|
|
|
|
hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
|
|
|
|
ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
/* Windows makes a maximized window slightly larger (to hide the borders?) */
|
|
|
|
fixup = min(abs(rc.left), abs(rc.top));
|
|
|
|
InflateRect(&rc, -fixup, -fixup);
|
|
|
|
ok(rc.left >= mi.rcWork.left && rc.top <= mi.rcWork.top &&
|
|
|
|
rc.right <= mi.rcWork.right && rc.bottom <= mi.rcWork.bottom,
|
2009-01-24 18:06:40 +01:00
|
|
|
"%#x/%#x: window rect %d,%d-%d,%d must be in %d,%d-%d,%d\n",
|
|
|
|
ex_style, style, rc.left, rc.top, rc.right, rc.bottom,
|
|
|
|
mi.rcWork.left, mi.rcWork.top, mi.rcWork.right, mi.rcWork.bottom);
|
2008-10-16 12:58:56 +02:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
|
|
|
|
style = t_style[i] | WS_MAXIMIZE | WS_MAXIMIZEBOX;
|
|
|
|
hwnd = CreateWindowExA(ex_style, "fullscreen_class", NULL, style,
|
|
|
|
mi.rcMonitor.left, mi.rcMonitor.top, mi.rcMonitor.right, mi.rcMonitor.bottom,
|
|
|
|
GetDesktopWindow(), 0, GetModuleHandle(0), NULL);
|
|
|
|
ok(hwnd != 0, "%d: CreateWindowExA(%#x/%#x) failed\n", i, ex_style, style);
|
|
|
|
GetWindowRect(hwnd, &rc);
|
|
|
|
trace("%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
/* Windows makes a maximized window slightly larger (to hide the borders?) */
|
|
|
|
fixup = min(abs(rc.left), abs(rc.top));
|
|
|
|
InflateRect(&rc, -fixup, -fixup);
|
|
|
|
if (style & (WS_CHILD | WS_POPUP))
|
|
|
|
ok(rc.left <= mi.rcMonitor.left && rc.top <= mi.rcMonitor.top &&
|
|
|
|
rc.right >= mi.rcMonitor.right && rc.bottom >= mi.rcMonitor.bottom,
|
|
|
|
"%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
else
|
|
|
|
ok(rc.left >= mi.rcWork.left && rc.top <= mi.rcWork.top &&
|
|
|
|
rc.right <= mi.rcWork.right && rc.bottom <= mi.rcWork.bottom,
|
|
|
|
"%#x/%#x: window rect %d,%d-%d,%d\n", ex_style, style, rc.left, rc.top, rc.right, rc.bottom);
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-20 01:26:52 +02:00
|
|
|
UnregisterClass("fullscreen_class", GetModuleHandle(0));
|
2008-10-16 12:58:56 +02:00
|
|
|
}
|
|
|
|
|
2008-11-19 11:07:00 +01:00
|
|
|
static BOOL test_thick_child_got_minmax;
|
2009-01-20 13:52:34 +01:00
|
|
|
static const char * test_thick_child_name;
|
|
|
|
static LONG test_thick_child_style;
|
|
|
|
static LONG test_thick_child_exStyle;
|
|
|
|
|
2008-11-19 11:07:00 +01:00
|
|
|
static LRESULT WINAPI test_thick_child_size_winproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
|
|
|
|
{
|
|
|
|
MINMAXINFO* minmax;
|
2009-01-20 13:52:34 +01:00
|
|
|
int expectedMinTrackX;
|
|
|
|
int expectedMinTrackY;
|
2008-11-19 11:07:00 +01:00
|
|
|
int actualMinTrackX;
|
|
|
|
int actualMinTrackY;
|
|
|
|
int expectedMaxTrackX;
|
|
|
|
int expectedMaxTrackY;
|
|
|
|
int actualMaxTrackX;
|
|
|
|
int actualMaxTrackY;
|
|
|
|
int expectedMaxSizeX;
|
|
|
|
int expectedMaxSizeY;
|
|
|
|
int actualMaxSizeX;
|
|
|
|
int actualMaxSizeY;
|
|
|
|
int expectedPosX;
|
|
|
|
int expectedPosY;
|
|
|
|
int actualPosX;
|
|
|
|
int actualPosY;
|
2009-01-20 13:52:34 +01:00
|
|
|
LONG adjustedStyle;
|
2008-11-19 11:07:00 +01:00
|
|
|
RECT rect;
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
minmax = (MINMAXINFO *)lparam;
|
|
|
|
trace("hwnd %p, WM_GETMINMAXINFO, %08lx, %08lx\n", hwnd, wparam, lparam);
|
|
|
|
dump_minmax_info( minmax );
|
|
|
|
|
|
|
|
test_thick_child_got_minmax = TRUE;
|
|
|
|
|
2009-01-24 18:06:37 +01:00
|
|
|
|
|
|
|
adjustedStyle = test_thick_child_style;
|
|
|
|
if ((adjustedStyle & WS_CAPTION) == WS_CAPTION)
|
|
|
|
adjustedStyle &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
|
|
|
|
GetClientRect(GetParent(hwnd), &rect);
|
|
|
|
AdjustWindowRectEx(&rect, adjustedStyle, FALSE, test_thick_child_exStyle);
|
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
if (test_thick_child_style & (WS_DLGFRAME | WS_BORDER))
|
|
|
|
{
|
|
|
|
expectedMinTrackX = GetSystemMetrics(SM_CXMINTRACK);
|
|
|
|
expectedMinTrackY = GetSystemMetrics(SM_CYMINTRACK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-24 18:06:37 +01:00
|
|
|
expectedMinTrackX = -2 * rect.left;
|
|
|
|
expectedMinTrackY = -2 * rect.top;
|
2009-01-20 13:52:34 +01:00
|
|
|
}
|
2008-11-19 11:07:00 +01:00
|
|
|
actualMinTrackX = minmax->ptMinTrackSize.x;
|
|
|
|
actualMinTrackY = minmax->ptMinTrackSize.y;
|
2009-01-24 18:06:39 +01:00
|
|
|
|
|
|
|
ok(actualMinTrackX == expectedMinTrackX && actualMinTrackY == expectedMinTrackY,
|
|
|
|
"expected minTrack %dx%d, actual minTrack %dx%d for %s\n",
|
|
|
|
expectedMinTrackX, expectedMinTrackY, actualMinTrackX, actualMinTrackY,
|
|
|
|
test_thick_child_name);
|
2008-11-19 11:07:00 +01:00
|
|
|
|
|
|
|
actualMaxTrackX = minmax->ptMaxTrackSize.x;
|
|
|
|
actualMaxTrackY = minmax->ptMaxTrackSize.y;
|
|
|
|
expectedMaxTrackX = GetSystemMetrics(SM_CXMAXTRACK);
|
|
|
|
expectedMaxTrackY = GetSystemMetrics(SM_CYMAXTRACK);
|
|
|
|
ok(actualMaxTrackX == expectedMaxTrackX && actualMaxTrackY == expectedMaxTrackY,
|
2009-01-20 13:52:34 +01:00
|
|
|
"expected maxTrack %dx%d, actual maxTrack %dx%d for %s\n",
|
|
|
|
expectedMaxTrackX, expectedMaxTrackY, actualMaxTrackX, actualMaxTrackY,
|
|
|
|
test_thick_child_name);
|
2008-11-19 11:07:00 +01:00
|
|
|
|
|
|
|
expectedMaxSizeX = rect.right - rect.left;
|
|
|
|
expectedMaxSizeY = rect.bottom - rect.top;
|
|
|
|
actualMaxSizeX = minmax->ptMaxSize.x;
|
|
|
|
actualMaxSizeY = minmax->ptMaxSize.y;
|
2009-01-20 13:52:40 +01:00
|
|
|
|
|
|
|
ok(actualMaxSizeX == expectedMaxSizeX && actualMaxSizeY == expectedMaxSizeY,
|
|
|
|
"expected maxSize %dx%d, actual maxSize %dx%d for %s\n",
|
|
|
|
expectedMaxSizeX, expectedMaxSizeY, actualMaxSizeX, actualMaxSizeY,
|
|
|
|
test_thick_child_name);
|
|
|
|
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-01-24 18:06:37 +01:00
|
|
|
expectedPosX = rect.left;
|
|
|
|
expectedPosY = rect.top;
|
2008-11-19 11:07:00 +01:00
|
|
|
actualPosX = minmax->ptMaxPosition.x;
|
|
|
|
actualPosY = minmax->ptMaxPosition.y;
|
2009-01-24 18:06:38 +01:00
|
|
|
ok(actualPosX == expectedPosX && actualPosY == expectedPosY,
|
|
|
|
"expected maxPosition (%d/%d), actual maxPosition (%d/%d) for %s\n",
|
|
|
|
expectedPosX, expectedPosY, actualPosX, actualPosY, test_thick_child_name);
|
2009-01-20 13:52:34 +01:00
|
|
|
|
2008-11-19 11:07:00 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcA(hwnd, msg, wparam, lparam);
|
|
|
|
}
|
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
#define NUMBER_OF_THICK_CHILD_TESTS 16
|
2008-11-19 11:07:00 +01:00
|
|
|
static void test_thick_child_size(HWND parentWindow)
|
|
|
|
{
|
|
|
|
BOOL success;
|
|
|
|
RECT childRect;
|
2009-01-24 18:06:37 +01:00
|
|
|
RECT adjustedParentRect;
|
2008-11-19 11:07:00 +01:00
|
|
|
HWND childWindow;
|
|
|
|
LONG childWidth;
|
|
|
|
LONG childHeight;
|
2009-01-20 13:52:34 +01:00
|
|
|
LONG expectedWidth;
|
|
|
|
LONG expectedHeight;
|
2008-11-19 11:07:00 +01:00
|
|
|
WNDCLASSA cls;
|
|
|
|
LPCTSTR className = "THICK_CHILD_CLASS";
|
2009-01-20 13:52:34 +01:00
|
|
|
int i;
|
2009-01-24 18:06:37 +01:00
|
|
|
LONG adjustedStyle;
|
2009-01-20 13:52:34 +01:00
|
|
|
static const LONG styles[NUMBER_OF_THICK_CHILD_TESTS] = {
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER,
|
|
|
|
WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER,
|
|
|
|
};
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
static const LONG exStyles[NUMBER_OF_THICK_CHILD_TESTS] = {
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_STATICEDGE,
|
|
|
|
WS_EX_STATICEDGE,
|
|
|
|
WS_EX_STATICEDGE,
|
|
|
|
WS_EX_STATICEDGE,
|
|
|
|
WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME,
|
|
|
|
WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME,
|
|
|
|
};
|
|
|
|
static const char *styleName[NUMBER_OF_THICK_CHILD_TESTS] = {
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_DLGMODALFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_DLGMODALFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_DLGMODALFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME exstyle= WS_EX_STATICEDGE",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME, exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_DLGFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
|
|
|
|
"style=WS_CHILD | WS_VISIBLE | WS_THICKFRAME | WS_BORDER exstyle= WS_EX_STATICEDGE | WS_EX_DLGMODALFRAME",
|
|
|
|
};
|
2008-11-19 11:07:00 +01:00
|
|
|
|
|
|
|
cls.style = 0;
|
|
|
|
cls.lpfnWndProc = test_thick_child_size_winproc;
|
|
|
|
cls.cbClsExtra = 0;
|
|
|
|
cls.cbWndExtra = 0;
|
|
|
|
cls.hInstance = GetModuleHandleA(0);
|
|
|
|
cls.hIcon = 0;
|
2009-02-05 09:53:39 +01:00
|
|
|
cls.hCursor = LoadCursorA(0, IDC_ARROW);
|
2008-11-19 11:07:00 +01:00
|
|
|
cls.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
cls.lpszMenuName = NULL;
|
|
|
|
cls.lpszClassName = className;
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ok(RegisterClassA(&cls),"RegisterClassA failed, error: %u\n", GetLastError());
|
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
for(i = 0; i < NUMBER_OF_THICK_CHILD_TESTS; i++)
|
|
|
|
{
|
|
|
|
test_thick_child_name = styleName[i];
|
|
|
|
test_thick_child_style = styles[i];
|
|
|
|
test_thick_child_exStyle = exStyles[i];
|
|
|
|
test_thick_child_got_minmax = FALSE;
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
childWindow = CreateWindowEx( exStyles[i], className, "", styles[i], 0, 0, 0, 0, parentWindow, 0, GetModuleHandleA(0), NULL );
|
|
|
|
ok(childWindow != NULL, "Failed to create child window, error: %u\n", GetLastError());
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
ok(test_thick_child_got_minmax, "Got no WM_GETMINMAXINFO\n");
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
success = GetWindowRect(childWindow, &childRect);
|
|
|
|
ok(success,"GetWindowRect call failed, error: %u\n", GetLastError());
|
|
|
|
childWidth = childRect.right - childRect.left;
|
|
|
|
childHeight = childRect.bottom - childRect.top;
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-01-24 18:06:37 +01:00
|
|
|
adjustedStyle = styles[i];
|
|
|
|
if ((adjustedStyle & WS_CAPTION) == WS_CAPTION)
|
|
|
|
adjustedStyle &= ~WS_BORDER; /* WS_CAPTION = WS_DLGFRAME | WS_BORDER */
|
|
|
|
GetClientRect(GetParent(childWindow), &adjustedParentRect);
|
|
|
|
AdjustWindowRectEx(&adjustedParentRect, adjustedStyle, FALSE, test_thick_child_exStyle);
|
|
|
|
|
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
if (test_thick_child_style & (WS_DLGFRAME | WS_BORDER))
|
|
|
|
{
|
|
|
|
expectedWidth = GetSystemMetrics(SM_CXMINTRACK);
|
|
|
|
expectedHeight = GetSystemMetrics(SM_CYMINTRACK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-24 18:06:37 +01:00
|
|
|
expectedWidth = -2 * adjustedParentRect.left;
|
|
|
|
expectedHeight = -2 * adjustedParentRect.top;
|
2009-01-20 13:52:34 +01:00
|
|
|
}
|
|
|
|
|
2009-01-24 18:06:39 +01:00
|
|
|
ok((childWidth == expectedWidth) && (childHeight == expectedHeight),
|
|
|
|
"size of window (%s) is wrong: expected size %dx%d != actual size %dx%d\n",
|
|
|
|
test_thick_child_name, expectedWidth, expectedHeight, childWidth, childHeight);
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-01-20 13:52:34 +01:00
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
success = DestroyWindow(childWindow);
|
|
|
|
ok(success,"DestroyWindow call failed, error: %u\n", GetLastError());
|
|
|
|
}
|
2008-11-19 11:07:00 +01:00
|
|
|
ok(UnregisterClass(className, GetModuleHandleA(0)),"UnregisterClass call failed\n");
|
|
|
|
}
|
|
|
|
|
2008-12-08 14:02:48 +01:00
|
|
|
static void test_handles( HWND full_hwnd )
|
|
|
|
{
|
|
|
|
HWND hwnd = full_hwnd;
|
|
|
|
BOOL ret;
|
|
|
|
RECT rect;
|
|
|
|
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = GetWindowRect( hwnd, &rect );
|
|
|
|
ok( ret, "GetWindowRect failed for %p err %u\n", hwnd, GetLastError() );
|
|
|
|
|
|
|
|
#ifdef _WIN64
|
|
|
|
if ((ULONG_PTR)full_hwnd >> 32)
|
|
|
|
hwnd = (HWND)((ULONG_PTR)full_hwnd & ~0u);
|
|
|
|
else
|
|
|
|
hwnd = (HWND)((ULONG_PTR)full_hwnd | ((ULONG_PTR)~0u << 32));
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = GetWindowRect( hwnd, &rect );
|
|
|
|
ok( ret, "GetWindowRect failed for %p err %u\n", hwnd, GetLastError() );
|
|
|
|
|
|
|
|
hwnd = (HWND)(((ULONG_PTR)full_hwnd & ~0u) | ((ULONG_PTR)0x1234 << 32));
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = GetWindowRect( hwnd, &rect );
|
|
|
|
ok( ret, "GetWindowRect failed for %p err %u\n", hwnd, GetLastError() );
|
|
|
|
|
|
|
|
hwnd = (HWND)(((ULONG_PTR)full_hwnd & 0xffff) | ((ULONG_PTR)0x9876 << 16));
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = GetWindowRect( hwnd, &rect );
|
|
|
|
ok( !ret, "GetWindowRect succeeded for %p\n", hwnd );
|
|
|
|
ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
|
|
|
|
|
|
|
|
hwnd = (HWND)(((ULONG_PTR)full_hwnd & 0xffff) | ((ULONG_PTR)0x12345678 << 16));
|
|
|
|
SetLastError( 0xdeadbeef );
|
|
|
|
ret = GetWindowRect( hwnd, &rect );
|
|
|
|
ok( !ret, "GetWindowRect succeeded for %p\n", hwnd );
|
|
|
|
ok( GetLastError() == ERROR_INVALID_WINDOW_HANDLE, "wrong error %u\n", GetLastError() );
|
|
|
|
#endif
|
|
|
|
}
|
2008-11-19 11:07:00 +01:00
|
|
|
|
2009-04-02 09:53:00 +02:00
|
|
|
static void test_winregion(void)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
RECT r;
|
|
|
|
int ret;
|
|
|
|
HRGN hrgn;
|
|
|
|
|
|
|
|
if (!pGetWindowRgnBox)
|
|
|
|
{
|
|
|
|
win_skip("GetWindowRgnBox not supported\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
hwnd = CreateWindowExA(0, "static", NULL, WS_VISIBLE, 10, 10, 10, 10, NULL, 0, 0, NULL);
|
|
|
|
/* NULL prect */
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pGetWindowRgnBox(hwnd, NULL);
|
|
|
|
ok( ret == ERROR, "Expected ERROR, got %d\n", ret);
|
|
|
|
ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
|
|
|
|
|
|
|
|
hrgn = CreateRectRgn(2, 3, 10, 15);
|
|
|
|
ok( hrgn != NULL, "Region creation failed\n");
|
|
|
|
if (hrgn)
|
|
|
|
{
|
|
|
|
SetWindowRgn(hwnd, hrgn, FALSE);
|
|
|
|
|
|
|
|
SetLastError(0xdeadbeef);
|
|
|
|
ret = pGetWindowRgnBox(hwnd, NULL);
|
|
|
|
ok( ret == ERROR, "Expected ERROR, got %d\n", ret);
|
|
|
|
ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError());
|
|
|
|
|
|
|
|
r.left = r.top = r.right = r.bottom = 0;
|
|
|
|
ret = pGetWindowRgnBox(hwnd, &r);
|
|
|
|
ok( ret == SIMPLEREGION, "Expected SIMPLEREGION, got %d\n", ret);
|
|
|
|
ok( r.left == 2 && r.top == 3 && r.right == 10 && r.bottom == 15,
|
|
|
|
"Expected (2,3,10,15), got (%d,%d,%d,%d)\n", r.left, r.top,
|
|
|
|
r.right, r.bottom);
|
|
|
|
DeleteObject(hrgn);
|
|
|
|
}
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
}
|
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
START_TEST(win)
|
|
|
|
{
|
2008-09-12 15:31:05 +02:00
|
|
|
HMODULE user32 = GetModuleHandleA( "user32.dll" );
|
|
|
|
pGetAncestor = (void *)GetProcAddress( user32, "GetAncestor" );
|
|
|
|
pGetWindowInfo = (void *)GetProcAddress( user32, "GetWindowInfo" );
|
|
|
|
pGetWindowModuleFileNameA = (void *)GetProcAddress( user32, "GetWindowModuleFileNameA" );
|
|
|
|
pGetLayeredWindowAttributes = (void *)GetProcAddress( user32, "GetLayeredWindowAttributes" );
|
|
|
|
pSetLayeredWindowAttributes = (void *)GetProcAddress( user32, "SetLayeredWindowAttributes" );
|
2008-10-16 12:58:56 +02:00
|
|
|
pGetMonitorInfoA = (void *)GetProcAddress( user32, "GetMonitorInfoA" );
|
|
|
|
pMonitorFromPoint = (void *)GetProcAddress( user32, "MonitorFromPoint" );
|
2009-04-02 09:53:00 +02:00
|
|
|
pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" );
|
2004-05-12 00:17:19 +02:00
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
if (!RegisterWindowClasses()) assert(0);
|
|
|
|
|
2003-10-24 06:22:24 +02:00
|
|
|
hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
|
2009-01-22 13:12:09 +01:00
|
|
|
if (!hhook) win_skip( "Cannot set CBT hook, skipping some tests\n" );
|
2003-10-24 06:22:24 +02:00
|
|
|
|
2002-09-25 02:21:56 +02:00
|
|
|
hwndMain = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
|
|
|
|
WS_MAXIMIZEBOX | WS_POPUP,
|
|
|
|
100, 100, 200, 200,
|
2008-02-19 13:17:13 +01:00
|
|
|
0, 0, GetModuleHandle(0), NULL);
|
2002-09-25 02:21:56 +02:00
|
|
|
hwndMain2 = CreateWindowExA(/*WS_EX_TOOLWINDOW*/ 0, "MainWindowClass", "Main window 2",
|
|
|
|
WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
|
|
|
|
WS_MAXIMIZEBOX | WS_POPUP,
|
|
|
|
100, 100, 200, 200,
|
2008-02-19 13:17:13 +01:00
|
|
|
0, 0, GetModuleHandle(0), NULL);
|
2002-09-25 02:21:56 +02:00
|
|
|
assert( hwndMain );
|
|
|
|
assert( hwndMain2 );
|
|
|
|
|
2008-02-19 13:17:13 +01:00
|
|
|
our_pid = GetWindowThreadProcessId(hwndMain, NULL);
|
|
|
|
|
2005-11-18 13:07:19 +01:00
|
|
|
/* Add the tests below this line */
|
2008-11-19 11:07:00 +01:00
|
|
|
test_thick_child_size(hwndMain);
|
2008-10-16 12:58:56 +02:00
|
|
|
test_fullscreen();
|
2008-06-25 15:24:02 +02:00
|
|
|
test_hwnd_message();
|
|
|
|
test_nonclient_area(hwndMain);
|
2005-05-14 20:49:19 +02:00
|
|
|
test_params();
|
2008-05-26 08:29:44 +02:00
|
|
|
test_GetWindowModuleFileName();
|
2004-08-26 20:33:40 +02:00
|
|
|
test_capture_1();
|
|
|
|
test_capture_2();
|
|
|
|
test_capture_3(hwndMain, hwndMain2);
|
|
|
|
|
2006-06-09 16:13:50 +02:00
|
|
|
test_CreateWindow();
|
2002-09-25 02:21:56 +02:00
|
|
|
test_parent_owner();
|
2005-03-02 11:11:06 +01:00
|
|
|
test_SetParent();
|
2009-10-23 14:46:58 +02:00
|
|
|
test_enum_thread_windows();
|
2003-12-30 22:54:54 +01:00
|
|
|
|
|
|
|
test_mdi();
|
2004-01-01 00:51:52 +01:00
|
|
|
test_icons();
|
2004-03-11 04:51:46 +01:00
|
|
|
test_SetWindowPos(hwndMain);
|
2004-03-19 20:14:45 +01:00
|
|
|
test_SetMenu(hwndMain);
|
2004-04-28 05:52:27 +02:00
|
|
|
test_SetFocus(hwndMain);
|
2004-05-18 02:48:09 +02:00
|
|
|
test_SetActiveWindow(hwndMain);
|
2009-07-10 01:10:07 +02:00
|
|
|
test_NCRedraw();
|
2003-12-30 22:54:54 +01:00
|
|
|
|
2004-04-13 00:05:53 +02:00
|
|
|
test_children_zorder(hwndMain);
|
2008-02-19 13:17:13 +01:00
|
|
|
test_popup_zorder(hwndMain2, hwndMain);
|
2004-09-16 21:09:44 +02:00
|
|
|
test_keyboard_input(hwndMain);
|
2004-12-17 19:49:24 +01:00
|
|
|
test_mouse_input(hwndMain);
|
2005-02-16 18:52:01 +01:00
|
|
|
test_validatergn(hwndMain);
|
2005-02-22 16:46:36 +01:00
|
|
|
test_nccalcscroll( hwndMain);
|
2009-09-24 11:17:26 +02:00
|
|
|
test_scrollwindow( hwndMain);
|
2005-03-25 18:11:04 +01:00
|
|
|
test_scrollvalidate( hwndMain);
|
2005-12-17 12:24:37 +01:00
|
|
|
test_scrolldc( hwndMain);
|
2005-03-29 13:29:50 +02:00
|
|
|
test_scroll();
|
2005-07-05 12:59:46 +02:00
|
|
|
test_IsWindowUnicode();
|
2005-09-26 18:46:31 +02:00
|
|
|
test_vis_rgn(hwndMain);
|
2004-04-13 00:05:53 +02:00
|
|
|
|
2005-05-24 11:51:20 +02:00
|
|
|
test_AdjustWindowRect();
|
2005-03-23 11:26:15 +01:00
|
|
|
test_window_styles();
|
2005-05-31 15:39:24 +02:00
|
|
|
test_redrawnow();
|
2005-08-02 11:56:25 +02:00
|
|
|
test_csparentdc();
|
2006-07-31 17:43:35 +02:00
|
|
|
test_SetWindowLong();
|
2006-12-04 08:06:54 +01:00
|
|
|
test_ShowWindow();
|
2008-11-11 23:00:10 +01:00
|
|
|
if (0) test_gettext(); /* crashes on NT4 */
|
2007-02-07 07:15:09 +01:00
|
|
|
test_GetUpdateRect();
|
2008-03-15 06:59:54 +01:00
|
|
|
test_Expose();
|
2008-09-12 15:31:05 +02:00
|
|
|
test_layered_window();
|
2005-11-18 13:07:19 +01:00
|
|
|
|
2008-11-11 23:00:10 +01:00
|
|
|
test_SetForegroundWindow(hwndMain);
|
2008-09-28 21:13:33 +02:00
|
|
|
test_shell_window();
|
2008-12-08 14:02:48 +01:00
|
|
|
test_handles( hwndMain );
|
2009-04-02 09:53:00 +02:00
|
|
|
test_winregion();
|
2008-09-28 21:13:33 +02:00
|
|
|
|
2005-11-18 13:07:19 +01:00
|
|
|
/* add the tests above this line */
|
2009-01-22 13:12:09 +01:00
|
|
|
if (hhook) UnhookWindowsHookEx(hhook);
|
2008-12-15 14:19:34 +01:00
|
|
|
|
|
|
|
DestroyWindow(hwndMain2);
|
|
|
|
DestroyWindow(hwndMain);
|
2002-09-25 02:21:56 +02:00
|
|
|
}
|