an jedem TVirtualNode gibt es ein Zeiger Data bzw. ab dort ist ein Speicherbereich für die Daten.
Meist 4 Byte für einen Zeiger, wenn du mit Objekten arbeitest.
In diese 4 Bytes legst du deinen neuen Zeiger rein.
Delphi-Quellcode:
TVirtualNode = packed record
Index, // index of node with regard to its parent
ChildCount: Cardinal; // number of child nodes
NodeHeight: Word; // height in pixels
States: TVirtualNodeStates; // states describing various properties of the node (expanded, initialized etc.)
Align: Byte; // line/button alignment
CheckState: TCheckState; // indicates the current check state (e.g. checked, pressed etc.)
CheckType: TCheckType; // indicates which check type shall be used for this node
Dummy: Byte; // dummy value to fill DWORD boundary
TotalCount, // sum of this node, all of its child nodes and their child nodes etc.
TotalHeight: Cardinal; // height in pixels this node covers on screen including the height of all of its
// children
// Note: Some copy routines require that all pointers (as well as the data area) in a node are
// located at the end of the node! Hence if you want to add new member fields (except pointers to internal
// data) then put them before field Parent.
Parent, // reference to the node's parent (for the root this contains the treeview)
PrevSibling, // link to the node's previous sibling or nil if it is the first node
NextSibling, // link to the node's next sibling or nil if it is the last node
FirstChild, // link to the node's first child...
LastChild: PVirtualNode; // link to the node's last child...
Data: record end; // this is a placeholder, each node gets extra data determined by NodeDataSize
end;
Bei AddChild findest du diesen Code welcher den Zeiger bzw. den Inhalt setzt:
Delphi-Quellcode:
function TBaseVirtualTree.AddChild(Parent: PVirtualNode; UserData: Pointer = nil): PVirtualNode;
if Assigned(UserData) then
if FNodeDataSize >= 4 then
begin
NodeData := Pointer(PChar(@Result.Data) + FTotalInternalDataSize);
NodeData^ := UserData;
Include(Result.States, vsInitialUserData);
end
result ist ein PVirtualNode