=?UTF-8?Q?Gabriel=20Iv=C4=83ncescu=20?=: comctl32/button: Implement NM_CUSTOMDRAW for other themed buttons.
Alexandre Julliard
julliard at winehq.org
Thu Mar 7 16:27:58 CST 2019
Module: wine
Branch: master
Commit: 04de7c9f05eb4deeca0f99354b25b572fb478523
URL: https://source.winehq.org/git/wine.git/?a=commit;h=04de7c9f05eb4deeca0f99354b25b572fb478523
Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date: Tue Mar 5 15:13:26 2019 +0200
comctl32/button: Implement NM_CUSTOMDRAW for other themed buttons.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/button.c | 35 +++++++++++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c
index faf8191..1637e05 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -2013,7 +2013,10 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
UINT btn_type = get_button_type( dwStyle );
int part = (btn_type == BS_RADIOBUTTON) || (btn_type == BS_AUTORADIOBUTTON) ? BP_RADIOBUTTON : BP_CHECKBOX;
WCHAR *text = get_button_text(infoPtr);
+ NMCUSTOMDRAW nmcd;
+ LRESULT cdrf;
LOGFONTW lf;
+ HWND parent;
BOOL created_font = FALSE;
HRESULT hr = GetThemeFont(theme, hDC, part, state, TMT_FONT, &lf);
@@ -2036,6 +2039,7 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
GetClientRect(infoPtr->hwnd, &bgRect);
GetThemeBackgroundContentRect(theme, hDC, part, state, &bgRect, &textRect);
+ init_custom_draw(&nmcd, infoPtr, hDC, &bgRect);
if (dtFlags & DT_SINGLELINE) /* Center the checkbox / radio button to the text. */
bgRect.top = bgRect.top + (textRect.bottom - textRect.top - sz.cy) / 2;
@@ -2045,13 +2049,39 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
bgRect.right = bgRect.left + sz.cx;
textRect.left = bgRect.right + 6;
- DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL);
+ parent = GetParent(infoPtr->hwnd);
+ if (!parent) parent = infoPtr->hwnd;
+ /* Send erase notifications */
+ cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+ if (cdrf & CDRF_SKIPDEFAULT) goto cleanup;
+
+ DrawThemeParentBackground(infoPtr->hwnd, hDC, NULL);
DrawThemeBackground(theme, hDC, part, state, &bgRect, NULL);
- if (text)
+
+ if (cdrf & CDRF_NOTIFYPOSTERASE)
{
+ nmcd.dwDrawStage = CDDS_POSTERASE;
+ SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+ }
+
+ /* Send paint notifications */
+ nmcd.dwDrawStage = CDDS_PREPAINT;
+ cdrf = SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+ if (cdrf & CDRF_SKIPDEFAULT) goto cleanup;
+
+ if (!(cdrf & CDRF_DOERASE) && text)
DrawThemeText(theme, hDC, part, state, text, lstrlenW(text), dtFlags, 0, &textRect);
+ if (cdrf & CDRF_NOTIFYPOSTPAINT)
+ {
+ nmcd.dwDrawStage = CDDS_POSTPAINT;
+ SendMessageW(parent, WM_NOTIFY, nmcd.hdr.idFrom, (LPARAM)&nmcd);
+ }
+ if (cdrf & CDRF_SKIPPOSTPAINT) goto cleanup;
+
+ if (text)
+ {
if (focused)
{
RECT focusRect;
@@ -2069,6 +2099,7 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
heap_free(text);
}
+cleanup:
if (created_font) DeleteObject(font);
if (hPrevFont) SelectObject(hDC, hPrevFont);
}
More information about the wine-cvs
mailing list