From 9e73b83aa8c87f8a31f24f8ef65472ed7ec18354 Mon Sep 17 00:00:00 2001 From: Grzegorz Tworek Date: Wed, 3 Jul 2024 13:13:32 +0200 Subject: [PATCH] Update add-tree-view-items.md The sample is wrong. Sizeof(LPWSTR) returns size of a pointer, and not length of the string. --- desktop-src/Controls/add-tree-view-items.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop-src/Controls/add-tree-view-items.md b/desktop-src/Controls/add-tree-view-items.md index 2e27e9640da..607b4cfd85f 100644 --- a/desktop-src/Controls/add-tree-view-items.md +++ b/desktop-src/Controls/add-tree-view-items.md @@ -55,7 +55,7 @@ HTREEITEM AddItemToTree(HWND hwndTV, LPTSTR lpszItem, int nLevel) // Set the text of the item. tvi.pszText = lpszItem; - tvi.cchTextMax = sizeof(tvi.pszText)/sizeof(tvi.pszText[0]); + tvi.cchTextMax = _tcslen(tvi.pszText) + 1; // Assume the item is not a parent item, so give it a // document image.