This function searches in a tree control for an item’s associated data.
If an exact data match is found, the matching item is returned, otherwise, NULL is returned.
HTREEITEM CTreeCtrlX::FindData(HTREEITEM hti, DWORD dwData) { if(hti == NULL) return NULL; if(GetItemData( hti ) == dwData) { Select( hti, TVGN_CARET); EnsureVisible( hti ); return hti; } hti = GetChildItem( hti ); do { HTREEITEM hti_res; if((hti_res = FindData( hti, dwData)) !=NULL ) return hti_res; }while( (hti = GetNextSiblingItem( hti )) != NULL ); return NULL; }