diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index 82db67d5d0f..eb63439f0b9 100644 --- a/dlls/comctl32/tests/treeview.c +++ b/dlls/comctl32/tests/treeview.c @@ -1327,7 +1327,7 @@ static LRESULT CALLBACK parent_wnd_proc(HWND hWnd, UINT message, WPARAM wParam, NMTVDISPINFOA *disp = (NMTVDISPINFOA *)lParam; if (disp->item.mask & TVIF_TEXT) { - todo_wine ok(disp->item.cchTextMax == MAX_PATH, "cchTextMax is %d\n", disp->item.cchTextMax); + ok(disp->item.cchTextMax == MAX_PATH, "cchTextMax is %d\n", disp->item.cchTextMax); if (g_endedit_overwrite_contents) strcpy(disp->item.pszText, g_endedit_overwrite_contents); if (g_endedit_overwrite_ptr) @@ -1705,7 +1705,7 @@ static void test_itemedit(void) item.cchTextMax = ARRAY_SIZE(buffA); r = SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&item); expect(TRUE, r); - todo_wine expect(MAX_PATH - 1, strlen(item.pszText)); + expect(MAX_PATH - 1, strlen(item.pszText)); /* We can't get around that MAX_PATH limit by increasing EM_SETLIMITTEXT */ edit = (HWND)SendMessageA(hTree, TVM_EDITLABELA, 0, (LPARAM)hRoot); @@ -1723,7 +1723,7 @@ static void test_itemedit(void) item.cchTextMax = ARRAY_SIZE(buffA); r = SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&item); expect(TRUE, r); - todo_wine expect(MAX_PATH - 1, strlen(item.pszText)); + expect(MAX_PATH - 1, strlen(item.pszText)); /* Overwriting of pszText contents in TVN_ENDLABELEDIT */ edit = (HWND)SendMessageA(hTree, TVM_EDITLABELA, 0, (LPARAM)hRoot); @@ -1757,7 +1757,7 @@ static void test_itemedit(void) item.cchTextMax = ARRAY_SIZE(buffA); r = SendMessageA(hTree, TVM_GETITEMA, 0, (LPARAM)&item); expect(TRUE, r); - todo_wine expect(0, strcmp(item.pszText, "")); + expect(0, strcmp(item.pszText, "")); DestroyWindow(hTree); } diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index 47623e2be2f..0d2c825714c 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -3993,8 +3993,8 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel) TREEVIEW_ITEM *editedItem = infoPtr->editItem; NMTVDISPINFOW tvdi; BOOL bCommit; - WCHAR tmpText[1024] = { '\0' }; - WCHAR *newText = tmpText; + WCHAR tmpText[MAX_PATH] = { '\0' }; + WCHAR *newText; int iLength = 0; if (!IsWindow(infoPtr->hwndEdit)) return FALSE; @@ -4007,18 +4007,13 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel) if (!bCancel) { if (!infoPtr->bNtfUnicode) - iLength = GetWindowTextA(infoPtr->hwndEdit, (LPSTR)tmpText, 1023); + iLength = GetWindowTextA(infoPtr->hwndEdit, (LPSTR)tmpText, ARRAY_SIZE(tmpText)); else - iLength = GetWindowTextW(infoPtr->hwndEdit, tmpText, 1023); - - if (iLength >= 1023) - { - ERR("Insufficient space to retrieve new item label\n"); - } + iLength = GetWindowTextW(infoPtr->hwndEdit, tmpText, ARRAY_SIZE(tmpText)); tvdi.item.mask = TVIF_TEXT; tvdi.item.pszText = tmpText; - tvdi.item.cchTextMax = iLength + 1; + tvdi.item.cchTextMax = ARRAY_SIZE(tmpText); } else { @@ -4032,11 +4027,13 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel) { if (!infoPtr->bNtfUnicode) { - DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)tmpText, -1, NULL, 0 ); + DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)tvdi.item.pszText, -1, NULL, 0 ); newText = heap_alloc(len * sizeof(WCHAR)); - MultiByteToWideChar( CP_ACP, 0, (LPSTR)tmpText, -1, newText, len ); + MultiByteToWideChar( CP_ACP, 0, (LPSTR)tvdi.item.pszText, -1, newText, len ); iLength = len - 1; } + else + newText = tvdi.item.pszText; if (lstrcmpW(newText, editedItem->pszText) != 0) {