Question : CTreeCtrl in MFC

I've never used a "Tree Control"  I need a solid example of how to use it:
the following BOOLs are set:
      m_bHasButtons = TRUE;// button style
      m_bHasLines = TRUE;//has lines
      m_bLinesAtRoot = TRUE;//root lines
      m_bShowSelAlways = TRUE;//always show
      m_bSingleExpand = TRUE;//allow single expand only

In the program I want to list files(database reports) for each Heading;
Ex: Headings, Shop, Yard, Building, Motorpool, Maintenance, Construction.

Question 1) How do I show these Headings in the TreeCtrl(named: CTreeCtrl  m_cTree) and Question 2) Then be able to insert various "Reports" for each heading(different amount of reports for each heading?

Answer : CTreeCtrl in MFC

Whichever item is highlighted is the "selected item."  So if the user clicked on
    Construction Exspenses.txt  
then that item would be selected -- it would be displayed in a black selection rectangle.

If you then called GetSelectedItem() you would get an HTREEITEM.  Given that, you can find out what its text is.  For example:

   HTREEITEM hItem= m_ctrlTree.GetSelectedItem();
    CString sSelText= m_ctrlTree.GetItemText( hItem );
    MessageBox( sSelText ); // display the text of the selected tree node

 

Random Solutions  
 
programming4us programming4us