comctl32/status: Do not draw background for status text.

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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2022-01-20 15:17:57 +08:00 committed by Alexandre Julliard
parent 1cdea98b18
commit ee3ec759d5
3 changed files with 39 additions and 32 deletions

View file

@ -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;

View file

@ -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.@]

View file

@ -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);
}
}