From 1f31cc412ee8345b403c361f30b6f6c5d47a01ae Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Tue, 28 Oct 2003 22:46:30 +0000 Subject: [PATCH] - Fixed more bugs reported by Wine user32 window test. (72/373 tests fail now) svn path=/trunk/; revision=6451 --- reactos/include/defines.h | 1 + reactos/lib/user32/windows/window.c | 12 +----- reactos/subsys/win32k/ntuser/window.c | 57 +++++++++++++++++++++------ 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/reactos/include/defines.h b/reactos/include/defines.h index 915ec30bc93..ed9e3023c32 100644 --- a/reactos/include/defines.h +++ b/reactos/include/defines.h @@ -2542,6 +2542,7 @@ extern "C" { #define HWND_NOTOPMOST ((HWND)-2) #define HWND_TOP ((HWND)0) #define HWND_TOPMOST ((HWND)-1) +#define HWND_MESSAGE ((HWND)-3) #define SWP_DRAWFRAME (32) #define SWP_FRAMECHANGED (32) #define SWP_HIDEWINDOW (128) diff --git a/reactos/lib/user32/windows/window.c b/reactos/lib/user32/windows/window.c index 4c3c0561128..7f2f5edd8b7 100644 --- a/reactos/lib/user32/windows/window.c +++ b/reactos/lib/user32/windows/window.c @@ -1,4 +1,4 @@ -/* $Id: window.c,v 1.75 2003/10/25 22:57:34 navaraf Exp $ +/* $Id: window.c,v 1.76 2003/10/28 22:46:30 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -402,11 +402,6 @@ CreateWindowExA(DWORD dwExStyle, ControlsInitCalled = TRUE; } - if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD && !hWndParent) - { - return (HWND)0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ - } - if (IS_ATOM(lpClassName)) { RtlInitUnicodeString(&ClassName, NULL); @@ -549,11 +544,6 @@ CreateWindowExW(DWORD dwExStyle, ControlsInitCalled = TRUE; } - if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD && !hWndParent) - { - return (HWND)0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ - } - if (IS_ATOM(lpClassName)) { RtlInitUnicodeString(&ClassName, NULL); diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 0ea63482bb1..328c3b9b6b6 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.122 2003/10/28 20:24:09 navaraf Exp $ +/* $Id: window.c,v 1.123 2003/10/28 22:46:30 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -851,6 +851,14 @@ IntSetFocusWindow(HWND hWnd) } +PWINDOW_OBJECT FASTCALL +IntSetOwner(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewOwner) +{ + HWND ret = Wnd->hWndOwner; + Wnd->hWndOwner = WndNewOwner; + return ret; +} + PWINDOW_OBJECT FASTCALL IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent) { @@ -860,6 +868,7 @@ IntSetParent(PWINDOW_OBJECT Wnd, PWINDOW_OBJECT WndNewParent) if (Wnd->Self == IntGetDesktopWindow()) { + SetLastWin32Error(STATUS_ACCESS_DENIED); return NULL; } @@ -1233,6 +1242,8 @@ NtUserCreateWindowEx(DWORD dwExStyle, PWNDCLASS_OBJECT ClassObject; PWINDOW_OBJECT WindowObject; PWINDOW_OBJECT ParentWindow; + HWND ParentWindowHandle; + HWND OwnerWindowHandle; PMENU_OBJECT SystemMenu; UNICODE_STRING WindowName; NTSTATUS Status; @@ -1259,17 +1270,32 @@ NtUserCreateWindowEx(DWORD dwExStyle, return((HWND)0); } - /* FIXME: parent must belong to the current process */ + ParentWindowHandle = PsGetWin32Thread()->Desktop->DesktopWindow; + OwnerWindowHandle = NULL; - if (hWndParent != NULL) + if (hWndParent == HWND_MESSAGE) { - ParentWindow = IntGetWindowObject(hWndParent); + /* + * native ole32.OleInitialize uses HWND_MESSAGE to create the + * message window (style: WS_POPUP|WS_DISABLED) + */ + UNIMPLEMENTED; } - else + else if (hWndParent) { - hWndParent = PsGetWin32Thread()->Desktop->DesktopWindow; - ParentWindow = IntGetWindowObject(hWndParent); + if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD) + ParentWindowHandle = hWndParent; + else + OwnerWindowHandle = NtUserGetAncestor(hWndParent, GA_ROOT); } + else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD) + { + return (HWND)0; /* WS_CHILD needs a parent, but WS_POPUP doesn't */ + } + + ParentWindow = IntGetWindowObject(ParentWindowHandle); + + /* FIXME: parent must belong to the current process */ /* Check the class. */ Status = ClassReferenceClassByNameOrAtom(&ClassObject, lpClassName->Buffer); @@ -1337,7 +1363,8 @@ NtUserCreateWindowEx(DWORD dwExStyle, WindowObject->Width = nWidth; WindowObject->Height = nHeight; WindowObject->ContextHelpId = 0; - WindowObject->ParentHandle = hWndParent; + WindowObject->ParentHandle = ParentWindowHandle; + WindowObject->hWndOwner = OwnerWindowHandle; WindowObject->IDMenu = (UINT)hMenu; WindowObject->Instance = hInstance; WindowObject->Parameters = lpParam; @@ -1449,7 +1476,7 @@ NtUserCreateWindowEx(DWORD dwExStyle, Cs.lpCreateParams = lpParam; Cs.hInstance = hInstance; Cs.hMenu = hMenu; - Cs.hwndParent = hWndParent; + Cs.hwndParent = ParentWindowHandle; Cs.cx = nWidth; Cs.cy = nHeight; Cs.x = x; @@ -2301,7 +2328,7 @@ NtUserGetWindowLong(HWND hWnd, DWORD Index, BOOL Ansi) case GWL_HWNDPARENT: if (WindowObject->ParentHandle == IntGetDesktopWindow()) { - Result = 0; + Result = (LONG) WindowObject->hWndOwner; } else { @@ -3034,8 +3061,14 @@ NtUserSetWindowLong(HWND hWnd, DWORD Index, LONG NewValue, BOOL Ansi) break; case GWL_HWNDPARENT: - OldValue = (LONG) WindowObject->ParentHandle; - IntSetParent(WindowObject, (HWND) NewValue); + if (WindowObject->ParentHandle == IntGetDesktopWindow()) + { + OldValue = (LONG) IntSetOwner(WindowObject, (HWND) NewValue); + } + else + { + OldValue = (LONG) IntSetParent(WindowObject, (HWND) NewValue); + } break; case GWL_ID: