comctl32/button: Do not select old font back after painting.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b7a08c9281
commit
81e698da27
|
@ -1220,7 +1220,7 @@ static void OB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
|
||||||
DRAWITEMSTRUCT dis;
|
DRAWITEMSTRUCT dis;
|
||||||
LONG_PTR id = GetWindowLongPtrW( infoPtr->hwnd, GWLP_ID );
|
LONG_PTR id = GetWindowLongPtrW( infoPtr->hwnd, GWLP_ID );
|
||||||
HWND parent;
|
HWND parent;
|
||||||
HFONT hFont, hPrevFont = 0;
|
HFONT hFont;
|
||||||
HRGN hrgn;
|
HRGN hrgn;
|
||||||
|
|
||||||
dis.CtlType = ODT_BUTTON;
|
dis.CtlType = ODT_BUTTON;
|
||||||
|
@ -1235,7 +1235,7 @@ static void OB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
|
||||||
dis.itemData = 0;
|
dis.itemData = 0;
|
||||||
GetClientRect( infoPtr->hwnd, &dis.rcItem );
|
GetClientRect( infoPtr->hwnd, &dis.rcItem );
|
||||||
|
|
||||||
if ((hFont = infoPtr->font)) hPrevFont = SelectObject( hDC, hFont );
|
if ((hFont = infoPtr->font)) SelectObject( hDC, hFont );
|
||||||
parent = GetParent(infoPtr->hwnd);
|
parent = GetParent(infoPtr->hwnd);
|
||||||
if (!parent) parent = infoPtr->hwnd;
|
if (!parent) parent = infoPtr->hwnd;
|
||||||
SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd );
|
SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)infoPtr->hwnd );
|
||||||
|
@ -1243,7 +1243,6 @@ static void OB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
|
||||||
hrgn = set_control_clipping( hDC, &dis.rcItem );
|
hrgn = set_control_clipping( hDC, &dis.rcItem );
|
||||||
|
|
||||||
SendMessageW( GetParent(infoPtr->hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
|
SendMessageW( GetParent(infoPtr->hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
|
||||||
if (hPrevFont) SelectObject(hDC, hPrevFont);
|
|
||||||
SelectClipRgn( hDC, hrgn );
|
SelectClipRgn( hDC, hrgn );
|
||||||
if (hrgn) DeleteObject( hrgn );
|
if (hrgn) DeleteObject( hrgn );
|
||||||
}
|
}
|
||||||
|
|
|
@ -519,11 +519,12 @@ static void test_button_messages(void)
|
||||||
setfocus_seq, killfocus_seq, setstyle_seq,
|
setfocus_seq, killfocus_seq, setstyle_seq,
|
||||||
setstate_seq, setstate_seq, setcheck_ignored_seq },
|
setstate_seq, setstate_seq, setcheck_ignored_seq },
|
||||||
};
|
};
|
||||||
|
LOGFONTA logfont = { 0 };
|
||||||
const struct message *seq;
|
const struct message *seq;
|
||||||
|
HFONT zfont, hfont2;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
HWND hwnd, parent;
|
HWND hwnd, parent;
|
||||||
DWORD dlg_code;
|
DWORD dlg_code;
|
||||||
HFONT zfont;
|
|
||||||
BOOL todo;
|
BOOL todo;
|
||||||
|
|
||||||
/* selection with VK_SPACE should capture button window */
|
/* selection with VK_SPACE should capture button window */
|
||||||
|
@ -540,10 +541,19 @@ static void test_button_messages(void)
|
||||||
100, 100, 200, 200, 0, 0, 0, NULL);
|
100, 100, 200, 200, 0, 0, 0, NULL);
|
||||||
ok(parent != 0, "Failed to create parent window\n");
|
ok(parent != 0, "Failed to create parent window\n");
|
||||||
|
|
||||||
|
logfont.lfHeight = -12;
|
||||||
|
logfont.lfWeight = FW_NORMAL;
|
||||||
|
strcpy(logfont.lfFaceName, "Tahoma");
|
||||||
|
|
||||||
|
hfont2 = CreateFontIndirectA(&logfont);
|
||||||
|
ok(hfont2 != NULL, "Failed to create Tahoma font\n");
|
||||||
|
|
||||||
for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
|
for (i = 0; i < sizeof(button)/sizeof(button[0]); i++)
|
||||||
{
|
{
|
||||||
|
HFONT prevfont, hfont;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
DWORD style, state;
|
DWORD style, state;
|
||||||
|
HDC hdc;
|
||||||
|
|
||||||
trace("%d: button test sequence\n", i);
|
trace("%d: button test sequence\n", i);
|
||||||
hwnd = create_button(button[i].style, parent);
|
hwnd = create_button(button[i].style, parent);
|
||||||
|
@ -686,9 +696,32 @@ static void test_button_messages(void)
|
||||||
else
|
else
|
||||||
ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
|
ok(style == button[i].style, "expected style %04x got %04x\n", button[i].style, style);
|
||||||
|
|
||||||
|
/* Test that original font is not selected back after painting */
|
||||||
|
hfont = (HFONT)SendMessageA(hwnd, WM_GETFONT, 0, 0);
|
||||||
|
ok(hfont == NULL, "Unexpected control font.\n");
|
||||||
|
|
||||||
|
SendMessageA(hwnd, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0);
|
||||||
|
|
||||||
|
hdc = CreateCompatibleDC(0);
|
||||||
|
|
||||||
|
prevfont = SelectObject(hdc, hfont2);
|
||||||
|
SendMessageA(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, 0);
|
||||||
|
ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT) || broken(hfont2 == GetCurrentObject(hdc, OBJ_FONT)) /* WinXP */,
|
||||||
|
"button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i);
|
||||||
|
SelectObject(hdc, prevfont);
|
||||||
|
|
||||||
|
prevfont = SelectObject(hdc, hfont2);
|
||||||
|
SendMessageA(hwnd, WM_PAINT, (WPARAM)hdc, 0);
|
||||||
|
ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT) || broken(hfont2 == GetCurrentObject(hdc, OBJ_FONT)) /* WinXP */,
|
||||||
|
"button[%u]: unexpected font selected after WM_PAINT\n", i);
|
||||||
|
SelectObject(hdc, prevfont);
|
||||||
|
|
||||||
|
DeleteDC(hdc);
|
||||||
|
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeleteObject(hfont2);
|
||||||
DestroyWindow(parent);
|
DestroyWindow(parent);
|
||||||
|
|
||||||
hwnd = create_button(BS_PUSHBUTTON, NULL);
|
hwnd = create_button(BS_PUSHBUTTON, NULL);
|
||||||
|
|
Loading…
Reference in New Issue