Your example looks like you are using virtual tree view. If that is the case, the tree view allocates memory for you when a node is created. All you need to do is:
VTree1.NodeDataSize := sizeof (TNodeData) You can then cast the return value from GetNodeData(Node) as TPNodeData. Memory is freed when the node is removed. ----- Original Message ----- From: "Alistair George" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 29, 2004 9:42 AM Subject: [DUG] Pointers (again) > Last night I got out my Delphi books - you know, the decent ones that you got > when you purchased Delphi years ago. > Unfortunately, the downside of them was that the information is disbursed around > which makes following them sometimes a bit tricky. So I am still stymied. > > In the following example, can anyone see if it is in error, as there is no > memory allocation given, and may be the cause of some non-specific access > violation program errors that I was trying to fix. If wrong, example > appreciated. > > type > TPNodeData = ^TNodeData; > TNodeData = record > Index, Level, from, adds, subject, body: Integer; > FullPath, UIDL: string; > end; > > > function GetSpamLevel(from, adds, subject, body: string; Data: TPNodeData): Integer; > > > > > procedure Tmainform.VTree1InitNode(Sender: TBaseVirtualTree; ParentNode, > Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); > var Data: TPNodeData; > begin > //should I insert here: New(Data); > with Sender do > begin > Data := GetNodeData(Node); //Pointer to Node data right? > Data.Index := node.Index; //no memory allocation here. > //Here is data being placed into the pointer 'Data.Level' > Data.Level := GetSpamLevel(SakMsgList1.Items[Data.Index].From, > SakMsgList1.Items[Data.Index].Subject, '', Data); > end; > end; > > > _______________________________________________ > Delphi mailing list > [EMAIL PROTECTED] > http://ns3.123.co.nz/mailman/listinfo/delphi > _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
