From c95aa8228acc57f99716ceb3845611c75f084fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Zalewski?= Date: Wed, 11 Oct 2006 20:48:38 +0200 Subject: [PATCH] comctl32: toolbar: Passing a string pointer in TB_INSERTBUTTON shouldn't change the strings table (with test case). --- dlls/comctl32/tests/toolbar.c | 8 ++++++++ dlls/comctl32/toolbar.c | 32 -------------------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/dlls/comctl32/tests/toolbar.c b/dlls/comctl32/tests/toolbar.c index 220d7032c2a..a007fa8db42 100644 --- a/dlls/comctl32/tests/toolbar.c +++ b/dlls/comctl32/tests/toolbar.c @@ -337,6 +337,7 @@ void test_add_string() LPCSTR ret6[] = {"a", "b", "|a|b||", "p", "q", "p", "p", "q", "p", "", "q"}; LPCSTR ret7[] = {"a", "b", "|a|b||", "p", "q", "p", "p", "q", "p", "", "q", "br", "c", "d"}; HWND hToolbar = NULL; + TBBUTTON button; int ret; rebuild_toolbar(&hToolbar); @@ -365,6 +366,13 @@ void test_add_string() ret = SendMessageA(hToolbar, TB_ADDSTRINGA, (WPARAM)GetModuleHandle(NULL), IDS_TBADD7); ok(ret == 11, "TB_ADDSTRINGA - unexpected return %d\n", ret); CHECK_STRING_TABLE(14, ret7); + + ZeroMemory(&button, sizeof(button)); + button.iString = (UINT_PTR)"Test"; + SendMessageA(hToolbar, TB_INSERTBUTTONA, 0, (LPARAM)&button); + CHECK_STRING_TABLE(14, ret7); + SendMessageA(hToolbar, TB_ADDBUTTONSA, 1, (LPARAM)&button); + CHECK_STRING_TABLE(14, ret7); } START_TEST(toolbar) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index 8531ac957ea..c2fd14b5f72 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -3833,22 +3833,6 @@ TOOLBAR_InsertButtonA (HWND hwnd, WPARAM wParam, LPARAM lParam) } else if (nIndex < 0) return FALSE; - /* If the string passed is not an index, assume address of string - and do our own AddString */ - if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) { - LPSTR ptr; - INT len; - - TRACE("string %s passed instead of index, adding string\n", - debugstr_a((LPSTR)lpTbb->iString)); - len = strlen((LPSTR)lpTbb->iString) + 2; - ptr = Alloc(len); - strcpy(ptr, (LPSTR)lpTbb->iString); - ptr[len - 1] = 0; /* ended by two '\0' */ - lpTbb->iString = TOOLBAR_AddStringA(hwnd, 0, (LPARAM)ptr); - Free(ptr); - } - TRACE("inserting button index=%d\n", nIndex); if (nIndex > infoPtr->nNumButtons) { nIndex = infoPtr->nNumButtons; @@ -3922,22 +3906,6 @@ TOOLBAR_InsertButtonW (HWND hwnd, WPARAM wParam, LPARAM lParam) } else if (nIndex < 0) return FALSE; - /* If the string passed is not an index, assume address of string - and do our own AddString */ - if ((HIWORD(lpTbb->iString) != 0) && (lpTbb->iString != -1)) { - LPWSTR ptr; - INT len; - - TRACE("string %s passed instead of index, adding string\n", - debugstr_w((LPWSTR)lpTbb->iString)); - len = strlenW((LPWSTR)lpTbb->iString) + 2; - ptr = Alloc(len*sizeof(WCHAR)); - strcpyW(ptr, (LPWSTR)lpTbb->iString); - ptr[len - 1] = 0; /* ended by two '\0' */ - lpTbb->iString = TOOLBAR_AddStringW(hwnd, 0, (LPARAM)ptr); - Free(ptr); - } - TRACE("inserting button index=%d\n", nIndex); if (nIndex > infoPtr->nNumButtons) { nIndex = infoPtr->nNumButtons;