[PATCH 1/3] comctl32/button: Simplify focus rectangle calculation for drawing themed push buttons.
The focus rectangle is the same as the result from GetThemeBackgroundContentRect(). So there is no need to retrieve content margins and calculate it again. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> --- dlls/comctl32/button.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index fbe060513d2..00f42322399 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -2651,7 +2651,7 @@ cleanup: */ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused) { - RECT bgRect, textRect; + RECT bgRect, textRect, focusRect; NMCUSTOMDRAW nmcd; LRESULT cdrf; HWND parent; @@ -2661,6 +2661,8 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in GetClientRect(infoPtr->hwnd, &bgRect); GetThemeBackgroundContentRect(theme, hDC, BP_PUSHBUTTON, state, &bgRect, &textRect); + focusRect = textRect; + init_custom_draw(&nmcd, infoPtr, hDC, &bgRect); parent = GetParent(infoPtr->hwnd); @@ -2698,20 +2700,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in } if (cdrf & CDRF_SKIPPOSTPAINT) return; - if (focused) - { - MARGINS margins; - RECT focusRect = bgRect; - - GetThemeMargins(theme, hDC, BP_PUSHBUTTON, state, TMT_CONTENTMARGINS, NULL, &margins); - - focusRect.left += margins.cxLeftWidth; - focusRect.top += margins.cyTopHeight; - focusRect.right -= margins.cxRightWidth; - focusRect.bottom -= margins.cyBottomHeight; - - DrawFocusRect( hDC, &focusRect ); - } + if (focused) DrawFocusRect(hDC, &focusRect); } static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused) -- 2.32.0
participants (1)
-
Zhiyi Zhang