BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Deleteing TreeNodes

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using
View previous topic :: View next topic  
Author Message
Debbie Erickson
Guest





PostPosted: Fri Oct 24, 2003 5:38 pm    Post subject: Deleteing TreeNodes Reply with quote



Hi. In the Delphi help file for "AddObject" of a treenode says "The memory
referenced by Ptr is not freed when the tree nodes object is freed.".
Under the listing of DeleteChildren, it says "delete all children of a tree
node, freeing all associated memory." These seem to contradict each other.
Before I use the DeleteChildren, do I need to call "dispose" to free up the
pointer(s) for each affected node?


Back to top
greybeard
Guest





PostPosted: Fri Oct 24, 2003 6:21 pm    Post subject: Re: Deleteing TreeNodes Reply with quote



Hi, Debbie

Quote:
Hi. In the Delphi help file for "AddObject" of a treenode says "The
memory
referenced by Ptr is not freed when the tree nodes object is freed.".

This is a pointer to a TreeNode.Data property, which points to your own
object unknown to TreeView. There is why it cannot be freed by TreeView
methods.

Quote:
Under the listing of DeleteChildren, it says "delete all children of a
tree
node, freeing all associated memory." These seem to contradict each
other.


TreeNode.DeleteChildren deletes all Nodes and frees all its memory,
including a Data property, but not the memory, to which the content of Data
points.

Quote:
Before I use the DeleteChildren, do I need to call "dispose" to free up
the
pointer(s) for each affected node?


It depends on the character of objects, to which Data properties point. If

these objects are created in "normal" way (TStringList.Create...), they will
be freed at the end of program. If they are created by New procedure, you
have to dispose the memory allocated before deleting of each node.

Best regards, Vlastik





Back to top
Debbie Erickson
Guest





PostPosted: Fri Oct 24, 2003 6:29 pm    Post subject: Re: Deleteing TreeNodes Reply with quote



Thanks, Greybeard. Have a great day! :)

Debbie
"greybeard" <vlastik.bartos (AT) seznam (DOT) cz> wrote

Quote:
Hi, Debbie

Hi. In the Delphi help file for "AddObject" of a treenode says "The
memory
referenced by Ptr is not freed when the tree nodes object is freed.".

This is a pointer to a TreeNode.Data property, which points to your own
object unknown to TreeView. There is why it cannot be freed by TreeView
methods.

Under the listing of DeleteChildren, it says "delete all children of a
tree
node, freeing all associated memory." These seem to contradict each
other.

TreeNode.DeleteChildren deletes all Nodes and frees all its memory,
including a Data property, but not the memory, to which the content of
Data
points.

Before I use the DeleteChildren, do I need to call "dispose" to free up
the
pointer(s) for each affected node?


It depends on the character of objects, to which Data properties point. If
these objects are created in "normal" way (TStringList.Create...), they
will
be freed at the end of program. If they are created by New procedure, you
have to dispose the memory allocated before deleting of each node.

Best regards, Vlastik







Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi VCL Components Using All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.