// Conversion d'un TreeControl en texte
void Conversion(void) 
{
	CStdioFile File;
	if(File.Open( "C:\\test.txt", CFile::modeCreate | CFile::modeWrite | CFile::typeText )) // Cree un nouveau fichier, ici : "C:\\test.txt"
	{
		HTREEITEM hti = m_TreeStruct.GetRootItem();
		while( hti )
		{
			int nLevel = GetTreeLevel( hti );
			while( nLevel-- ) File.WriteString( "|\t" );
			if (m_TreeStruct.ItemHasChildren( hti ))
				File.WriteString("+ " + m_TreeStruct.GetItemText( hti ) + "\r\n");
			else
				File.WriteString("  " + m_TreeStruct.GetItemText( hti ) + "\r\n");
			hti = GetNextItem( hti );
		}
	}

        File.Close(); // Ferme le fichier

	ShellExecute(NULL, "open", "C:\\essai.txt", 0, 0, SW_SHOWNORMAL); // On l'ouvre avec l'executable auquel il est associƩ, sous windows notepad.
	
}



/************************************************************************
									    	           
FONCTION: int GetTreeLevel(HTREEITEM)&HTREEITEM GetNextItem(HTREEITEM)
																        
DEFINITION: Sous fonctions pour la conversion du Tree -> Txt			

************************************************************************/
int CTailleStructureDlg::GetTreeLevel( HTREEITEM hItem )
{
	int iIndent = 0;
	while( (hItem = m_TreeStruct.GetParentItem( hItem )) != NULL )
		iIndent++;
	return iIndent;
}
 
 
HTREEITEM CTailleStructureDlg::GetNextItem( HTREEITEM hItem )
{
	HTREEITEM	hti;
 
	if( m_TreeStruct.ItemHasChildren( hItem ) )
		return m_TreeStruct.GetChildItem( hItem );		
	else
	{		
		while( (hti = m_TreeStruct.GetNextSiblingItem( hItem )) == NULL )
		{
			if( (hItem = m_TreeStruct.GetParentItem( hItem ) ) == NULL )
				return NULL;
		}
	}
	return hti;
}