[PATCH 1/3] user32: Always restore previously selected font in the button painting helpers.
Nikolay Sivov
nsivov at codeweavers.com
Sun Feb 5 11:52:46 CST 2017
From: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
Series for https://bugs.winehq.org/show_bug.cgi?id=41830
dlls/user32/button.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index e85e30daaf..4a03314201 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -752,7 +752,7 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action )
HBRUSH hOldBrush;
INT oldBkMode;
COLORREF oldTxtColor;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
LONG state = get_button_state( hwnd );
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
BOOL pushedState = (state & BST_PUSHED);
@@ -762,7 +762,7 @@ static void PB_Paint( HWND hwnd, HDC hDC, UINT action )
GetClientRect( hwnd, &rc );
/* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
@@ -829,6 +829,7 @@ draw_focus:
SetBkMode(hDC, oldBkMode);
SelectClipRgn( hDC, hrgn );
if (hrgn) DeleteObject( hrgn );
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
/**********************************************************************
@@ -841,7 +842,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
HBRUSH hBrush;
int delta, text_offset, checkBoxWidth, checkBoxHeight;
UINT dtFlags;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
LONG state = get_button_state( hwnd );
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
LONG ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
@@ -860,7 +861,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
GetCharWidthW( hDC, '0', '0', &text_offset );
text_offset /= 2;
@@ -962,6 +963,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
}
SelectClipRgn( hDC, hrgn );
if (hrgn) DeleteObject( hrgn );
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
@@ -996,14 +998,14 @@ static void GB_Paint( HWND hwnd, HDC hDC, UINT action )
{
RECT rc, rcFrame;
HBRUSH hbr;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
UINT dtFlags;
TEXTMETRICW tm;
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
HWND parent;
HRGN hrgn;
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
/* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
@@ -1038,6 +1040,7 @@ static void GB_Paint( HWND hwnd, HDC hDC, UINT action )
}
SelectClipRgn( hDC, hrgn );
if (hrgn) DeleteObject( hrgn );
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
@@ -1049,13 +1052,13 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
{
RECT rc;
HBRUSH hBrush;
- HFONT hFont;
+ HFONT hFont, hPrevFont = 0;
LONG state = get_button_state( hwnd );
HWND parent;
GetClientRect( hwnd, &rc);
- if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
+ if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont );
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
@@ -1082,6 +1085,8 @@ static void UB_Paint( HWND hwnd, HDC hDC, UINT action )
BUTTON_NOTIFY_PARENT( hwnd, BN_PAINT );
break;
}
+
+ if (hPrevFont) SelectObject( hDC, hPrevFont );
}
--
2.11.0
More information about the wine-patches
mailing list