From: Zhiyi Zhang zzhang@codeweavers.com
Drawing a focus rect when the button is really small creates an effect that makes the button look corrupted. On Windows, the focus rect is not drawn when keyboard cues are disabled, which is the default. --- dlls/comctl32/button.c | 18 +++++++++--------- dlls/comctl32/comctl32.h | 1 + dlls/comctl32/commctrl.c | 3 +++ 3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index a0eb41fec20..2e009aa222d 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -1960,7 +1960,7 @@ static void PB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action ) } if ((cdrf & CDRF_SKIPPOSTPAINT) || dtFlags == (UINT)-1L) goto cleanup;
- if (action == ODA_FOCUS || (state & BST_FOCUS)) + if (COMCTL32_keyboard_cues_enabled && (action == ODA_FOCUS || (state & BST_FOCUS))) { InflateRect( &rc, -2, -2 ); DrawFocusRect( hDC, &rc ); @@ -2133,7 +2133,7 @@ static void CB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action ) if ((cdrf & CDRF_SKIPPOSTPAINT) || dtFlags == (UINT)-1L) goto cleanup;
/* ... and focus */ - if (action == ODA_FOCUS || (state & BST_FOCUS)) + if (COMCTL32_keyboard_cues_enabled && (action == ODA_FOCUS || (state & BST_FOCUS))) { labelRect.left--; labelRect.right++; @@ -2274,7 +2274,7 @@ static void UB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action ) SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd); }
- if (!(cdrf & CDRF_SKIPPOSTPAINT)) + if (COMCTL32_keyboard_cues_enabled && !(cdrf & CDRF_SKIPPOSTPAINT)) DrawFocusRect( hDC, &rc ); }
@@ -2459,7 +2459,7 @@ static void SB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action ) } if ((cdrf & CDRF_SKIPPOSTPAINT) || dtFlags == (UINT)-1L) goto cleanup;
- if (action == ODA_FOCUS || (state & BST_FOCUS)) + if (COMCTL32_keyboard_cues_enabled && (action == ODA_FOCUS || (state & BST_FOCUS))) DrawFocusRect(hDC, &push_rect);
cleanup: @@ -2732,7 +2732,7 @@ static void CL_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action ) } if (cdrf & CDRF_SKIPPOSTPAINT) goto cleanup;
- if (action == ODA_FOCUS || (state & BST_FOCUS)) + if (COMCTL32_keyboard_cues_enabled && (action == ODA_FOCUS || (state & BST_FOCUS))) { InflateRect(&rc, -2, -2); DrawFocusRect(hDC, &rc); @@ -2810,7 +2810,7 @@ static void PB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in } if (cdrf & CDRF_SKIPPOSTPAINT) return;
- if (focused) DrawFocusRect(hDC, &focusRect); + if (COMCTL32_keyboard_cues_enabled && focused) DrawFocusRect(hDC, &focusRect); }
static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused) @@ -2917,7 +2917,7 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in } if ((cdrf & CDRF_SKIPPOSTPAINT) || dtFlags == (UINT)-1L) goto cleanup;
- if (focused) + if (COMCTL32_keyboard_cues_enabled && focused) { label_rect.left--; label_rect.right++; @@ -3108,7 +3108,7 @@ static void SB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in } if (cdrf & CDRF_SKIPPOSTPAINT) return;
- if (focused) DrawFocusRect(hDC, &focus_rect); + if (COMCTL32_keyboard_cues_enabled && focused) DrawFocusRect(hDC, &focus_rect); }
static void CL_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, int state, UINT dtFlags, BOOL focused) @@ -3217,7 +3217,7 @@ static void CL_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in } if (cdrf & CDRF_SKIPPOSTPAINT) return;
- if (focused) + if (COMCTL32_keyboard_cues_enabled && focused) { MARGINS margins;
diff --git a/dlls/comctl32/comctl32.h b/dlls/comctl32/comctl32.h index a9a0b44fcd1..ae65fdcd656 100644 --- a/dlls/comctl32/comctl32.h +++ b/dlls/comctl32/comctl32.h @@ -37,6 +37,7 @@
extern HMODULE COMCTL32_hModule; extern HBRUSH COMCTL32_hPattern55AABrush; +extern BOOL COMCTL32_keyboard_cues_enabled;
/* Property sheet / Wizard */ #define IDD_PROPSHEET 1006 diff --git a/dlls/comctl32/commctrl.c b/dlls/comctl32/commctrl.c index 6097b1a9735..27e58eb7ae0 100644 --- a/dlls/comctl32/commctrl.c +++ b/dlls/comctl32/commctrl.c @@ -81,6 +81,7 @@ HMODULE COMCTL32_hModule = 0; static LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); HBRUSH COMCTL32_hPattern55AABrush = NULL; COMCTL32_SysColor comctl32_color; +BOOL COMCTL32_keyboard_cues_enabled = FALSE;
static HBITMAP COMCTL32_hPattern55AABitmap = NULL;
@@ -171,6 +172,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
COMCTL32_hModule = hinstDLL;
+ SystemParametersInfoW (SPI_GETKEYBOARDCUES, 0, &COMCTL32_keyboard_cues_enabled, 0); + /* add global subclassing atom (used by 'tooltip' and 'updown') */ COMCTL32_wSubclass = (LPWSTR)(DWORD_PTR)GlobalAddAtomW (strCC32SubclassInfo); TRACE("Subclassing atom added: %p\n", COMCTL32_wSubclass);