comctl32: toolbar: Passing a string pointer in TB_INSERTBUTTON shouldn't change the strings table (with test case).
This commit is contained in:
parent
4cf682b8c4
commit
c95aa8228a
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue