Sync with trunk r43123
[reactos.git] / reactos / dll / win32 / user32 / windows / defwnd.c
index 4a328f5..52da270 100644 (file)
@@ -52,7 +52,7 @@ InitStockObjects(void)
              SysColors table - the pens, brushes and stock objects are not affected
              as their handles never change. But it'd be faster to map them, too. */
 
- // Done! g_psi!
+ // Done! gpsi!
 }
 
 /*
@@ -63,7 +63,7 @@ GetSysColor(int nIndex)
 {
   if(nIndex >= 0 && nIndex < NUM_SYSCOLORS)
   {
-    return g_psi->argbSystem[nIndex];
+    return gpsi->argbSystem[nIndex];
   }
 
   SetLastError(ERROR_INVALID_PARAMETER);
@@ -78,7 +78,7 @@ GetSysColorBrush(int nIndex)
 {
   if(nIndex >= 0 && nIndex < NUM_SYSCOLORS)
   {
-    return g_psi->ahbrSystem[nIndex];
+    return gpsi->ahbrSystem[nIndex];
   }
 
   SetLastError(ERROR_INVALID_PARAMETER);
@@ -970,7 +970,7 @@ static void DefWndPrint( HWND hwnd, HDC hdc, ULONG uFlags)
    * Client area
    */
   if ( uFlags & PRF_CLIENT)
-    SendMessageW(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, PRF_CLIENT);
+    SendMessageW(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, uFlags);
 }
 
 static BOOL CALLBACK
@@ -1148,7 +1148,7 @@ User32DefWindowProc(HWND hWnd,
             else
             {
                 POINT Pt;
-                DWORD Style;
+                LONG_PTR Style;
                 LONG HitCode;
 
                 Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
@@ -1245,7 +1245,14 @@ User32DefWindowProc(HWND hWnd,
 
         case WM_SETREDRAW:
         {
-            DefWndSetRedraw(hWnd, wParam);
+            LONG_PTR Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
+            if (wParam) SetWindowLongPtr(hWnd, GWL_STYLE, Style | WS_VISIBLE);
+            else
+            {
+                RedrawWindow(hWnd, NULL, 0, RDW_ALLCHILDREN | RDW_VALIDATE);
+                Style &= ~WS_VISIBLE;
+                SetWindowLongPtr(hWnd, GWL_STYLE, Style);
+            }
             return (0);
         }
 
@@ -1345,7 +1352,7 @@ User32DefWindowProc(HWND hWnd,
 
         case WM_SETCURSOR:
         {
-            ULONG Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
+            LONG_PTR Style = GetWindowLongPtrW(hWnd, GWL_STYLE);
 
             if (Style & WS_CHILD)
             {
@@ -1518,7 +1525,15 @@ User32DefWindowProc(HWND hWnd,
             return ((LRESULT)LoadIconW(0, IDI_APPLICATION));
         }
 
-        /* FIXME: WM_ISACTIVEICON */
+        case WM_ISACTIVEICON:
+        {
+           PWND pWnd;
+           BOOL isai;
+           pWnd = ValidateHwnd(hWnd);
+           if (!pWnd) return 0;
+           isai = (pWnd->state & WNDS_ACTIVEFRAME) != 0;
+           return isai;
+        }
 
         case WM_NOTIFYFORMAT:
         {
@@ -1777,7 +1792,7 @@ User32DefWindowProc(HWND hWnd,
             /* Pack the information and call win32k */
             if (Change)
             {
-                if (!NtUserCallTwoParam((DWORD)hWnd, (DWORD)Flags | ((DWORD)Action << 3), TWOPARAM_ROUTINE_ROS_UPDATEUISTATE))
+                if (!NtUserCallTwoParam((DWORD_PTR)hWnd, (DWORD_PTR)Flags | ((DWORD_PTR)Action << 3), TWOPARAM_ROUTINE_ROS_UPDATEUISTATE))
                     break;
             }
 
@@ -1864,10 +1879,10 @@ DefWndImmIsUIMessageW(HWND hwndIME, UINT msg, WPARAM wParam, LPARAM lParam)
 
 
 LRESULT WINAPI
-DefWindowProcA(HWND hWnd,
-              UINT Msg,
-              WPARAM wParam,
-              LPARAM lParam)
+RealDefWindowProcA(HWND hWnd,
+                   UINT Msg,
+                   WPARAM wParam,
+                   LPARAM lParam)
 {
     LRESULT Result = 0;
     PWND Wnd;
@@ -1877,13 +1892,17 @@ DefWindowProcA(HWND hWnd,
     {
         case WM_NCCREATE:
         {
-            LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
-            /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
-             * may have child window IDs instead of window name */
-
-             DefSetText(hWnd, (PCWSTR)cs->lpszName, TRUE);
-
-            Result = 1;
+            if (lParam)
+            {
+                LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam;
+                /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
+                 * may have child window IDs instead of window name */
+                if (HIWORD(cs->lpszName))
+                {
+                    DefSetText(hWnd, (PCWSTR)cs->lpszName, TRUE);
+                }
+                Result = 1;
+            }
             break;
         }
 
@@ -2013,10 +2032,10 @@ DefWindowProcA(HWND hWnd,
 
 
 LRESULT WINAPI
-DefWindowProcW(HWND hWnd,
-              UINT Msg,
-              WPARAM wParam,
-              LPARAM lParam)
+RealDefWindowProcW(HWND hWnd,
+                   UINT Msg,
+                   WPARAM wParam,
+                   LPARAM lParam)
 {
     LRESULT Result = 0;
     PWND Wnd;
@@ -2026,12 +2045,18 @@ DefWindowProcW(HWND hWnd,
     {
         case WM_NCCREATE:
         {
-            LPCREATESTRUCTW cs = (LPCREATESTRUCTW)lParam;
-            /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
-             * may have child window IDs instead of window name */
+            if (lParam)
+            {
+                LPCREATESTRUCTW cs = (LPCREATESTRUCTW)lParam;
+                /* check for string, as static icons, bitmaps (SS_ICON, SS_BITMAP)
+                 * may have child window IDs instead of window name */
 
-            DefSetText(hWnd, cs->lpszName, FALSE);
-            Result = 1;
+                if (HIWORD(cs->lpszName))
+                {
+                    DefSetText(hWnd, cs->lpszName, FALSE);
+                }
+                Result = 1;
+            }
             break;
         }
 
@@ -2150,3 +2175,68 @@ DefWindowProcW(HWND hWnd,
     return Result;
 }
 
+LRESULT WINAPI
+DefWindowProcA(HWND hWnd,
+              UINT Msg,
+              WPARAM wParam,
+              LPARAM lParam)
+{
+   BOOL Hook, msgOverride = FALSE;
+   LRESULT Result = 0;
+
+   LOADUSERAPIHOOK
+
+   Hook = BeginIfHookedUserApiHook();
+   if (Hook)
+      msgOverride = IsMsgOverride(Msg, &guah.DefWndProcArray);
+
+   /* Bypass SEH and go direct. */
+   if (!Hook || !msgOverride)
+      return RealDefWindowProcA(hWnd, Msg, wParam, lParam);
+
+   _SEH2_TRY
+   {
+      Result = guah.DefWindowProcA(hWnd, Msg, wParam, lParam);
+   }
+   _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+   {
+   }
+   _SEH2_END;
+
+   EndUserApiHook();
+
+   return Result;
+}
+
+LRESULT WINAPI
+DefWindowProcW(HWND hWnd,
+              UINT Msg,
+              WPARAM wParam,
+              LPARAM lParam)
+{
+   BOOL Hook, msgOverride = FALSE;
+   LRESULT Result = 0;
+
+   LOADUSERAPIHOOK
+
+   Hook = BeginIfHookedUserApiHook();
+   if (Hook)
+      msgOverride = IsMsgOverride(Msg, &guah.DefWndProcArray);
+
+   /* Bypass SEH and go direct. */
+   if (!Hook || !msgOverride)
+      return RealDefWindowProcW(hWnd, Msg, wParam, lParam);
+
+   _SEH2_TRY
+   {
+      Result = guah.DefWindowProcW(hWnd, Msg, wParam, lParam);
+   }
+   _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+   {
+   }
+   _SEH2_END;
+
+   EndUserApiHook();
+
+   return Result;
+}