[Release tree-items data] 

It is common use to associate user data with a tree item. If it is a pointer to some class the function that gracefully releases all memory is needed. The one is given below. It takes as an argument a handle of a tree item and deletes all CSomeXObjets (user objects) in all subitems. If You want to release the whole tree call: ReleaseTreeItem( TVI_ROOT ); 

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

Date Posted: August 11, 1998