From: James Tabor Date: Fri, 10 Feb 2017 16:05:15 +0000 (+0000) Subject: [User32] X-Git-Tag: ReactOS-0.4.4-CLT2017~321 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=ebc1f941e0e92a0e1bfe537b2644c517f95d4dd7 [User32] - Patch by Dmitry Timoshkov : Fix groupbox rectangle calculation in the button's WM_SETTEXT handler. BUTTON_CalcLabelRect should use the button font. Otherwise WM_SETTEXT handler gets wrong rectangle to erase an old text. - Fixes CORE-12464. svn path=/trunk/; revision=73768 --- diff --git a/reactos/win32ss/user/user32/controls/button.c b/reactos/win32ss/user/user32/controls/button.c index 29cbbd45f20..1dc8af3b59b 100644 --- a/reactos/win32ss/user/user32/controls/button.c +++ b/reactos/win32ss/user/user32/controls/button.c @@ -496,6 +496,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg, GetClientRect(hWnd, &client); rc = client; + /* FIXME: check other BS_* handlers */ + if (btn_type == BS_GROUPBOX) + InflateRect(&rc, -7, 1); /* GB_Paint does this */ BUTTON_CalcLabelRect(hWnd, hdc, &rc); /* Clip by client rect bounds */ if (rc.right > client.right) rc.right = client.right; @@ -759,19 +762,26 @@ 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 ); #ifdef __REACTOS__ if (get_ui_state(hwnd) & UISF_HIDEACCEL) dtStyle |= DT_HIDEPREFIX; #endif break; + } case BS_ICON: if (!GetIconInfo((HICON)GetWindowLongPtrW( hwnd, HIMAGE_GWL_OFFSET ), &iconInfo))