I am not able to find (in MSDN), if parameter int cchTextMax
of TVITEM structure is included the end null terminated string character \0
or no.
TVITEM
structure is used by CTreeCtrl or CTreeView class.
I mean, is it right
cchTextMax = wcslen(lsTxt)
or
cchTextMax = wcslen(lsTxt)+1
??
Thanks for advice.
Unfortunately, the TreeView documentation does not say explicitly whether or not
cchTextMax
includes the null terminator (on the other hand, the ListView documentation does say, and ListView and TreeView are implemented in the same library, so it is likely that they behave similarly).Since
pszText
points to a null-terminated string, andcchTextMax
is the size of thepszText
buffer in characters, it stands to reason thatcchTextMax
includes the null terminator. Particularly when retrieving text, sinceTVM_GETITEM
and similar messages need to know how large the buffer is so they can store the null terminator and truncate text if needed.