Search code examples
c++buildervcl

Can the TTreeView display more than 259 characters in a Row?


I was wondering why the TTreeView cuts off my text at the 259th character. I have already found some forums and website, where they say it is a limitation of Windows. Does it also apply to the C++ Builder 2010?

And if it is, why is it possible to store more characters in the TreeNode property?


Solution

  • I was wondering why the TTreeView cuts off my text at the 259th character.

    Because that is simply how a standard Win32 TreeView control works. This is documented behavior on MSDN:

    TVITEMA structure (commctrl.h)
    TVITEMW structure (commctrl.h)

    Note that although the tree-view control allows any length string to be stored as item text, only the first 260 characters are displayed.

    If you need to display more characters, you will have to draw the TreeView nodes yourself using the TTreeView::OnCustomDrawItem or TTreeView::OnAdvancedCustomDrawItem event.


    I have already found some forums and website, where they say it is a limitation of Windows. Does it also apply to the C++ Builder 2010?

    Yes, because the TTreeView component is just a wrapper for the standard Win32 TreeView control.


    And if it is, why is it possible to store more characters in the TreeNode property?

    Because the TTreeNode::Text property is just a plain System::String, so it can be as long as memory allows. But when the TTreeNode::Text is applied to the underlying Win32 TreeView (in response to a TVN_GETDISPINFO notification), the Text is copied into whatever buffer the OS decides to receive the text into, and the OS displays only 260 characters from that buffer.