Zhiyi Zhang : comctl32/tests: Add more WM_CTLCOLORSTATIC tests for static controls in a dialog.
Alexandre Julliard
julliard at winehq.org
Tue Dec 7 15:58:43 CST 2021
Module: wine
Branch: master
Commit: fa1294faa64cdfca2d4f7bff5ece3ce513c6d62a
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fa1294faa64cdfca2d4f7bff5ece3ce513c6d62a
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Tue Dec 7 17:12:34 2021 +0800
comctl32/tests: Add more WM_CTLCOLORSTATIC tests for static controls in a dialog.
Mostly to test that even when theme texture is enabled for a dialog, the default dialog procedure
still returns the stock COLOR_BTNFACE brush in response to WM_CTLCOLORSTATIC.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/tests/static.c | 61 +++++++++++++++++++++++++++++++++++---------
1 file changed, 49 insertions(+), 12 deletions(-)
diff --git a/dlls/comctl32/tests/static.c b/dlls/comctl32/tests/static.c
index 99738f7b513..ce21e03df3c 100644
--- a/dlls/comctl32/tests/static.c
+++ b/dlls/comctl32/tests/static.c
@@ -40,6 +40,11 @@
static HWND hMainWnd;
static int g_nReceivedColorStatic;
+static HRESULT (WINAPI *pEnableThemeDialogTexture)(HWND, DWORD);
+static HTHEME (WINAPI *pGetWindowTheme)(HWND);
+static BOOL (WINAPI *pIsThemeActive)(void);
+static BOOL (WINAPI *pIsThemeDialogTextureEnabled)(HWND);
+
/* try to make sure pending X events have been processed before continuing */
static void flush_events(void)
{
@@ -385,7 +390,7 @@ static INT_PTR CALLBACK test_WM_CTLCOLORSTATIC_proc(HWND hwnd, UINT msg, WPARAM
switch (msg)
{
case WM_INITDIALOG:
- child = CreateWindowA(WC_STATICA, "child", WS_CHILD | WS_VISIBLE, 0, 0, 50, 50, hwnd,
+ child = CreateWindowA(WC_STATICA, "child", WS_CHILD | WS_VISIBLE, 1, 2, 50, 50, hwnd,
(HMENU)100, 0, NULL);
ok(child != NULL, "CreateWindowA failed, error %d.\n", GetLastError());
return FALSE;
@@ -401,14 +406,14 @@ static INT_PTR CALLBACK test_WM_CTLCOLORSTATIC_proc(HWND hwnd, UINT msg, WPARAM
static void test_WM_CTLCOLORSTATIC(void)
{
- HTHEME (WINAPI *pGetWindowTheme)(HTHEME) = NULL;
HWND parent, dialog, child;
COLORREF color, old_color;
HDC child_hdc, dialog_hdc;
+ BOOL ret, todo = FALSE;
int mode, old_mode;
- BOOL todo = FALSE;
- HMODULE uxtheme;
HBRUSH brush;
+ HRESULT hr;
+ POINT org;
struct
{
@@ -430,13 +435,7 @@ static void test_WM_CTLCOLORSTATIC(void)
child = GetDlgItem(dialog, 100);
ok(child != NULL, "Failed to get child static control, error %d.\n", GetLastError());
- uxtheme = LoadLibraryA("uxtheme.dll");
- if (uxtheme)
- {
- pGetWindowTheme = (void*)GetProcAddress(uxtheme, "GetWindowTheme");
- if (pGetWindowTheme)
- todo = !!pGetWindowTheme(dialog);
- }
+ todo = !!pGetWindowTheme(dialog);
dialog_hdc = GetDC(dialog);
child_hdc = GetDC(child);
@@ -447,6 +446,11 @@ static void test_WM_CTLCOLORSTATIC(void)
old_color = SetBkColor(child_hdc, 0xaa5511);
ok(old_color != CLR_INVALID, "SetBkColor failed.\n");
+ ret = pIsThemeDialogTextureEnabled(dialog);
+ ok(ret, "Expected theme dialog texture supported.\n");
+ todo_wine_if(todo)
+ ok(pGetWindowTheme(dialog) == NULL, "Expected NULL theme handle.\n");
+
brush = (HBRUSH)SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
todo_wine_if(todo)
ok(brush == GetSysColorBrush(COLOR_BTNFACE), "Expected brush %p, got %p.\n",
@@ -460,11 +464,42 @@ static void test_WM_CTLCOLORSTATIC(void)
color = GetPixel(dialog_hdc, 40, 40);
ok(color == 0, "Expected pixel %#x, got %#x.\n", 0, color);
+ /* Test that EnableThemeDialogTexture() doesn't make WM_CTLCOLORSTATIC return a different brush */
+ hr = pEnableThemeDialogTexture(dialog, ETDT_DISABLE);
+ ok(hr == S_OK, "EnableThemeDialogTexture failed, hr %#x.\n", hr);
+ ret = pIsThemeDialogTextureEnabled(dialog);
+ ok(!ret, "Expected theme dialog texture disabled.\n");
+ hr = pEnableThemeDialogTexture(dialog, ETDT_ENABLETAB);
+ ok(hr == S_OK, "EnableThemeDialogTexture failed, hr %#x.\n", hr);
+ ret = pIsThemeDialogTextureEnabled(dialog);
+ ok(ret, "Expected theme dialog texture enabled.\n");
+
+ brush = (HBRUSH)SendMessageW(dialog, WM_CTLCOLORSTATIC, (WPARAM)child_hdc, (LPARAM)child);
+ todo_wine_if(pIsThemeActive())
+ ok(brush == GetSysColorBrush(COLOR_BTNFACE), "Expected brush %p, got %p.\n",
+ GetSysColorBrush(COLOR_BTNFACE), brush);
+
+ /* Test that WM_CTLCOLORSTATIC doesn't change brush origin */
+ ret = GetBrushOrgEx(child_hdc, &org);
+ ok(ret, "GetBrushOrgEx failed, error %u.\n", GetLastError());
+ ok(org.x == 0 && org.y == 0, "Expected (0,0), got %s.\n", wine_dbgstr_point(&org));
+
ReleaseDC(child, child_hdc);
ReleaseDC(dialog, dialog_hdc);
EndDialog(dialog, 0);
DestroyWindow(parent);
- FreeLibrary(uxtheme);
+}
+
+static void init_functions(void)
+{
+ HMODULE uxtheme = LoadLibraryA("uxtheme.dll");
+
+#define X(f) p##f = (void *)GetProcAddress(uxtheme, #f);
+ X(EnableThemeDialogTexture)
+ X(GetWindowTheme)
+ X(IsThemeActive)
+ X(IsThemeDialogTextureEnabled)
+#undef X
}
START_TEST(static)
@@ -477,6 +512,8 @@ START_TEST(static)
if (!load_v6_module(&ctx_cookie, &hCtx))
return;
+ init_functions();
+
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
More information about the wine-cvs
mailing list