From d8570739ebf0398e9ceba95c8a3c87d056ce7d6a Mon Sep 17 00:00:00 2001 From: Reece Dunn Date: Wed, 16 Jul 2008 09:41:51 +0100 Subject: [PATCH] comctl32: support for drawing themed push buttons. --- dlls/comctl32/theme_button.c | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/theme_button.c b/dlls/comctl32/theme_button.c index 4ff344c..6e66393 100644 --- a/dlls/comctl32/theme_button.c +++ b/dlls/comctl32/theme_button.c @@ -107,6 +107,37 @@ static int get_button_part(DWORD style) } } +static void PB_draw(HTHEME theme, HWND hwnd, HDC hDC, int part, int drawState, UINT dtFlags) +{ + static const int states[] = + { + PBS_NORMAL, + PBS_DISABLED, + PBS_HOT, + PBS_PRESSED, + PBS_DEFAULTED, + }; + + RECT bgRect, textRect; + HFONT font = (HFONT)SendMessageW(hwnd, WM_GETFONT, 0, 0); + HFONT hPrevFont = font ? SelectObject(hDC, font) : NULL; + int state = states[ drawState ]; + WCHAR text[MAX_PATH]; + int len = MAX_PATH; + + GetClientRect(hwnd, &bgRect); + textRect = bgRect; + + len = GetWindowTextW(hwnd, text, len); + + if (IsThemeBackgroundPartiallyTransparent(theme, part, state)) + DrawThemeParentBackground(hwnd, hDC, NULL); + DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL); + DrawThemeText(theme, hDC, part, state, text, len, dtFlags, 0, &textRect); + + if (hPrevFont) SelectObject(hDC, hPrevFont); +} + static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, int part, int drawState, UINT dtFlags) { static const int states[] = @@ -153,8 +184,8 @@ static void GB_draw(HTHEME theme, HWND hwnd, HDC hDC, int part, int drawState, U static const pfThemedPaint btnThemedPaintFunc[BUTTON_TYPE] = { - NULL, /* BS_PUSHBUTTON */ - NULL, /* BS_DEFPUSHBUTTON */ + PB_draw, /* BS_PUSHBUTTON */ + PB_draw, /* BS_DEFPUSHBUTTON */ NULL, /* BS_CHECKBOX */ NULL, /* BS_AUTOCHECKBOX */ NULL, /* BS_RADIOBUTTON */ -- 1.5.4.3