[PATCH 5/5] comctl32/status: Do not draw background for status text.

Zhiyi Zhang zzhang at codeweavers.com
Thu Jan 20 01:17:57 CST 2022


DrawStatusTextW() always draws the text background, so it's unfit to use it directly to draw status
text because status control draws its own background.

Fix status control text having wrong background when themed.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/comctl32/comctl32.h |  1 +
 dlls/comctl32/commctrl.c | 67 ++++++++++++++++++++++------------------
 dlls/comctl32/status.c   |  3 +-
 3 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h
index 44d3b43ab9b..f9ed8b84ffd 100644
--- a/dlls/comctl32/comctl32.h
+++ b/dlls/comctl32/comctl32.h
@@ -182,6 +182,7 @@ extern COMCTL32_SysColor  comctl32_color DECLSPEC_HIDDEN;
 
 /* Internal function */
 HWND COMCTL32_CreateToolTip (HWND) DECLSPEC_HIDDEN;
+void COMCTL32_DrawStatusText(HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style, BOOL draw_background) DECLSPEC_HIDDEN;
 VOID COMCTL32_RefreshSysColors(void) DECLSPEC_HIDDEN;
 void COMCTL32_DrawInsertMark(HDC hDC, const RECT *lpRect, COLORREF clrInsertMark, BOOL bHorizontal) DECLSPEC_HIDDEN;
 void COMCTL32_EnsureBitmapSize(HBITMAP *pBitmap, int cxMinWidth, int cyMinHeight, COLORREF crBackground) DECLSPEC_HIDDEN;
diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c
index b457bdcb8be..c707703ccd2 100644
--- a/dlls/comctl32/commctrl.c
+++ b/dlls/comctl32/commctrl.c
@@ -460,39 +460,25 @@ GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, const INT *lpInfo)
     } while (*lpRun);
 }
 
-
-/***********************************************************************
- * DrawStatusTextW [COMCTL32.@]
- *
- * Draws text with borders, like in a status bar.
- *
- * PARAMS
- *     hdc   [I] handle to the window's display context
- *     lprc  [I] pointer to a rectangle
- *     text  [I] pointer to the text
- *     style [I] drawing style
- *
- * RETURNS
- *     No return value.
- *
- * NOTES
- *     The style variable can have one of the following values:
- *     (will be written ...)
- */
-
-void WINAPI DrawStatusTextW (HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style)
+void COMCTL32_DrawStatusText(HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style, BOOL draw_background)
 {
     RECT r = *lprc;
-    UINT border = BDR_SUNKENOUTER;
+    UINT border;
     COLORREF oldbkcolor;
 
-    if (style & SBT_POPOUT)
-        border = BDR_RAISEDOUTER;
-    else if (style & SBT_NOBORDERS)
-        border = 0;
+    if (draw_background)
+    {
+        if (style & SBT_POPOUT)
+            border = BDR_RAISEDOUTER;
+        else if (style & SBT_NOBORDERS)
+            border = 0;
+        else
+            border = BDR_SUNKENOUTER;
 
-    oldbkcolor = SetBkColor (hdc, comctl32_color.clrBtnFace);
-    DrawEdge (hdc, &r, border, BF_MIDDLE|BF_RECT|BF_ADJUST);
+        oldbkcolor = SetBkColor (hdc, comctl32_color.clrBtnFace);
+        DrawEdge (hdc, &r, border, BF_MIDDLE|BF_RECT|BF_ADJUST);
+        SetBkColor (hdc, oldbkcolor);
+    }
 
     /* now draw text */
     if (text) {
@@ -524,10 +510,31 @@ void WINAPI DrawStatusTextW (HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style)
         SetBkMode (hdc, oldbkmode);
         SetTextColor (hdc, oldtextcolor);
     }
-
-    SetBkColor (hdc, oldbkcolor);
 }
 
+/***********************************************************************
+ * DrawStatusTextW [COMCTL32.@]
+ *
+ * Draws text with borders, like in a status bar.
+ *
+ * PARAMS
+ *     hdc   [I] handle to the window's display context
+ *     lprc  [I] pointer to a rectangle
+ *     text  [I] pointer to the text
+ *     style [I] drawing style
+ *
+ * RETURNS
+ *     No return value.
+ *
+ * NOTES
+ *     The style variable can have one of the following values:
+ *     (will be written ...)
+ */
+
+void WINAPI DrawStatusTextW(HDC hdc, LPCRECT lprc, LPCWSTR text, UINT style)
+{
+    COMCTL32_DrawStatusText(hdc, lprc, text, style, TRUE);
+}
 
 /***********************************************************************
  * DrawStatusText  [COMCTL32.@]
diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index 6fcdc32086a..e804c0418f4 100644
--- a/dlls/comctl32/status.c
+++ b/dlls/comctl32/status.c
@@ -139,7 +139,6 @@ STATUSBAR_DrawSizeGrip (HTHEME theme, HDC hdc, LPRECT lpRect)
     DrawFrameControl( hdc, &rc, DFC_SCROLL, DFCS_SCROLLSIZEGRIP );
 }
 
-
 static void
 STATUSBAR_DrawPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART *part, int itemID)
 {
@@ -187,7 +186,7 @@ STATUSBAR_DrawPart (const STATUS_INFO *infoPtr, HDC hdc, const STATUSWINDOWPART
         SendMessageW (infoPtr->Notify, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
     } else {
         r.left += x;
-        DrawStatusTextW (hdc, &r, part->text, SBT_NOBORDERS);
+        COMCTL32_DrawStatusText(hdc, &r, part->text, 0, FALSE);
     }
 }
 
-- 
2.32.0



More information about the wine-devel mailing list