Release tree-items' data
Posted
by Yura Khodak
on October 13th, 1998
void CTreeCtrlX::ReleaseTreeItem(const HTREEITEM hti)
{
if(hti == NULL)
return;
HTREEITEM hti_ch = GetChildItem( hti );
while( hti_ch != NULL )
{
CSomeXObjets* pObject = ( CSomeXObjets* )GetItemData( hti_ch );
delete pObject;
ReleaseTreeItem( hti_ch );
hti_ch = GetNextSiblingItem( hti_ch );
} //whil
}; //ReleaseTreeIte

Comments
Combining Loj's and Freeman's into the optimal solution
Posted by Legacy on 09/20/1999 12:00amOriginally posted by: Tomaz Stih
When writing tiered app the domain level will
almost certainly contain a copy of your tree ctrl data
as demonstrated in Zoran M. Todorovic's "Connectiong Container to Tree" article.
Thus direct deletion of objects is a bad practice and
one should avoid it... The good solution would be to
delete the tree item and then instruct (in on delete
event as proposed by Freeman) your domain level to
execute the deletion on the pointer.
Tomaz
ReplyWhat if...
Posted by Legacy on 12/30/1998 12:00amOriginally posted by: Pawel Loj
ReplyAn alternative...
Posted by Legacy on 10/22/1998 12:00amOriginally posted by: Russ Freeman
Reply