Author: jimtabor
Date: Thu May 10 06:08:51 2012
New Revision: 56557

URL: http://svn.reactos.org/svn/reactos?rev=56557&view=rev
Log:
[Win32SS]
- Fix the remaining wine Win tests for FindWindow/Ex/A/W. Check the buffer not 
the length, buffer could be pointing to a null. Enable the message window 
handling. Use wine code for FindWindowExA.

Modified:
    trunk/reactos/win32ss/user/ntuser/window.c
    trunk/reactos/win32ss/user/user32/windows/window.c

Modified: trunk/reactos/win32ss/user/ntuser/window.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/window.c?rev=56557&r1=56556&r2=56557&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/window.c [iso-8859-1] Thu May 10 06:08:51 
2012
@@ -2509,7 +2509,7 @@
 
    ASSERT(Parent);
 
-   CheckWindowName = WindowName->Length != 0;
+   CheckWindowName = WindowName->Buffer != 0;
 
    if((List = IntWinListChildren(Parent)))
    {
@@ -2588,6 +2588,7 @@
    PWND Parent, ChildAfter;
    UNICODE_STRING ClassName = {0}, WindowName = {0};
    HWND Desktop, Ret = NULL;
+   BOOL DoMessageWnd = FALSE;
    RTL_ATOM ClassAtom = (RTL_ATOM)0;
    DECLARE_RETURN(HWND);
 
@@ -2657,7 +2658,10 @@
    Desktop = IntGetCurrentThreadDesktopWindow();
 
    if(hwndParent == NULL)
+   {
       hwndParent = Desktop;
+      DoMessageWnd = TRUE;
+   }
    else if(hwndParent == HWND_MESSAGE)
    {
      hwndParent = IntGetMessageWindow();
@@ -2698,7 +2702,7 @@
                    ;
              }
 
-             CheckWindowName = WindowName.Length != 0;
+             CheckWindowName = WindowName.Buffer != 0;
 
              /* search children */
              while(*phWnd)
@@ -2741,15 +2745,13 @@
           }
        }
        else
+       {
+          ERR("FindWindowEx: Not Desktop Parent!\n");
           Ret = IntFindWindow(Parent, ChildAfter, ClassAtom, &WindowName);
-
-#if 0
-
-       if(Ret == NULL && hwndParent == NULL && hwndChildAfter == NULL)
+       }
+
+       if (Ret == NULL && DoMessageWnd)
        {
-          /* FIXME:  If both hwndParent and hwndChildAfter are NULL, we also 
should
-                     search the message-only windows. Should this also be done 
if
-                     Parent is the desktop window??? */
           PWND MsgWindows;
 
           if((MsgWindows = UserGetWindowObject(IntGetMessageWindow())))
@@ -2757,7 +2759,6 @@
              Ret = IntFindWindow(MsgWindows, ChildAfter, ClassAtom, 
&WindowName);
           }
        }
-#endif
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {

Modified: trunk/reactos/win32ss/user/user32/windows/window.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/windows/window.c?rev=56557&r1=56556&r2=56557&view=diff
==============================================================================
--- trunk/reactos/win32ss/user/user32/windows/window.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/user32/windows/window.c [iso-8859-1] Thu May 10 
06:08:51 2012
@@ -744,54 +744,29 @@
               LPCSTR lpszClass,
               LPCSTR lpszWindow)
 {
-    UNICODE_STRING ucClassName, *pucClassName = NULL;
-    UNICODE_STRING ucWindowName, *pucWindowName = NULL;
-    HWND Result;
-
-    if (IS_ATOM(lpszClass))
-    {
-        ucClassName.Buffer = (LPWSTR)lpszClass;
-        ucClassName.Length = 0;
-        pucClassName = &ucClassName;
-    }
-    else if (lpszClass != NULL)
-    {
-        if (!RtlCreateUnicodeStringFromAsciiz(&ucClassName,
-                                            (LPSTR)lpszClass))
-        {
-            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-            return NULL;
-        }
-        pucClassName = &ucClassName;
-    }
-
-    if (lpszWindow != NULL)
-    {
-        if (!RtlCreateUnicodeStringFromAsciiz(&ucWindowName,
-                                            (LPSTR)lpszWindow))
-        {
-            if (!IS_ATOM(lpszClass) && lpszClass != NULL)
-                RtlFreeUnicodeString(&ucWindowName);
-
-            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-            return NULL;
-        }
-
-        pucWindowName = &ucWindowName;
-    }
-
-    Result = NtUserFindWindowEx(hwndParent,
-                                hwndChildAfter,
-                                pucClassName,
-                                pucWindowName,
-                                0);
-
-    if (!IS_ATOM(lpszClass) && lpszClass != NULL)
-        RtlFreeUnicodeString(&ucClassName);
-    if (lpszWindow != NULL)
-        RtlFreeUnicodeString(&ucWindowName);
-
-    return Result;
+    LPWSTR titleW = NULL;
+    HWND hwnd = 0;
+
+    if (lpszWindow)
+    {
+        DWORD len = MultiByteToWideChar( CP_ACP, 0, lpszWindow, -1, NULL, 0 );
+        if (!(titleW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) 
return 0;
+        MultiByteToWideChar( CP_ACP, 0, lpszWindow, -1, titleW, len );
+    }
+
+    if (!IS_INTRESOURCE(lpszClass))
+    {
+        WCHAR classW[256];
+        if (MultiByteToWideChar( CP_ACP, 0, lpszClass, -1, classW, 
sizeof(classW)/sizeof(WCHAR) ))
+            hwnd = FindWindowExW( hwndParent, hwndChildAfter, classW, titleW );
+    }
+    else
+    {
+        hwnd = FindWindowExW( hwndParent, hwndChildAfter, (LPCWSTR)lpszClass, 
titleW );
+    }
+
+    HeapFree( GetProcessHeap(), 0, titleW );
+    return hwnd;
 }
 
 


Reply via email to