Zhiyi Zhang : comctl32/rebar: Do not remove WS_BORDER when theming is on.

Alexandre Julliard julliard at winehq.org
Wed Oct 6 15:51:36 CDT 2021


Module: wine
Branch: master
Commit: 106a5f43ec612b7d176513019ec1325e1c63b42c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=106a5f43ec612b7d176513019ec1325e1c63b42c

Author: Zhiyi Zhang <zzhang at codeweavers.com>
Date:   Wed Oct  6 15:48:07 2021 +0800

comctl32/rebar: Do not remove WS_BORDER when theming is on.

Signed-off-by: Zhiyi Zhang <zzhang at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/rebar.c       | 17 +++------------
 dlls/comctl32/tests/rebar.c | 50 +++++++++++++++++++++++++++++++++++----------
 2 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c
index 84390bd0b52..6a065514e60 100644
--- a/dlls/comctl32/rebar.c
+++ b/dlls/comctl32/rebar.c
@@ -2930,14 +2930,9 @@ REBAR_Create (REBAR_INFO *infoPtr, LPCREATESTRUCTW cs)
 	      cs->x, cs->y, cs->cx, cs->cy);
     }
 
-    TRACE("created!\n");
-
-    if (OpenThemeData (infoPtr->hwndSelf, themeClass))
-    {
-        /* native seems to clear WS_BORDER when themed */
-        infoPtr->dwStyle &= ~WS_BORDER;
-    }
+    OpenThemeData(infoPtr->hwndSelf, themeClass);
 
+    TRACE("created!\n");
     return 0;
 }
 
@@ -3508,8 +3503,6 @@ REBAR_StyleChanged (REBAR_INFO *infoPtr, INT nType, const STYLESTRUCT *lpStyle)
     if (nType == GWL_STYLE)
     {
         infoPtr->orgStyle = infoPtr->dwStyle = lpStyle->styleNew;
-        if (GetWindowTheme (infoPtr->hwndSelf))
-            infoPtr->dwStyle &= ~WS_BORDER;
         /* maybe it should be COMMON_STYLES like in toolbar */
         if ((lpStyle->styleNew ^ lpStyle->styleOld) & CCS_VERT)
             REBAR_Layout(infoPtr);
@@ -3522,11 +3515,7 @@ static LRESULT theme_changed (REBAR_INFO* infoPtr)
 {
     HTHEME theme = GetWindowTheme (infoPtr->hwndSelf);
     CloseThemeData (theme);
-    theme = OpenThemeData (infoPtr->hwndSelf, themeClass);
-    /* WS_BORDER disappears when theming is enabled and reappears when
-     * disabled... */
-    infoPtr->dwStyle &= ~WS_BORDER;
-    infoPtr->dwStyle |= theme ? 0 : (infoPtr->orgStyle & WS_BORDER);
+    OpenThemeData(infoPtr->hwndSelf, themeClass);
     return 0;
 }
 
diff --git a/dlls/comctl32/tests/rebar.c b/dlls/comctl32/tests/rebar.c
index 21b655b197f..462782a1b11 100644
--- a/dlls/comctl32/tests/rebar.c
+++ b/dlls/comctl32/tests/rebar.c
@@ -77,11 +77,11 @@ static void init_system_font_height(void) {
     system_font_height = tm.tmHeight;
 }
 
-static HWND create_rebar_control(void)
+static HWND create_rebar_control(DWORD style)
 {
     HWND hwnd;
 
-    hwnd = CreateWindowA(REBARCLASSNAMEA, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
+    hwnd = CreateWindowA(REBARCLASSNAMEA, NULL, style | WS_CHILD | WS_VISIBLE, 0, 0, 0, 0,
         hMainWnd, (HMENU)17, GetModuleHandleA(NULL), NULL);
     ok(hwnd != NULL, "Failed to create Rebar\n");
 
@@ -499,7 +499,7 @@ static void test_layout(void)
 
     rbsize_results_init();
 
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
     check_sizes();
     rbi.cbSize = REBARBANDINFOA_V6_SIZE;
     rbi.fMask = RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
@@ -559,7 +559,7 @@ static void test_layout(void)
 
     DestroyWindow(hRebar);
 
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
     add_band_w(hRebar, "ABC",     70,  40, 100);
     add_band_w(hRebar, NULL,      40,  70, 100);
     add_band_w(hRebar, NULL,     170, 240, 100);
@@ -602,7 +602,7 @@ static void test_layout(void)
     DestroyWindow(hRebar);
 
     /* VARHEIGHT resizing test on a horizontal rebar */
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
     SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | RBS_AUTOSIZE);
     check_sizes();
     rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
@@ -630,7 +630,7 @@ static void test_layout(void)
     DestroyWindow(hRebar);
 
     /* VARHEIGHT resizing on a vertical rebar */
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
     SetWindowLongA(hRebar, GWL_STYLE, GetWindowLongA(hRebar, GWL_STYLE) | CCS_VERT | RBS_AUTOSIZE);
     check_sizes();
     rbi.fMask = RBBIM_CHILD | RBBIM_CHILDSIZE | RBBIM_SIZE | RBBIM_STYLE;
@@ -661,7 +661,7 @@ static void test_layout(void)
     pImageList_Destroy(himl);
 
     /* One hidden band. */
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
 
     rbi.cbSize = REBARBANDINFOA_V6_SIZE;
     rbi.fMask = RBBIM_STYLE | RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_CHILD;
@@ -966,7 +966,7 @@ static void test_bandinfo(void)
     CHAR szABCD[] = "ABCD";
     HWND hRebar;
 
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
     rb.cbSize = REBARBANDINFOA_V6_SIZE;
     rb.fMask = 0;
     if (!SendMessageA(hRebar, RB_INSERTBANDA, 0, (LPARAM)&rb))
@@ -1027,7 +1027,7 @@ static void test_colors(void)
     HWND hRebar;
     REBARBANDINFOA bi;
 
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
 
     /* test default colors */
     clr = SendMessageA(hRebar, RB_GETTEXTCOLOR, 0, 0);
@@ -1106,7 +1106,7 @@ static void test_showband(void)
     REBARBANDINFOA rbi;
     BOOL ret;
 
-    hRebar = create_rebar_control();
+    hRebar = create_rebar_control(0);
 
     /* no bands */
     ret = SendMessageA(hRebar, RB_SHOWBAND, 0, TRUE);
@@ -1135,7 +1135,7 @@ static void test_notification(void)
     MEASUREITEMSTRUCT mis;
     HWND rebar;
 
-    rebar = create_rebar_control();
+    rebar = create_rebar_control(0);
 
     g_parent_measureitem = 0;
     SendMessageA(rebar, WM_MEASUREITEM, 0, (LPARAM)&mis);
@@ -1144,6 +1144,33 @@ static void test_notification(void)
     DestroyWindow(rebar);
 }
 
+static void test_style(void)
+{
+    STYLESTRUCT style_struct;
+    LONG style;
+    HWND hwnd;
+    RECT rect;
+
+    /* WS_BORDER */
+    hwnd = create_rebar_control(WS_BORDER);
+    ok(GetWindowLongW(hwnd, GWL_STYLE) & WS_BORDER, "Expected WS_BORDER.\n");
+
+    GetClientRect(hwnd, &rect);
+    SendMessageW(hwnd, WM_NCCALCSIZE, 0, (LPARAM)&rect);
+    ok(GetWindowLongW(hwnd, GWL_STYLE) & WS_BORDER, "Expected WS_BORDER.\n");
+
+    SendMessageW(hwnd, WM_THEMECHANGED, 0, 0);
+    style = GetWindowLongW(hwnd, GWL_STYLE);
+    ok(style & WS_BORDER, "Expected WS_BORDER.\n");
+
+    style_struct.styleOld = style;
+    style_struct.styleNew = style | WS_DLGFRAME;
+    SendMessageW(hwnd, WM_STYLECHANGED, (WPARAM)GWL_STYLE, (LPARAM)&style_struct);
+    ok(GetWindowLongW(hwnd, GWL_STYLE) & WS_BORDER, "Expected WS_BORDER.\n");
+
+    DestroyWindow(hwnd);
+}
+
 static void init_functions(void)
 {
     HMODULE hComCtl32 = LoadLibraryA("comctl32.dll");
@@ -1176,6 +1203,7 @@ START_TEST(rebar)
 
     test_layout();
     test_resize();
+    test_style();
 
 out:
     PostQuitMessage(0);




More information about the wine-cvs mailing list