Damjan Jovanovic : comctl32: Implement treeview edit control text trimming and overwriting.
Alexandre Julliard
julliard at winehq.org
Mon Apr 20 15:01:50 CDT 2020
Module: wine
Branch: oldstable
Commit: 2cf27cba96a94daa3686d371bcd4a1802e13fbc2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=2cf27cba96a94daa3686d371bcd4a1802e13fbc2
Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date: Wed Nov 13 05:54:15 2019 +0200
comctl32: Implement treeview edit control text trimming and overwriting.
Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 80bd7fdd5629a89dec7ee5e14a05c2ff512301c4)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/comctl32/tests/treeview.c | 8 ++++----
dlls/comctl32/treeview.c | 21 +++++++++------------
2 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 192ca8c636..b27dda8664 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, "<new_ptr>"));
+ expect(0, strcmp(item.pszText, "<new_ptr>"));
DestroyWindow(hTree);
}
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 9f16888241..85a963ddc1 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -3997,8 +3997,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;
@@ -4011,18 +4011,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
{
@@ -4036,11 +4031,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 (strcmpW(newText, editedItem->pszText) != 0)
{
More information about the wine-cvs
mailing list