diff --git a/win32ss/gdi/ntgdi/gdibatch.c b/win32ss/gdi/ntgdi/gdibatch.c
index ab68c503037..d7acd6b3a5b 100644
--- a/win32ss/gdi/ntgdi/gdibatch.c
+++ b/win32ss/gdi/ntgdi/gdibatch.c
@@ -94,9 +94,9 @@ GdiFlushUserBatch(PDC dc, PGDIBATCHHDR pHdr)
      case GdiBCPatBlt:
      {
         PGDIBSPATBLT pgDPB;
-        DWORD dwRop, flags;
-        HBRUSH hOrgBrush;
-        COLORREF crColor, crBkColor, crBrushClr;
+        DWORD dwRop, flags = 0, savedflags;
+        HBRUSH hOrgBrush = (HBRUSH)-1;
+        COLORREF crColor = -1, crBkColor, crBrushClr;
         ULONG ulForegroundClr, ulBackgroundClr, ulBrushClr;
         if (!dc) break;
         pgDPB = (PGDIBSPATBLT) pHdr;
@@ -116,22 +116,42 @@ GdiFlushUserBatch(PDC dc, PGDIBATCHHDR pHdr)
            break;
         }
         // Save current attributes and flags
-        crColor         = dc->pdcattr->crForegroundClr;
-        crBkColor       = dc->pdcattr->ulBackgroundClr;
-        crBrushClr      = dc->pdcattr->crBrushClr;
-        ulForegroundClr = dc->pdcattr->ulForegroundClr;
-        ulBackgroundClr = dc->pdcattr->ulBackgroundClr;
-        ulBrushClr      = dc->pdcattr->ulBrushClr;
-        hOrgBrush       = dc->pdcattr->hbrush;
-        flags = dc->pdcattr->ulDirty_ & (DIRTY_BACKGROUND | DIRTY_TEXT | DIRTY_FILL | DC_BRUSH_DIRTY);
-        // Set the attribute snapshot
-        dc->pdcattr->hbrush          = pgDPB->hbrush; 
-        dc->pdcattr->crForegroundClr = pgDPB->crForegroundClr;
-        dc->pdcattr->crBackgroundClr = pgDPB->crBackgroundClr;
-        dc->pdcattr->crBrushClr      = pgDPB->crBrushClr;
-        dc->pdcattr->ulForegroundClr = pgDPB->ulForegroundClr;
-        dc->pdcattr->ulBackgroundClr = pgDPB->ulBackgroundClr;
-        dc->pdcattr->ulBrushClr      = pgDPB->ulBrushClr;
+        savedflags = dc->pdcattr->ulDirty_ & (DIRTY_BACKGROUND | DIRTY_TEXT | DIRTY_FILL | DC_BRUSH_DIRTY);
+
+        // Save current attributes and flags
+        if ( dc->pdcattr->crForegroundClr != pgDPB->crForegroundClr )
+        {
+            crColor = dc->pdcattr->crForegroundClr;
+            dc->pdcattr->crForegroundClr = pgDPB->crForegroundClr;
+            ulForegroundClr = dc->pdcattr->ulForegroundClr;
+            dc->pdcattr->ulForegroundClr = pgDPB->ulForegroundClr;
+            flags |= (DIRTY_FILL|DIRTY_LINE|DIRTY_TEXT);
+        }
+        if ( dc->pdcattr->crBackgroundClr != pgDPB->crBackgroundClr )
+        {
+            crBkColor = dc->pdcattr->ulBackgroundClr;
+            dc->pdcattr->crBackgroundClr = pgDPB->crBackgroundClr;
+            ulBackgroundClr = dc->pdcattr->ulBackgroundClr;
+            dc->pdcattr->ulBackgroundClr = pgDPB->ulBackgroundClr;
+            flags |= (DIRTY_FILL|DIRTY_LINE|DIRTY_TEXT|DIRTY_BACKGROUND);
+        }
+        if ( dc->pdcattr->crBrushClr != pgDPB->crBrushClr )
+        {
+            ulBrushClr = dc->pdcattr->ulBrushClr;
+            crBrushClr = dc->pdcattr->crBrushClr;
+            dc->pdcattr->crBrushClr = pgDPB->crBrushClr;
+            dc->pdcattr->ulBrushClr = pgDPB->ulBrushClr;
+            flags |= DIRTY_FILL|DC_BRUSH_DIRTY;
+        }
+        if ( dc->pdcattr->hbrush != pgDPB->hbrush)
+        {
+            hOrgBrush = dc->pdcattr->hbrush;
+            dc->pdcattr->hbrush = pgDPB->hbrush;
+            flags |= DIRTY_FILL;
+        }
+
+        dc->pdcattr->ulDirty_ |= flags;
+
         // Process dirty attributes if any.
         if (dc->pdcattr->ulDirty_ & (DIRTY_FILL | DC_BRUSH_DIRTY))
             DC_vUpdateFillBrush(dc);
@@ -139,17 +159,32 @@ GdiFlushUserBatch(PDC dc, PGDIBATCHHDR pHdr)
             DC_vUpdateTextBrush(dc);
         if (pdcattr->ulDirty_ & DIRTY_BACKGROUND)
             DC_vUpdateBackgroundBrush(dc);
+
         /* Call the internal function */
         IntPatBlt(dc, pgDPB->nXLeft, pgDPB->nYLeft, pgDPB->nWidth, pgDPB->nHeight, dwRop, &dc->eboFill);
+
         // Restore attributes and flags
-        dc->pdcattr->hbrush          = hOrgBrush;
-        dc->pdcattr->crForegroundClr = crColor;
-        dc->pdcattr->crBackgroundClr = crBkColor;
-        dc->pdcattr->crBrushClr      = crBrushClr;
-        dc->pdcattr->ulForegroundClr = ulForegroundClr;
-        dc->pdcattr->ulBackgroundClr = ulBackgroundClr;
-        dc->pdcattr->ulBrushClr      = ulBrushClr;
-        dc->pdcattr->ulDirty_ |= flags;
+        if (flags & DC_BRUSH_DIRTY)
+        {
+           dc->pdcattr->crBrushClr = crBrushClr;
+           dc->pdcattr->ulBrushClr = ulBrushClr;
+        }
+        if (flags & DIRTY_TEXT && crColor != -1)
+        {
+            dc->pdcattr->crForegroundClr = crColor;
+            dc->pdcattr->ulForegroundClr = ulForegroundClr;
+        }
+        if (flags & DIRTY_BACKGROUND)
+        {
+            dc->pdcattr->crBackgroundClr = crBkColor;
+            dc->pdcattr->ulBackgroundClr = ulBackgroundClr;
+        }
+        if ( hOrgBrush != (HBRUSH)-1 )
+        {
+            dc->pdcattr->hbrush = hOrgBrush;
+            DC_vUpdateFillBrush(dc);
+        }
+        dc->pdcattr->ulDirty_ |= savedflags | flags;
         break;
      }
 
@@ -160,8 +195,8 @@ GdiFlushUserBatch(PDC dc, PGDIBATCHHDR pHdr)
         PBRUSH pbrush;
         PPATRECT pRects;
         INT i;
-        DWORD dwRop, flags;
-        COLORREF crColor, crBkColor, crBrushClr;
+        DWORD dwRop, flags = 0, savedflags;
+        COLORREF crColor = -1, crBkColor, crBrushClr;
         ULONG ulForegroundClr, ulBackgroundClr, ulBrushClr;
         if (!dc) break;
         pgDPB = (PGDIBSPPATBLT) pHdr;
@@ -180,21 +215,39 @@ GdiFlushUserBatch(PDC dc, PGDIBATCHHDR pHdr)
            /* Nothing to do */
            break;
         }
+
+        savedflags = dc->pdcattr->ulDirty_ & (DIRTY_BACKGROUND | DIRTY_TEXT | DIRTY_FILL | DC_BRUSH_DIRTY);
+
         // Save current attributes and flags
-        crColor         = dc->pdcattr->crForegroundClr;
-        crBkColor       = dc->pdcattr->ulBackgroundClr;
-        crBrushClr      = dc->pdcattr->crBrushClr;
-        ulForegroundClr = dc->pdcattr->ulForegroundClr;
-        ulBackgroundClr = dc->pdcattr->ulBackgroundClr;
-        ulBrushClr      = dc->pdcattr->ulBrushClr;
-        flags = dc->pdcattr->ulDirty_ & (DIRTY_BACKGROUND | DIRTY_TEXT | DIRTY_FILL | DC_BRUSH_DIRTY);
-        // Set the attribute snapshot
-        dc->pdcattr->crForegroundClr = pgDPB->crForegroundClr;
-        dc->pdcattr->crBackgroundClr = pgDPB->crBackgroundClr;
-        dc->pdcattr->crBrushClr      = pgDPB->crBrushClr;
-        dc->pdcattr->ulForegroundClr = pgDPB->ulForegroundClr;
-        dc->pdcattr->ulBackgroundClr = pgDPB->ulBackgroundClr;
-        dc->pdcattr->ulBrushClr      = pgDPB->ulBrushClr;
+        if ( dc->pdcattr->crForegroundClr != pgDPB->crForegroundClr )
+        {
+            crColor = dc->pdcattr->crForegroundClr;
+            dc->pdcattr->crForegroundClr = pgDPB->crForegroundClr;
+            ulForegroundClr = dc->pdcattr->ulForegroundClr;
+            dc->pdcattr->ulForegroundClr = pgDPB->ulForegroundClr;
+            flags |= (DIRTY_FILL|DIRTY_LINE|DIRTY_TEXT);
+        }
+
+        if ( dc->pdcattr->crBackgroundClr != pgDPB->crBackgroundClr )
+        {
+            crBkColor = dc->pdcattr->ulBackgroundClr;
+            dc->pdcattr->crBackgroundClr = pgDPB->crBackgroundClr;
+            ulBackgroundClr = dc->pdcattr->ulBackgroundClr;
+            dc->pdcattr->ulBackgroundClr = pgDPB->ulBackgroundClr;
+            flags |= (DIRTY_FILL|DIRTY_LINE|DIRTY_TEXT|DIRTY_BACKGROUND);
+        }
+
+        if ( dc->pdcattr->crBrushClr != pgDPB->crBrushClr )
+        {
+            ulBrushClr = dc->pdcattr->ulBrushClr;
+            crBrushClr = dc->pdcattr->crBrushClr;
+            dc->pdcattr->crBrushClr = pgDPB->crBrushClr;
+            dc->pdcattr->ulBrushClr = pgDPB->ulBrushClr;
+            flags |= DIRTY_FILL|DC_BRUSH_DIRTY;
+        }
+
+        dc->pdcattr->ulDirty_ |= flags;
+
         // Process dirty attributes if any
         if (dc->pdcattr->ulDirty_ & DIRTY_TEXT)
             DC_vUpdateTextBrush(dc);
@@ -231,13 +284,23 @@ GdiFlushUserBatch(PDC dc, PGDIBATCHHDR pHdr)
         }
 
         // Restore attributes and flags
-        dc->pdcattr->crForegroundClr = crColor;
-        dc->pdcattr->crBackgroundClr = crBkColor;
-        dc->pdcattr->crBrushClr      = crBrushClr;
-        dc->pdcattr->ulForegroundClr = ulForegroundClr;
-        dc->pdcattr->ulBackgroundClr = ulBackgroundClr;
-        dc->pdcattr->ulBrushClr      = ulBrushClr;
-        dc->pdcattr->ulDirty_ |= flags;
+        if (flags & DIRTY_TEXT && crColor != -1)
+        {
+            dc->pdcattr->crForegroundClr = crColor;
+            dc->pdcattr->ulForegroundClr = ulForegroundClr;
+        }
+        if (flags & DIRTY_BACKGROUND)
+        {
+            dc->pdcattr->crBackgroundClr = crBkColor;
+            dc->pdcattr->ulBackgroundClr = ulBackgroundClr;
+        }
+
+        if (flags & DC_BRUSH_DIRTY)
+        {
+           dc->pdcattr->crBrushClr      = crBrushClr;
+           dc->pdcattr->ulBrushClr      = ulBrushClr;
+        }
+        dc->pdcattr->ulDirty_ |= savedflags | flags;
         break;
      }
 
