[PATCH 5/8] comctl32/button: Implement NM_CUSTOMDRAW for other themed buttons
Gabriel Ivăncescu
gabrielopcode at gmail.com
Mon Mar 4 10:25:18 CST 2019
Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
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 88f8f2f..cb5aa83 100644
--- a/dlls/comctl32/button.c
+++ b/dlls/comctl32/button.c
@@ -2015,7 +2015,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);
@@ -2037,6 +2040,7 @@ static void CB_ThemedPaint(HTHEME theme, const BUTTON_INFO *infoPtr, HDC hDC, in
sz.cx = sz.cy = 13;
GetClientRect(infoPtr->hwnd, &bgRect);
+ init_custom_draw(&nmcd, infoPtr, hDC, &bgRect);
GetThemeBackgroundContentRect(theme, hDC, part, state, &bgRect, &textRect);
if (dtFlags & DT_SINGLELINE) /* Center the checkbox / radio button to the text. */
@@ -2047,13 +2051,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;
@@ -2071,6 +2101,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);
}
--
2.20.1
More information about the wine-devel
mailing list