You typically specify the text of an item's label when you add the item to the tree view control. The TVM_INSERTITEM message includes a TVITEM structure that defines the item's properties, including a string containing the label text.
A tree view control allocates memory for storing each item; the text of the item labels takes up a significant portion of this memory. If you maintain a copy of the strings in the tree view control, you can decrease the memory requirements of the control by specifying the LPSTR_TEXTCALLBACK value in the pszText member of TVITEM instead of passing actual strings to the tree view. Using LPSTR_TEXTCALLBACK causes the tree view control to retrieve the text of an item's label from the parent window when the item needs to be redrawn.
A user can directly edit the labels of items in a tree view control that has the TVS_EDITLABELS style. A user begins editing by clicking the label of the item that has the focus. An application begins editing by using the TVM_EDITLABEL message. The tree view control notifies the parent window when editing begins and when it is canceled or completed. When a user or application completes editing, the parent window is responsible for updating the item's label, if appropriate.
When a user begins editing the label, a tree view control sends its parent window a TVN_BEGINLABELEDIT notification message. By processing this notification, an application can accept some label editing and reject editing others. Returning zero accepts editing, and returning nonzero rejects it.
When a user cancels or completes editing the label, a tree view control sends its parent window a TVN_ENDLABELEDIT notification message. The pszText member of TVITEM is zero if editing is canceled.