Zhiyi Zhang : comctl32/toolbar: Remove a redundant theme handle check in TOOLBAR_NCCreate().
Alexandre Julliard
julliard at winehq.org
Tue Jun 22 16:17:06 CDT 2021
Module: wine
Branch: master
Commit: a769679113a627d0e900aabd4bfb3c54e305c504
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a769679113a627d0e900aabd4bfb3c54e305c504
Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date: Tue Jun 22 16:21:02 2021 +0800
comctl32/toolbar: Remove a redundant theme handle check in TOOLBAR_NCCreate().
This is a no-op. In TOOLBAR_NCCreate(), GetWindowTheme() always returns NULL because the theme
handle is not open by OpenThemeData() by that time. Also tests show that TBSTYLE_TRANSPARENT is not
added when theming is active.
Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/comctl32/tests/toolbar.c | 81 +++++++++++++++++++++++++++++++++++++------
dlls/comctl32/toolbar.c | 3 +-
2 files changed, 71 insertions(+), 13 deletions(-)
diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c
index b7e03c3e378..9cfdcc689d9 100644
--- a/dlls/comctl32/tests/toolbar.c
+++ b/dlls/comctl32/tests/toolbar.c
@@ -26,11 +26,13 @@
#include "winuser.h"
#include "winnls.h"
#include "winreg.h"
-#include "commctrl.h"
+#include "commctrl.h"
+#include "uxtheme.h"
#include "resources.h"
#include "wine/test.h"
+#include "v6util.h"
#include "msg.h"
@@ -44,6 +46,10 @@ static INT (WINAPI *pImageList_GetImageCount)(HIMAGELIST);
static BOOL (WINAPI *pImageList_GetIconSize)(HIMAGELIST, int *, int *);
static HIMAGELIST (WINAPI *pImageList_LoadImageA)(HINSTANCE, LPCSTR, int, int, COLORREF, UINT, UINT);
+static BOOL (WINAPI *pIsThemeActive)(VOID);
+
+static BOOL is_theme_active;
+
static struct msg_sequence *sequences[NUM_MSG_SEQUENCES];
static HWND hMainWnd;
@@ -2203,7 +2209,7 @@ static LRESULT CALLBACK cbt_hook_proc(int code, WPARAM wParam, LPARAM lParam)
return CallNextHookEx(g_tbhook, code, wParam, lParam);
}
-static void test_create(void)
+static void test_create(BOOL v6)
{
HWND hwnd, tooltip;
DWORD style;
@@ -2217,16 +2223,32 @@ static void test_create(void)
hwnd = CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
hMainWnd, (HMENU)5, GetModuleHandleA(NULL), NULL);
- CHECK_CALLED(g_hook_create);
- CHECK_CALLED(g_hook_WM_NCCREATE);
- CHECK_CALLED(g_hook_WM_CREATE);
+ if (v6)
+ {
+ expect(called_g_hook_create, FALSE);
+ expect(called_g_hook_WM_NCCREATE, FALSE);
+ expect(called_g_hook_WM_CREATE, FALSE);
+ }
+ else
+ {
+ CHECK_CALLED(g_hook_create);
+ CHECK_CALLED(g_hook_WM_NCCREATE);
+ CHECK_CALLED(g_hook_WM_CREATE);
+ }
style = GetWindowLongA(hwnd, GWL_STYLE);
- ok((style & TBSTYLE_TOOLTIPS) == TBSTYLE_TOOLTIPS, "got 0x%08x\n", style);
+ if (v6)
+ {
+ ok(!(style & TBSTYLE_TOOLTIPS), "got 0x%08x\n", style);
+ }
+ else
+ {
+ ok((style & TBSTYLE_TOOLTIPS) == TBSTYLE_TOOLTIPS, "got 0x%08x\n", style);
- tooltip = (HWND)SendMessageA(hwnd, TB_GETTOOLTIPS, 0, 0);
- ok(tooltip != NULL, "got %p\n", tooltip);
- ok(GetParent(tooltip) == hMainWnd, "got %p, %p\n", hMainWnd, hwnd);
+ tooltip = (HWND)SendMessageA(hwnd, TB_GETTOOLTIPS, 0, 0);
+ ok(tooltip != NULL, "got %p\n", tooltip);
+ ok(GetParent(tooltip) == hMainWnd, "got %p, %p\n", hMainWnd, hwnd);
+ }
DestroyWindow(hwnd);
UnhookWindowsHook(WH_CBT, cbt_hook_proc);
@@ -2243,6 +2265,24 @@ static void test_create(void)
ok((style & TBSTYLE_TRANSPARENT) == TBSTYLE_TRANSPARENT, "got 0x%08x\n", style);
DestroyWindow(hwnd);
+
+ if (!is_theme_active)
+ {
+ skip("Theming is not active, skipping following tests.\n");
+ return;
+ }
+
+ hwnd = CreateWindowA(TOOLBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS
+ | TBSTYLE_TOOLTIPS | TBSTYLE_GROUP, 0, 0, 0, 0, hMainWnd, (HMENU)5,
+ GetModuleHandleA(NULL), NULL);
+
+ style = GetWindowLongA(hwnd, GWL_STYLE);
+ ok(!(style & TBSTYLE_TRANSPARENT), "got 0x%08x\n", style);
+
+ style = SendMessageA(hwnd, TB_GETSTYLE, 0, 0);
+ ok(!(style & TBSTYLE_TRANSPARENT), "got 0x%08x\n", style);
+
+ DestroyWindow(hwnd);
}
typedef struct {
@@ -2536,7 +2576,10 @@ static void test_imagelist(void)
static void init_functions(void)
{
- HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
+ HMODULE hComCtl32, hUxtheme;
+
+ hComCtl32 = LoadLibraryA("comctl32.dll");
+ hUxtheme = LoadLibraryA("uxtheme.dll");
#define X(f) p##f = (void*)GetProcAddress(hComCtl32, #f);
X(CreateToolbarEx);
@@ -2545,17 +2588,26 @@ static void init_functions(void)
X(ImageList_LoadImageA);
X(ImageList_Destroy);
#undef X
+
+#define X(f) p##f = (void*)GetProcAddress(hUxtheme, #f)
+ X(IsThemeActive);
+#undef X
}
START_TEST(toolbar)
{
+ ULONG_PTR ctx_cookie;
WNDCLASSA wc;
+ HANDLE ctx;
MSG msg;
RECT rc;
init_msg_sequences(sequences, NUM_MSG_SEQUENCES);
init_functions();
+ if (pIsThemeActive)
+ is_theme_active = pIsThemeActive();
+
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
@@ -2586,17 +2638,24 @@ START_TEST(toolbar)
test_getstring();
test_tooltip();
test_get_set_style();
- test_create();
+ test_create(FALSE);
test_TB_GET_SET_EXTENDEDSTYLE();
test_noresize();
test_save();
test_drawtext_flags();
test_imagelist();
+ if (!load_v6_module(&ctx_cookie, &ctx))
+ return;
+
+ test_create(TRUE);
+
PostQuitMessage(0);
while(GetMessageA(&msg,0,0,0)) {
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
DestroyWindow(hMainWnd);
+
+ unload_v6_module(ctx_cookie, ctx);
}
diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 1aeb499c45f..a8777ae5480 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -6104,8 +6104,7 @@ TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, const CREATESTRUCTW *lpcs)
* (Guy Albertelli 9/2001)
*
*/
- if (((infoPtr->dwStyle & TBSTYLE_FLAT) || GetWindowTheme (infoPtr->hwndSelf))
- && !(lpcs->style & TBSTYLE_TRANSPARENT))
+ if ((infoPtr->dwStyle & TBSTYLE_FLAT) && !(lpcs->style & TBSTYLE_TRANSPARENT))
styleadd |= TBSTYLE_TRANSPARENT;
if (!(lpcs->style & (CCS_TOP | CCS_NOMOVEY))) {
styleadd |= CCS_TOP; /* default to top */
More information about the wine-cvs
mailing list