mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
- Implement FindWindowEx for case when ClassName == NULL.
svn path=/trunk/; revision=9068
This commit is contained in:
parent
d0003f99f5
commit
17abe3357c
2 changed files with 52 additions and 27 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: window.c,v 1.108 2004/04/09 20:03:15 navaraf Exp $
|
/* $Id: window.c,v 1.109 2004/04/10 07:37:28 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS user32.dll
|
* PROJECT: ReactOS user32.dll
|
||||||
|
@ -677,7 +677,12 @@ FindWindowExA(HWND hwndParent,
|
||||||
UNICODE_STRING ucWindowName;
|
UNICODE_STRING ucWindowName;
|
||||||
HWND Result;
|
HWND Result;
|
||||||
|
|
||||||
if (IS_ATOM(lpszClass))
|
if (lpszClass == NULL)
|
||||||
|
{
|
||||||
|
ucClassName.Buffer = NULL;
|
||||||
|
ucClassName.Length = 0;
|
||||||
|
}
|
||||||
|
else if (IS_ATOM(lpszClass))
|
||||||
{
|
{
|
||||||
ucClassName.Buffer = (LPWSTR)lpszClass;
|
ucClassName.Buffer = (LPWSTR)lpszClass;
|
||||||
ucClassName.Length = 0;
|
ucClassName.Length = 0;
|
||||||
|
@ -709,26 +714,30 @@ FindWindowExW(HWND hwndParent,
|
||||||
LPCWSTR lpszClass,
|
LPCWSTR lpszClass,
|
||||||
LPCWSTR lpszWindow)
|
LPCWSTR lpszWindow)
|
||||||
{
|
{
|
||||||
UNICODE_STRING ucClassName;
|
UNICODE_STRING ucClassName;
|
||||||
UNICODE_STRING ucWindowName;
|
UNICODE_STRING ucWindowName;
|
||||||
|
|
||||||
if (IS_ATOM(lpszClass))
|
if (lpszClass == NULL)
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&ucClassName, NULL);
|
ucClassName.Buffer = NULL;
|
||||||
ucClassName.Buffer = (LPWSTR)lpszClass;
|
ucClassName.Length = 0;
|
||||||
}
|
}
|
||||||
else
|
else if (IS_ATOM(lpszClass))
|
||||||
{
|
{
|
||||||
RtlInitUnicodeString(&ucClassName, lpszClass);
|
RtlInitUnicodeString(&ucClassName, NULL);
|
||||||
}
|
ucClassName.Buffer = (LPWSTR)lpszClass;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RtlInitUnicodeString(&ucClassName, lpszClass);
|
||||||
|
}
|
||||||
|
|
||||||
// Window names can't be atoms, and if lpszWindow = NULL,
|
// Window names can't be atoms, and if lpszWindow = NULL,
|
||||||
// RtlInitUnicodeString will clear it
|
// RtlInitUnicodeString will clear it
|
||||||
|
|
||||||
RtlInitUnicodeString(&ucWindowName, lpszWindow);
|
RtlInitUnicodeString(&ucWindowName, lpszWindow);
|
||||||
|
|
||||||
|
return NtUserFindWindowEx(hwndParent, hwndChildAfter, &ucClassName, &ucWindowName);
|
||||||
return NtUserFindWindowEx(hwndParent, hwndChildAfter, &ucClassName, &ucWindowName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: window.c,v 1.210 2004/04/09 20:03:19 navaraf Exp $
|
/* $Id: window.c,v 1.211 2004/04/10 07:37:28 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -2056,13 +2056,20 @@ NtUserFindWindowEx(HWND hwndParent,
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
HWND windowHandle;
|
HWND windowHandle;
|
||||||
PWINDOW_OBJECT ParentWindow, WndChildAfter, WndChild;
|
PWINDOW_OBJECT ParentWindow, WndChildAfter, WndChild;
|
||||||
PWNDCLASS_OBJECT classObject;
|
PWNDCLASS_OBJECT classObject = NULL;
|
||||||
|
|
||||||
|
DPRINT1("NtUserFindWindowEx(%x,%x,%wZ,%wZ)\n",
|
||||||
|
hwndParent, hwndChildAfter, ucClassName, ucWindowName);
|
||||||
|
|
||||||
// Get a pointer to the class
|
// Get a pointer to the class
|
||||||
status = ClassReferenceClassByNameOrAtom(&classObject, ucClassName->Buffer);
|
if (ucClassName->Buffer != NULL)
|
||||||
if (!NT_SUCCESS(status))
|
|
||||||
{
|
{
|
||||||
return NULL;
|
status = ClassReferenceClassByNameOrAtom(&classObject, ucClassName->Buffer);
|
||||||
|
if (!NT_SUCCESS(status))
|
||||||
|
{
|
||||||
|
DPRINT1("Error 1\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If hwndParent==NULL use the desktop window instead
|
// If hwndParent==NULL use the desktop window instead
|
||||||
|
@ -2074,7 +2081,9 @@ NtUserFindWindowEx(HWND hwndParent,
|
||||||
|
|
||||||
if(!ParentWindow)
|
if(!ParentWindow)
|
||||||
{
|
{
|
||||||
ObmDereferenceObject(classObject);
|
if (classObject != NULL)
|
||||||
|
ObmDereferenceObject(classObject);
|
||||||
|
DPRINT1("Error 2\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2085,6 +2094,7 @@ NtUserFindWindowEx(HWND hwndParent,
|
||||||
if (!(WndChildAfter = IntGetWindowObject(hwndChildAfter)))
|
if (!(WndChildAfter = IntGetWindowObject(hwndChildAfter)))
|
||||||
{
|
{
|
||||||
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
||||||
|
DPRINT1("Error 3\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2092,6 +2102,7 @@ NtUserFindWindowEx(HWND hwndParent,
|
||||||
IntLockRelatives(WndChildAfter);
|
IntLockRelatives(WndChildAfter);
|
||||||
if (WndChildAfter->Parent != ParentWindow->Self)
|
if (WndChildAfter->Parent != ParentWindow->Self)
|
||||||
{
|
{
|
||||||
|
DPRINT1("Error 4\n");
|
||||||
IntUnLockRelatives(WndChildAfter);
|
IntUnLockRelatives(WndChildAfter);
|
||||||
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
SetLastWin32Error(ERROR_INVALID_PARAMETER);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -2107,15 +2118,18 @@ NtUserFindWindowEx(HWND hwndParent,
|
||||||
|
|
||||||
while (WndChild)
|
while (WndChild)
|
||||||
{
|
{
|
||||||
if (classObject == WndChild->Class && (ucWindowName->Buffer==NULL ||
|
if ((classObject == NULL || classObject == WndChild->Class) &&
|
||||||
|
(ucWindowName->Buffer==NULL ||
|
||||||
RtlCompareUnicodeString (ucWindowName, &WndChild->WindowName, TRUE) == 0))
|
RtlCompareUnicodeString (ucWindowName, &WndChild->WindowName, TRUE) == 0))
|
||||||
{
|
{
|
||||||
windowHandle = WndChild->Self;
|
windowHandle = WndChild->Self;
|
||||||
|
|
||||||
IntUnLockRelatives(ParentWindow);
|
IntUnLockRelatives(ParentWindow);
|
||||||
IntReleaseWindowObject(ParentWindow);
|
IntReleaseWindowObject(ParentWindow);
|
||||||
ObmDereferenceObject (classObject);
|
if (classObject != NULL)
|
||||||
|
ObmDereferenceObject (classObject);
|
||||||
|
|
||||||
|
DPRINT1("Success: %x\n", windowHandle);
|
||||||
return windowHandle;
|
return windowHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2125,8 +2139,10 @@ NtUserFindWindowEx(HWND hwndParent,
|
||||||
IntUnLockRelatives(ParentWindow);
|
IntUnLockRelatives(ParentWindow);
|
||||||
|
|
||||||
IntReleaseWindowObject(ParentWindow);
|
IntReleaseWindowObject(ParentWindow);
|
||||||
ObmDereferenceObject (classObject);
|
if (classObject != NULL)
|
||||||
|
ObmDereferenceObject (classObject);
|
||||||
|
|
||||||
|
DPRINT1("Not found\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue