Commit 80bd7fdd authored by Damjan Jovanovic's avatar Damjan Jovanovic Committed by Alexandre Julliard

comctl32: Implement treeview edit control text trimming and overwriting.

parent 59bb6220
......@@ -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, "<new_ptr>"));
expect(0, strcmp(item.pszText, "<new_ptr>"));
DestroyWindow(hTree);
}
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment