- Fix a FIXME and fix the last test in wine Win test_ShowWindow.
[reactos.git] / reactos / win32ss / user / user32 / windows / window.c
index 6a59486..53ed882 100644 (file)
@@ -44,18 +44,12 @@ User32CallSendAsyncProcForKernel(PVOID Arguments, ULONG ArgumentLength)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL WINAPI
 AllowSetForegroundWindow(DWORD dwProcessId)
 {
-    static BOOL show_message = TRUE;
-    if (show_message)
-    {  
-        UNIMPLEMENTED;
-        show_message = FALSE;
-    }
-    return TRUE;
+    return NtUserxAllowSetForegroundWindow(dwProcessId);
 }
 
 
@@ -750,54 +744,29 @@ FindWindowExA(HWND hwndParent,
               LPCSTR lpszClass,
               LPCSTR lpszWindow)
 {
-    UNICODE_STRING ucClassName, *pucClassName = NULL;
-    UNICODE_STRING ucWindowName, *pucWindowName = NULL;
-    HWND Result;
+    LPWSTR titleW = NULL;
+    HWND hwnd = 0;
 
-    if (IS_ATOM(lpszClass))
+    if (lpszWindow)
     {
-        ucClassName.Buffer = (LPWSTR)lpszClass;
-        ucClassName.Length = 0;
-        pucClassName = &ucClassName;
+        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 );
     }
-    else if (lpszClass != NULL)
+
+    if (!IS_INTRESOURCE(lpszClass))
     {
-        if (!RtlCreateUnicodeStringFromAsciiz(&ucClassName,
-                                            (LPSTR)lpszClass))
-        {
-            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-            return NULL;
-        }
-        pucClassName = &ucClassName;
+        WCHAR classW[256];
+        if (MultiByteToWideChar( CP_ACP, 0, lpszClass, -1, classW, sizeof(classW)/sizeof(WCHAR) ))
+            hwnd = FindWindowExW( hwndParent, hwndChildAfter, classW, titleW );
     }
-
-    if (lpszWindow != NULL)
+    else
     {
-        if (!RtlCreateUnicodeStringFromAsciiz(&ucWindowName,
-                                            (LPSTR)lpszWindow))
-        {
-            if (!IS_ATOM(lpszClass) && lpszClass != NULL)
-                RtlFreeUnicodeString(&ucWindowName);
-
-            SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-            return NULL;
-        }
-
-        pucWindowName = &ucWindowName;
+        hwnd = FindWindowExW( hwndParent, hwndChildAfter, (LPCWSTR)lpszClass, titleW );
     }
 
-    Result = NtUserFindWindowEx(hwndParent,
-                                hwndChildAfter,
-                                pucClassName,
-                                pucWindowName,
-                                0);
-
-    if (!IS_ATOM(lpszClass) && lpszClass != NULL)
-        RtlFreeUnicodeString(&ucClassName);
-    if (lpszWindow != NULL)
-        RtlFreeUnicodeString(&ucWindowName);
-
-    return Result;
+    HeapFree( GetProcessHeap(), 0, titleW );
+    return hwnd;
 }
 
 
@@ -1002,8 +971,11 @@ GetLastActivePopup(HWND hWnd)
     {
         _SEH2_TRY
         {
-            if (Wnd->hWndLastActive)
-               Ret = Wnd->hWndLastActive;
+            if (Wnd->spwndLastActive)
+            {
+               PWND LastActive = DesktopPtrToUser(Wnd->spwndLastActive);
+               Ret = UserHMGetHandle(LastActive);
+            }
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
@@ -1056,21 +1028,12 @@ GetParent(HWND hWnd)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL WINAPI
 GetProcessDefaultLayout(DWORD *pdwDefaultLayout)
 {
-    if (!pdwDefaultLayout)
-    {
-        SetLastError(ERROR_INVALID_PARAMETER);
-        return FALSE;
-    }
-
-    UNIMPLEMENTED;
-
-    *pdwDefaultLayout = 0;
-    return TRUE;
+return (BOOL)NtUserCallOneParam( (DWORD_PTR)pdwDefaultLayout, ONEPARAM_ROUTINE_GETPROCDEFLAYOUT);
 }
 
 
@@ -1538,7 +1501,9 @@ IsWindow(HWND hWnd)
     PWND Wnd = ValidateHwndNoErr(hWnd);
     if (Wnd != NULL)
     {
-        /* FIXME: If window is being destroyed return FALSE! */
+        if (Wnd->state & WNDS_DESTROYED ||
+            Wnd->state2 & WNDS2_INDESTROY)
+           return FALSE;
         return TRUE;
     }
 
@@ -1627,13 +1592,12 @@ IsZoomed(HWND hWnd)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL WINAPI
 LockSetForegroundWindow(UINT uLockCode)
 {
-    UNIMPLEMENTED;
-    return TRUE;
+    return NtUserxLockSetForegroundWindow(uLockCode);
 }
 
 
@@ -1688,7 +1652,7 @@ HWND WINAPI
 RealChildWindowFromPoint(HWND hwndParent,
                          POINT ptParentClientCoords)
 {
-    return ChildWindowFromPointEx(hwndParent, ptParentClientCoords, CWP_SKIPTRANSPARENT | CWP_SKIPINVISIBLE);
+    return NtUserRealChildWindowFromPoint(hwndParent, ptParentClientCoords.x, ptParentClientCoords.y);
 }
 
 /*
@@ -1702,16 +1666,12 @@ SetForegroundWindow(HWND hWnd)
 
 
 /*
- * @unimplemented
+ * @implemented
  */
 BOOL WINAPI
 SetProcessDefaultLayout(DWORD dwDefaultLayout)
 {
-    if (dwDefaultLayout == 0)
-        return TRUE;
-
-    UNIMPLEMENTED;
-    return FALSE;
+return NtUserCallOneParam( (DWORD_PTR)dwDefaultLayout, ONEPARAM_ROUTINE_SETPROCDEFLAYOUT);
 }