comctl32/button: Do not restore push button font after themed painting.

Fix button tests failures when theming is on.

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2021-10-01 11:26:53 +08:00 committed by Alexandre Julliard
parent 760acf6c13
commit 8b30c00a7b
1 changed files with 5 additions and 8 deletions

View File

@ -2656,13 +2656,13 @@ cleanup:
static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused)
{
RECT bgRect, textRect;
HFONT font = infoPtr->font;
HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL;
NMCUSTOMDRAW nmcd;
LRESULT cdrf;
HWND parent;
WCHAR *text;
if (infoPtr->font) SelectObject(hDC, infoPtr->font);
GetClientRect(infoPtr->hwnd, &bgRect);
GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect);
init_custom_draw(&nmcd, infoPtr, hDC, &bgRect);
@ -2672,7 +2672,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
/* Send erase notifications */
cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
if (cdrf & CDRF_SKIPDEFAULT) goto cleanup;
if (cdrf & CDRF_SKIPDEFAULT) return;
if (IsThemeBackgroundPartiallyTransparent(theme, BP_PUSHBUTTON, state))
DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL);
@ -2687,7 +2687,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
/* Send paint notifications */
nmcd.dwDrawStage = CDDS_PREPAINT;
cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
if (cdrf & CDRF_SKIPDEFAULT) goto cleanup;
if (cdrf & CDRF_SKIPDEFAULT) return;
if (!(cdrf & CDRF_DOERASE) && (text = get_button_text(infoPtr)))
{
@ -2700,7 +2700,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
nmcd.dwDrawStage = CDDS_POSTPAINT;
SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
}
if (cdrf & CDRF_SKIPPOSTPAINT) goto cleanup;
if (cdrf & CDRF_SKIPPOSTPAINT) return;
if (focused)
{
@ -2716,9 +2716,6 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
DrawFocusRect( hDC, &focusRect );
}
cleanup:
if (hPrevFont) SelectObject(hDC, hPrevFont);
}
static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused)