Commit b7a08c92 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

user32/button: Do not select old font back after painting.

parent ab3c0a3e
...@@ -1096,7 +1096,7 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action ) ...@@ -1096,7 +1096,7 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action )
DRAWITEMSTRUCT dis; DRAWITEMSTRUCT dis;
LONG_PTR id = GetWindowLongPtrW( hwnd, GWLP_ID ); LONG_PTR id = GetWindowLongPtrW( 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;
...@@ -1111,7 +1111,7 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action ) ...@@ -1111,7 +1111,7 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action )
dis.itemData = 0; dis.itemData = 0;
GetClientRect( hwnd, &dis.rcItem ); GetClientRect( hwnd, &dis.rcItem );
if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hDC, hFont ); if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
parent = GetParent(hwnd); parent = GetParent(hwnd);
if (!parent) parent = hwnd; if (!parent) parent = hwnd;
SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd ); SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
...@@ -1119,7 +1119,6 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action ) ...@@ -1119,7 +1119,6 @@ static void OB_Paint( HWND hwnd, HDC hDC, UINT action )
hrgn = set_control_clipping( hDC, &dis.rcItem ); hrgn = set_control_clipping( hDC, &dis.rcItem );
SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis ); SendMessageW( GetParent(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 );
} }
...@@ -6466,15 +6466,13 @@ static void test_button_messages(void) ...@@ -6466,15 +6466,13 @@ static void test_button_messages(void)
prevfont = SelectObject(hdc, hfont2); prevfont = SelectObject(hdc, hfont2);
ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n"); ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n");
SendMessageA(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, 0); SendMessageA(hwnd, WM_PRINTCLIENT, (WPARAM)hdc, 0);
todo_wine ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i);
ok(GetStockObject(SYSTEM_FONT) == GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PRINTCLIENT\n", i);
SelectObject(hdc, prevfont); SelectObject(hdc, prevfont);
prevfont = SelectObject(hdc, hfont2); prevfont = SelectObject(hdc, hfont2);
ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n"); ok(prevfont == GetStockObject(SYSTEM_FONT), "Unexpected default font\n");
SendMessageA(hwnd, WM_PAINT, (WPARAM)hdc, 0); SendMessageA(hwnd, WM_PAINT, (WPARAM)hdc, 0);
todo_wine ok(hfont2 != GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PAINT\n", i);
ok(GetStockObject(SYSTEM_FONT) == GetCurrentObject(hdc, OBJ_FONT), "button[%u]: unexpected font selected after WM_PAINT\n", i);
SelectObject(hdc, prevfont); SelectObject(hdc, prevfont);
DeleteDC(hdc); DeleteDC(hdc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment