update for HEAD-2003050101
[reactos.git] / lib / user32 / windows / window.c
index 24d70e7..a95151b 100644 (file)
 #include <user32/callback.h>
 
 /* FUNCTIONS *****************************************************************/
+ULONG
+   WinHasThickFrameStyle(ULONG Style, ULONG ExStyle)
+{
+  return((Style & WS_THICKFRAME) &&
+        (!((Style & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)));
+}
 
 NTSTATUS STDCALL
 User32SendNCCALCSIZEMessageForKernel(PVOID Arguments, ULONG ArgumentLength)
@@ -161,6 +167,59 @@ User32CallWindowProcFromKernel(PVOID Arguments, ULONG ArgumentLength)
   return(ZwCallbackReturn(&Result, sizeof(LRESULT), STATUS_SUCCESS));
 }
 
+static void NC_AdjustRectOuter95 (LPRECT rect, DWORD style, BOOL menu, DWORD exStyle)
+{
+    int adjust;
+    if(style & WS_ICONIC) return;
+
+    if ((exStyle & (WS_EX_STATICEDGE|WS_EX_DLGMODALFRAME)) ==
+        WS_EX_STATICEDGE)
+    {
+        adjust = 1; /* for the outer frame always present */
+    }
+    else
+    {
+        adjust = 0;
+        if ((exStyle & WS_EX_DLGMODALFRAME) ||
+            (style & (WS_THICKFRAME|WS_DLGFRAME))) adjust = 2; /* outer */
+    }
+    if (style & WS_THICKFRAME)
+        adjust +=  ( GetSystemMetrics (SM_CXFRAME)
+                   - GetSystemMetrics (SM_CXDLGFRAME)); /* The resize border */
+    if ((style & (WS_BORDER|WS_DLGFRAME)) ||
+        (exStyle & WS_EX_DLGMODALFRAME))
+        adjust++; /* The other border */
+
+    InflateRect (rect, adjust, adjust);
+
+    if ((style & WS_CAPTION) == WS_CAPTION)
+    {
+        if (exStyle & WS_EX_TOOLWINDOW)
+            rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
+        else
+            rect->top -= GetSystemMetrics(SM_CYCAPTION);
+    }
+    if (menu) rect->top -= GetSystemMetrics(SM_CYMENU);
+}
+
+static void
+NC_AdjustRectInner95 (LPRECT rect, DWORD style, DWORD exStyle)
+{
+    if(style & WS_ICONIC) return;
+
+    if (exStyle & WS_EX_CLIENTEDGE)
+        InflateRect(rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
+
+    if (style & WS_VSCROLL)
+    {
+        if((exStyle & WS_EX_LEFTSCROLLBAR) != 0)
+            rect->left  -= GetSystemMetrics(SM_CXVSCROLL);
+        else
+            rect->right += GetSystemMetrics(SM_CXVSCROLL);
+    }
+    if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
+}
+
 WINBOOL STDCALL
 AdjustWindowRect(LPRECT lpRect,
                 DWORD dwStyle,
@@ -175,7 +234,16 @@ AdjustWindowRectEx(LPRECT lpRect,
                   WINBOOL bMenu, 
                   DWORD dwExStyle)
 {
-  return(FALSE);
+    dwStyle &= (WS_DLGFRAME | WS_BORDER | WS_THICKFRAME | WS_CHILD);
+    dwExStyle &= (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE |
+                WS_EX_STATICEDGE | WS_EX_TOOLWINDOW);
+    if (dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
+
+    NC_AdjustRectOuter95( lpRect, dwStyle, bMenu, dwExStyle );
+    NC_AdjustRectInner95( lpRect, dwStyle, dwExStyle );
+    lpRect->right += 2;
+    lpRect->bottom += 2;
+    return TRUE;
 }
 
 WINBOOL STDCALL
@@ -238,7 +306,10 @@ ChildWindowFromPointEx(HWND hwndParent,
 WINBOOL STDCALL
 CloseWindow(HWND hWnd)
 {
-  return FALSE;
+    SendMessageA(hWnd, WM_CLOSE, 0, 0);
+    SendMessageA(hWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
+    
+    return (WINBOOL)(hWnd);
 }
 
 HWND STDCALL
@@ -472,7 +543,10 @@ DeferWindowPos(HDWP hWinPosInfo,
 WINBOOL STDCALL
 DestroyWindow(HWND hWnd)
 {
-  return FALSE;
+  SendMessageW(hWnd, WM_DESTROY, 0, 0);
+  SendMessageW(hWnd, WM_NCDESTROY, 0, 0);
+
+  return NtUserDestroyWindow(hWnd);
 }
 
 WINBOOL STDCALL
@@ -577,7 +651,7 @@ GetAncestor(HWND hwnd, UINT gaFlags)
 WINBOOL STDCALL
 GetClientRect(HWND hWnd, LPRECT lpRect)
 {
-  return FALSE;
+  return(NtUserGetClientRect(hWnd, lpRect));
 }
 
 HWND STDCALL
@@ -608,7 +682,7 @@ GetLastActivePopup(HWND hWnd)
 HWND STDCALL
 GetParent(HWND hWnd)
 {
-  return (HWND)0;
+  return NtUserGetAncestor(hWnd, GA_PARENT);
 }
 
 WINBOOL STDCALL
@@ -757,7 +831,9 @@ IsWindowVisible(HWND hWnd)
 WINBOOL STDCALL
 IsZoomed(HWND hWnd)
 {
-  return FALSE;
+  ULONG uStyle = GetWindowLong(hWnd, GWL_STYLE);
+  
+  return (uStyle & WS_MAXIMIZE);
 }
 
 WINBOOL STDCALL
@@ -774,7 +850,7 @@ MoveWindow(HWND hWnd,
           int nHeight,
           WINBOOL bRepaint)
 {
-  return FALSE;
+    return NtUserMoveWindow(hWnd, X, Y, nWidth, nHeight, bRepaint);
 }
 
 WINBOOL STDCALL
@@ -919,8 +995,9 @@ MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints)
 
   NtUserGetClientOrigin(hWndFrom, &FromOffset);
   NtUserGetClientOrigin(hWndTo, &ToOffset);
-  XMove = ToOffset.x - FromOffset.x;
-  YMove = ToOffset.y - FromOffset.y;
+  XMove = FromOffset.x - ToOffset.x;
+  YMove = FromOffset.y - ToOffset.y;
+
   for (i = 0; i < cPoints; i++)
     {
       lpPoints[i].x += XMove;