From 54b6c76720c502097cc63dad9a42fbf772ff83d4 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sat, 7 Jan 2012 21:27:38 +0300 Subject: [PATCH] comctl32: Fix TB_SETSTYLE behaviour and return value. --- dlls/comctl32/tests/toolbar.c | 50 +++++++++++++++++++++++++++++++++++ dlls/comctl32/toolbar.c | 9 +++---- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 8850b1120db..22ad75c7239 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -164,6 +164,7 @@ static void basic_test(void) TBBUTTON buttons[9]; HWND hToolbar; int i; + for (i=0; i<9; i++) MakeButton(buttons+i, 1000+i, TBSTYLE_CHECKGROUP, 0); MakeButton(buttons+3, 1003, TBSTYLE_SEP|TBSTYLE_GROUP, 0); @@ -1633,6 +1634,54 @@ static void test_tooltip(void) DestroyWindow(hToolbar); } +static void test_get_set_style(void) +{ + TBBUTTON buttons[9]; + DWORD style, style2, ret; + HWND hToolbar; + int i; + + for (i=0; i<9; i++) + MakeButton(buttons+i, 1000+i, TBSTYLE_CHECKGROUP, 0); + MakeButton(buttons+3, 1003, TBSTYLE_SEP|TBSTYLE_GROUP, 0); + MakeButton(buttons+6, 1006, TBSTYLE_SEP, 0); + + hToolbar = CreateToolbarEx(hMainWnd, + WS_VISIBLE | WS_CLIPCHILDREN | CCS_TOP | + WS_CHILD | TBSTYLE_LIST, + 100, + 0, NULL, 0, + buttons, sizeof(buttons)/sizeof(buttons[0]), + 0, 0, 20, 16, sizeof(TBBUTTON)); + ok(hToolbar != NULL, "Toolbar creation\n"); + SendMessage(hToolbar, TB_ADDSTRINGA, 0, (LPARAM)"test\000"); + + style = SendMessageA(hToolbar, TB_GETSTYLE, 0, 0); + style2 = GetWindowLongA(hToolbar, GWL_STYLE); +todo_wine + ok(style == style2, "got 0x%08x, expected 0x%08x\n", style, style2); + + /* try to alter common window bits */ + style2 |= WS_BORDER; + ret = SendMessageA(hToolbar, TB_SETSTYLE, 0, style2); + ok(ret == 0, "got %d\n", ret); + style = SendMessageA(hToolbar, TB_GETSTYLE, 0, 0); + style2 = GetWindowLongA(hToolbar, GWL_STYLE); + ok((style != style2) && (style == (style2 | WS_BORDER)), + "got 0x%08x, expected 0x%08x\n", style, style2); + ok(style & WS_BORDER, "got 0x%08x\n", style); + + /* now styles are the same, alter window style */ + ret = SendMessageA(hToolbar, TB_SETSTYLE, 0, style2); + ok(ret == 0, "got %d\n", ret); + style2 |= WS_BORDER; + SetWindowLongA(hToolbar, GWL_STYLE, style2); + style = SendMessageA(hToolbar, TB_GETSTYLE, 0, 0); + ok(style == style2, "got 0x%08x, expected 0x%08x\n", style, style2); + + DestroyWindow(hToolbar); +} + START_TEST(toolbar) { WNDCLASSA wc; @@ -1672,6 +1721,7 @@ START_TEST(toolbar) test_setrows(); test_getstring(); test_tooltip(); + test_get_set_style(); PostQuitMessage(0); while(GetMessageA(&msg,0,0,0)) { diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index fba9bce0419..3868967c21c 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -4908,11 +4908,10 @@ TOOLBAR_SetState (TOOLBAR_INFO *infoPtr, INT Id, LPARAM lParam) static LRESULT -TOOLBAR_SetStyle (TOOLBAR_INFO *infoPtr, LPARAM lParam) +TOOLBAR_SetStyle (TOOLBAR_INFO *infoPtr, DWORD style) { - SetWindowLongW(infoPtr->hwndSelf, GWL_STYLE, lParam); - - return TRUE; + infoPtr->dwStyle = style; + return 0; } @@ -5155,7 +5154,7 @@ TOOLBAR_Create (HWND hwnd, const CREATESTRUCTW *lpcs) DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); LOGFONTW logFont; - TRACE("hwnd = %p\n", hwnd); + TRACE("hwnd = %p, style=0x%08x\n", hwnd, lpcs->style); infoPtr->dwStyle = dwStyle; GetClientRect(hwnd, &infoPtr->client_rect);