From 0a9026f76e7c5ca73d8015d094863f800f415be5 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Sat, 17 Nov 2007 06:50:23 +0000 Subject: [PATCH] Optimize IsChild() to use the desktop heap instead of calling win32k svn path=/trunk/; revision=30519 --- reactos/dll/win32/user32/windows/window.c | 42 +++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index fc3f2f7ebe9..559ece8439c 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1252,18 +1252,40 @@ BOOL STDCALL IsChild(HWND hWndParent, HWND hWnd) { - if (! IsWindow(hWndParent) || ! IsWindow(hWnd)) - { - return FALSE; - } + PWINDOW WndParent, Wnd; + BOOL Ret = FALSE; - do - { - hWnd = (HWND)NtUserGetWindowLong(hWnd, GWL_HWNDPARENT, FALSE); - } - while (hWnd != NULL && hWnd != hWndParent); + WndParent = ValidateHwnd(hWndParent); + if (!WndParent) + return FALSE; + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return FALSE; - return hWnd == hWndParent; + _SEH_TRY + { + while (Wnd != NULL) + { + if (Wnd->Parent != NULL) + { + Wnd = DesktopPtrToUser(Wnd->Parent); + if (Wnd == WndParent) + { + Ret = TRUE; + break; + } + } + else + break; + } + } + _SEH_HANDLE + { + /* Do nothing */ + } + _SEH_END; + + return Ret; }