From 2bf00ca962f6dfc850b7ba456b83e1b020aec685 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Tue, 28 Dec 2010 07:22:42 +0000 Subject: [PATCH] [Win32k|User32] - Fix all the user32 wine win test_SetParent tests. svn path=/trunk/; revision=50181 --- reactos/dll/win32/user32/windows/window.c | 5 +- .../subsystems/win32/win32k/ntuser/window.c | 139 ++++++++++-------- 2 files changed, 77 insertions(+), 67 deletions(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 1b1a0894e15..9ad0f2198c3 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1450,15 +1450,12 @@ IsChild(HWND hWndParent, _SEH2_TRY { - while (Wnd != NULL) + while (Wnd != NULL && ((Wnd->style & (WS_POPUP|WS_CHILD)) == WS_CHILD)) { if (Wnd->spwndParent != NULL) { Wnd = DesktopPtrToUser(Wnd->spwndParent); - if(Wnd == DesktopWnd) - Wnd = NULL; - if (Wnd == WndParent) { Ret = TRUE; diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 95a43d6ff37..f1e70cf63c0 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -899,16 +899,12 @@ IntIsChildWindow(PWND Parent, PWND BaseWindow) PWND Window; Window = BaseWindow; - while (Window) + while (Window && ((Window->style & (WS_POPUP|WS_CHILD)) == WS_CHILD)) { if (Window == Parent) { return(TRUE); } - if(!(Window->style & WS_CHILD)) - { - break; - } Window = Window->spwndParent; } @@ -1090,7 +1086,7 @@ IntSetOwner(HWND hWnd, HWND hWndNewOwner) PWND FASTCALL co_IntSetParent(PWND Wnd, PWND WndNewParent) { - PWND WndOldParent; + PWND WndOldParent, pWndExam; BOOL WasVisible; ASSERT(Wnd); @@ -1098,6 +1094,12 @@ co_IntSetParent(PWND Wnd, PWND WndNewParent) ASSERT_REFS_CO(Wnd); ASSERT_REFS_CO(WndNewParent); + if (Wnd == Wnd->head.rpdesk->spwndMessage) + { + EngSetLastError(ERROR_ACCESS_DENIED); + return( NULL); + } + /* Some applications try to set a child as a parent */ if (IntIsChildWindow(Wnd, WndNewParent)) { @@ -1105,6 +1107,18 @@ co_IntSetParent(PWND Wnd, PWND WndNewParent) return NULL; } + pWndExam = WndNewParent; // Load parent Window to examine. + // Now test for set parent to parent hit. + while (pWndExam) + { + if (Wnd == pWndExam) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + pWndExam = pWndExam->spwndParent; + } + /* * Windows hides the window first, then shows it again * including the WM_SHOWWINDOW messages and all @@ -1150,6 +1164,62 @@ co_IntSetParent(PWND Wnd, PWND WndNewParent) return WndOldParent; } +HWND FASTCALL +co_UserSetParent(HWND hWndChild, HWND hWndNewParent) +{ + PWND Wnd = NULL, WndParent = NULL, WndOldParent; + HWND hWndOldParent = NULL; + USER_REFERENCE_ENTRY Ref, ParentRef; + + if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent)) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + return( NULL); + } + + if (hWndChild == IntGetDesktopWindow()) + { + EngSetLastError(ERROR_ACCESS_DENIED); + return( NULL); + } + + if (hWndNewParent) + { + if (!(WndParent = UserGetWindowObject(hWndNewParent))) + { + return( NULL); + } + } + else + { + if (!(WndParent = UserGetWindowObject(IntGetDesktopWindow()))) + { + return( NULL); + } + } + + if (!(Wnd = UserGetWindowObject(hWndChild))) + { + return( NULL); + } + + UserRefObjectCo(Wnd, &Ref); + UserRefObjectCo(WndParent, &ParentRef); + + WndOldParent = co_IntSetParent(Wnd, WndParent); + + UserDerefObjectCo(WndParent); + UserDerefObjectCo(Wnd); + + if (WndOldParent) + { + hWndOldParent = WndOldParent->head.h; + UserDereferenceObject(WndOldParent); + } + + return( hWndOldParent); +} + BOOL FASTCALL IntSetSystemMenu(PWND Window, PMENU_OBJECT Menu) { @@ -3057,63 +3127,6 @@ CLEANUP: END_CLEANUP; } - -HWND FASTCALL -co_UserSetParent(HWND hWndChild, HWND hWndNewParent) -{ - PWND Wnd = NULL, WndParent = NULL, WndOldParent; - HWND hWndOldParent = NULL; - USER_REFERENCE_ENTRY Ref, ParentRef; - - if (IntIsBroadcastHwnd(hWndChild) || IntIsBroadcastHwnd(hWndNewParent)) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - return( NULL); - } - - if (hWndChild == IntGetDesktopWindow()) - { - EngSetLastError(ERROR_ACCESS_DENIED); - return( NULL); - } - - if (hWndNewParent) - { - if (!(WndParent = UserGetWindowObject(hWndNewParent))) - { - return( NULL); - } - } - else - { - if (!(WndParent = UserGetWindowObject(IntGetDesktopWindow()))) - { - return( NULL); - } - } - - if (!(Wnd = UserGetWindowObject(hWndChild))) - { - return( NULL); - } - - UserRefObjectCo(Wnd, &Ref); - UserRefObjectCo(WndParent, &ParentRef); - - WndOldParent = co_IntSetParent(Wnd, WndParent); - - UserDerefObjectCo(WndParent); - UserDerefObjectCo(Wnd); - - if (WndOldParent) - { - hWndOldParent = WndOldParent->head.h; - UserDereferenceObject(WndOldParent); - } - - return( hWndOldParent); -} - /* * NtUserSetParent *