Zhiyi Zhang : comctl32/button: Turn off themed painting if parts are unavailable for Command Links.

Alexandre Julliard julliard at winehq.org
Mon Feb 22 15:43:22 CST 2021


Module: wine
Branch: master
Commit: b08c622e22428effc4c0e47446a06e12d3532f40
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b08c622e22428effc4c0e47446a06e12d3532f40

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Mon Feb 22 22:32:28 2021 +0800

comctl32/button: Turn off themed painting if parts are unavailable for Command Links.

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>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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));




More information about the wine-cvs mailing list