[v3 PATCH 2/3] user32: BUTTON_CalcLabelRect should use the button font.

Nikolay Sivov nsivov at codeweavers.com
Mon Feb 6 05:23:41 CST 2017


From: Dmitry Timoshkov <dmitry at baikal.ru>

Otherwise WM_SETTEXT handler gets wrong rectangle to erase an old text.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/user32/button.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/dlls/user32/button.c b/dlls/user32/button.c
index e85e30daaf..cc70e37306 100644
--- a/dlls/user32/button.c
+++ b/dlls/user32/button.c
@@ -598,15 +598,22 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
    switch (style & (BS_ICON|BS_BITMAP))
    {
       case BS_TEXT:
+      {
+          HFONT hFont, hPrevFont = 0;
+
           if (!(text = get_button_text( hwnd ))) goto empty_rect;
           if (!text[0])
           {
               HeapFree( GetProcessHeap(), 0, text );
               goto empty_rect;
           }
+
+          if ((hFont = get_button_font( hwnd ))) hPrevFont = SelectObject( hdc, hFont );
           DrawTextW(hdc, text, -1, &r, dtStyle | DT_CALCRECT);
+          if (hPrevFont) SelectObject( hdc, hPrevFont );
           HeapFree( GetProcessHeap(), 0, text );
           break;
+      }
 
       case BS_ICON:
          if (!GetIconInfo((HICON)GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ), &iconInfo))
-- 
2.11.0




More information about the wine-patches mailing list