There is a lot of code in TTreeView
and its related classes to keep the link between the Delphi objects and the underlying Windows control in sync. When nodes are added directly via window messages, the Delphi object needs to reflect that change the very next time you ask it how many nodes it has, for example.
TTreeView
is a wrapper for the Windows control, and TTreeNodes
and TTreeNode
are simply part of that wrapper. They don't actually implement all the tree operations that the control does. Certain operations are invalid if there currently isn't any Windows control available.
TTreeView
is a visual control. If you don't have anything to visualize, then it's not the control for you. If you have multiple tree data structures, and you only want one tree control, then you're going to have to live with destroying and re-creating the tree nodes whenever you switch to a different structure. The control doesn't even provide a way to hide certain nodes temporarily.
You might be interested in Mike Lischke's virtual tree control. In its intended usage, you manage the tree data structure yourself; the control is just a visualization. It asks you how many children each node has, and then it asks you what the text of each node is each time it has to draw that node. It managed which nodes are expanded, selected, checked, or visible, but you manage all the data. It is free and open-source.