[ros-diffs] [fireball] 50453: - Change DrawFocusRect to use PatBlt instead of alternate pen, as it's done in trunk. It looks like earlier Windows also used PatBlt for this purpose, and even Wine itself hints t...

fireball at svn.reactos.org fireball at svn.reactos.org
Fri Jan 21 17:19:59 UTC 2011


Author: fireball
Date: Fri Jan 21 17:19:57 2011
New Revision: 50453

URL: http://svn.reactos.org/svn/reactos?rev=50453&view=rev
Log:
- Change DrawFocusRect to use PatBlt instead of alternate pen, as it's done in trunk. It looks like earlier Windows also used PatBlt for this purpose, and even Wine itself hints that it should be done this way. Fixes bug #5280.

Modified:
    branches/arwinss/reactos/dll/win32/user32/uitools.c

Modified: branches/arwinss/reactos/dll/win32/user32/uitools.c
URL: http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user32/uitools.c?rev=50453&r1=50452&r2=50453&view=diff
==============================================================================
--- branches/arwinss/reactos/dll/win32/user32/uitools.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/dll/win32/user32/uitools.c [iso-8859-1] Fri Jan 21 17:19:57 2011
@@ -1493,31 +1493,37 @@
 
 /***********************************************************************
  *		DrawFocusRect (USER32.@)
- *
- * FIXME: PatBlt(PATINVERT) with background brush.
- */
-BOOL WINAPI DrawFocusRect( HDC hdc, const RECT* rc )
-{
-    HBRUSH hOldBrush;
-    HPEN hOldPen, hNewPen;
-    INT oldDrawMode, oldBkMode;
-    LOGBRUSH lb;
-
-    hOldBrush = SelectObject(hdc, GetStockObject(NULL_BRUSH));
-    lb.lbStyle = BS_SOLID;
-    lb.lbColor = GetSysColor(COLOR_WINDOWTEXT);
-    hNewPen = ExtCreatePen(PS_COSMETIC|PS_ALTERNATE, 1, &lb, 0, NULL);
-    hOldPen = SelectObject(hdc, hNewPen);
-    oldDrawMode = SetROP2(hdc, R2_XORPEN);
-    oldBkMode = SetBkMode(hdc, TRANSPARENT);
-
-    Rectangle(hdc, rc->left, rc->top, rc->right, rc->bottom);
-
-    SetBkMode(hdc, oldBkMode);
-    SetROP2(hdc, oldDrawMode);
-    SelectObject(hdc, hOldPen);
-    DeleteObject(hNewPen);
-    SelectObject(hdc, hOldBrush);
+ */
+BOOL WINAPI DrawFocusRect( HDC hdc, const RECT* rect )
+{
+    static HBRUSH hFocusRectBrush = NULL;
+    HGDIOBJ OldObj;
+    UINT cx, cy;
+
+    if(!hFocusRectBrush)
+    {
+        static HBITMAP hFocusPattern = NULL;
+        const DWORD Pattern[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA};
+
+        hFocusPattern = CreateBitmap(8, 8, 1, 1, Pattern);
+        hFocusRectBrush = CreatePatternBrush(hFocusPattern);
+    }
+
+    SystemParametersInfoW(SPI_GETFOCUSBORDERWIDTH, 0, &cx, 0);
+    SystemParametersInfoW(SPI_GETFOCUSBORDERHEIGHT, 0, &cy, 0);
+
+    OldObj = SelectObject(hdc, hFocusRectBrush);
+
+    /* top */
+    PatBlt(hdc, rect->left, rect->top, rect->right - rect->left, cy, PATINVERT);
+    /* bottom */
+    PatBlt(hdc, rect->left, rect->bottom - cy, rect->right - rect->left, cy, PATINVERT);
+    /* left */
+    PatBlt(hdc, rect->left, rect->top + cy, cx, rect->bottom - rect->top - (2 * cy), PATINVERT);
+    /* right */
+    PatBlt(hdc, rect->right - cx, rect->top + cy, cx, rect->bottom - rect->top - (2 * cy), PATINVERT);
+
+    SelectObject(hdc, OldObj);
 
     return TRUE;
 }




More information about the Ros-diffs mailing list