Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54927
-- v2: uxtheme/tests: Add some DrawThemeTextEx() tests. uxtheme: Handle NULL options in DrawThemeTextEx().
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54927 --- dlls/uxtheme/draw.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/dlls/uxtheme/draw.c b/dlls/uxtheme/draw.c index eec73d67d07..f69fcc49f0c 100644 --- a/dlls/uxtheme/draw.c +++ b/dlls/uxtheme/draw.c @@ -1782,7 +1782,7 @@ HRESULT WINAPI DrawThemeTextEx(HTHEME hTheme, HDC hdc, int iPartId, int iStateId COLORREF textColor; COLORREF oldTextColor; int oldBkMode; - int fontProp; + int fontProp = TMT_GLYPHFONT;
TRACE("%p %p %d %d %s:%d 0x%08lx %p %p\n", hTheme, hdc, iPartId, iStateId, debugstr_wn(pszText, iCharCount), iCharCount, flags, rect, options); @@ -1790,13 +1790,19 @@ HRESULT WINAPI DrawThemeTextEx(HTHEME hTheme, HDC hdc, int iPartId, int iStateId if(!hTheme) return E_HANDLE;
- if (options->dwFlags & ~(DTT_TEXTCOLOR | DTT_FONTPROP)) - FIXME("unsupported flags 0x%08lx\n", options->dwFlags); + if(options) { + if(options->dwFlags & ~(DTT_TEXTCOLOR | DTT_FONTPROP)) + FIXME("unsupported flags 0x%08lx\n", options->dwFlags); + if(options->dwFlags & DTT_FONTPROP) + fontProp = options->iFontPropId; + if(options->dwFlags & DTT_TEXTCOLOR) + textColor = options->crText; + }
- if (options->dwFlags & DTT_FONTPROP) - fontProp = options->iFontPropId; - else - fontProp = TMT_FONT; + if(!options || !(options->dwFlags & DTT_TEXTCOLOR)) { + if(FAILED(GetThemeColor(hTheme, iPartId, iStateId, TMT_TEXTCOLOR, &textColor))) + textColor = GetTextColor(hdc); + }
hr = GetThemeFont(hTheme, hdc, iPartId, iStateId, fontProp, &logfont); if(SUCCEEDED(hr)) { @@ -1808,12 +1814,6 @@ HRESULT WINAPI DrawThemeTextEx(HTHEME hTheme, HDC hdc, int iPartId, int iStateId if(hFont) oldFont = SelectObject(hdc, hFont);
- if (options->dwFlags & DTT_TEXTCOLOR) - textColor = options->crText; - else { - if(FAILED(GetThemeColor(hTheme, iPartId, iStateId, TMT_TEXTCOLOR, &textColor))) - textColor = GetTextColor(hdc); - } oldTextColor = SetTextColor(hdc, textColor); oldBkMode = SetBkMode(hdc, TRANSPARENT); DrawTextW(hdc, pszText, iCharCount, rect, flags);
From: Mohamad Al-Jaf mohamadaljaf@gmail.com
--- dlls/uxtheme/tests/system.c | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
diff --git a/dlls/uxtheme/tests/system.c b/dlls/uxtheme/tests/system.c index 6597dc274cd..c1786fea9d9 100644 --- a/dlls/uxtheme/tests/system.c +++ b/dlls/uxtheme/tests/system.c @@ -2798,6 +2798,49 @@ static void test_DrawThemeEdge(void) DestroyWindow(hwnd); }
+static void test_DrawThemeTextEx(void) +{ + DTTOPTS options; + HTHEME htheme; + HRESULT hr; + RECT rect; + HWND hwnd; + HDC hdc; + + hwnd = CreateWindowA(WC_STATICA, "", WS_POPUP, 0, 0, 1, 1, 0, 0, 0, NULL); + ok(hwnd != NULL, "CreateWindowA failed, error %#lx.\n", GetLastError()); + htheme = OpenThemeData(hwnd, L"Button"); + if (!htheme) + { + skip("Theming is inactive.\n"); + DestroyWindow(hwnd); + return; + } + + hdc = GetDC(hwnd); + SetRect(&rect, 0, 0, 1, 1); + + hr = DrawThemeTextEx(NULL, hdc, 0, 0, L"Wine", -1, DT_CENTER, &rect, NULL); + ok(hr == E_HANDLE, "Got unexpected hr %#lx.\n", hr); + + hr = DrawThemeTextEx(htheme, hdc, 0, 0, L"Wine", -1, DT_CENTER, &rect, NULL); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + options.dwSize = sizeof(options); + options.dwFlags = DTT_VALIDBITS; + options.iFontPropId = TMT_BODYFONT; + hr = DrawThemeTextEx(htheme, hdc, 0, 0, L"Wine", -1, DT_CENTER, &rect, &options); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + options.crText = CLR_INVALID; + hr = DrawThemeTextEx(htheme, hdc, 0, 0, L"Wine", -1, DT_CENTER, &rect, &options); + ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr); + + ReleaseDC(hwnd, hdc); + CloseThemeData(htheme); + DestroyWindow(hwnd); +} + START_TEST(system) { ULONG_PTR ctx_cookie; @@ -2827,6 +2870,7 @@ START_TEST(system) test_ShouldSystemUseDarkMode(); test_ShouldAppsUseDarkMode(); test_DrawThemeEdge(); + test_DrawThemeTextEx();
if (load_v6_module(&ctx_cookie, &ctx)) {
**v2** - Initialize `fontProp` to `TMT_GLYPHFONT` - Don't assign `CLR_INVALID` to `textColor` - Better match existing style