[PATCH 2/6] comctl32/button: Turn off themed painting if parts are unavailable for Command Links.

Zhiyi Zhang zzhang at codeweavers.com
Mon Feb 22 08:32:28 CST 2021


Themed painting for Command Links requires BP_COMMANDLINK and
BP_COMMANDLINKGLYPH to be defined in the theme. However, Wine currently
only supports the v3 theme file format used by XP, which doesn't support
Command Links. So turn off themed painting for Command Links if user
uses a third party theme that doesn't have the required parts. Otherwise,
only plain text is drawn.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
---
 dlls/comctl32/button.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index 67bf5ceae48..0dcbb38d202 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -276,6 +276,20 @@ static LONG get_default_glyph_size(const BUTTON_INFO *infoPtr)
     return GetSystemMetrics(SM_CYMENUCHECK);
 }
 
+static BOOL is_themed_paint_supported(HTHEME theme, UINT btn_type)
+{
+    if (!theme || !btnThemedPaintFunc[btn_type])
+        return FALSE;
+
+    if (btn_type == BS_COMMANDLINK || btn_type == BS_DEFCOMMANDLINK)
+    {
+        if (!IsThemePartDefined(theme, BP_COMMANDLINK, 0))
+            return FALSE;
+    }
+
+    return TRUE;
+}
+
 static void init_custom_draw(NMCUSTOMDRAW *nmcd, const BUTTON_INFO *infoPtr, HDC hdc, const RECT *rc)
 {
     nmcd->hdr.hwndFrom = infoPtr->hwnd;
@@ -548,7 +562,7 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
         theme = GetWindowTheme( hWnd );
         hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
 
-        if (theme && btnThemedPaintFunc[btn_type])
+        if (is_themed_paint_supported(theme, btn_type))
         {
             int drawState = get_draw_state(infoPtr);
             UINT dtflags = BUTTON_BStoDT(style, GetWindowLongW(hWnd, GWL_EXSTYLE));
-- 
2.27.0




More information about the wine-devel mailing list