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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zhiyi Zhang 2021-02-22 22:32:28 +08:00 committed by Alexandre Julliard
parent d9b47aa303
commit b08c622e22
1 changed files with 15 additions and 1 deletions

View File

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