Sign in to follow this  
chrisliando

Tree Control in Visual C++ MFC

Recommended Posts

chrisliando    100
Hi, I am using Visual C++ MFC to develop an application consist of a Tree Control. The IDE I used is the Visual Studio 2008. At the beginning, there has been a text file (CSV format) named List.dat like this, so I don't create the file: GROUP,FIRST GROUP <--------Parent 1 00005,CHK,1,AAAAA <--------Child of Parent 1 00008,CHK,1,BBBBB <--------Child of Parent 1 00015,CHK,0,CCCCC <--------Child of Parent 1 00001,CHK,0,DDDDD <--------Child of Parent 1 00002,CHK,1,EEEEE <--------Child of Parent 1 00011,RAD,0,OPTION,2 <--------Child of Parent 1 0,OPTION-1 <--------Child of 00011 1,OPTION-2 <--------Child of 00011 GROUP,SECOND GROUP <--------Parent 2 00007,CHK,1,ZZZZZ <--------Child of Parent 2 NOTE: The text Parent 1, Child of Parent 1, etc is just my remark to make it clear.. So it is not part of the file. What I have to do is read the text file and display its content in a form of a Tree Control like this: This is how the application will be: <Folder Image>FIRST GROUP .....................<Checked CheckBox Image>AAAAA .....................<Checked CheckBox Image>BBBBB .....................<UNChecked CheckBox Image>CCCCC .....................<UNChecked CheckBox Image>DDDDD .....................<Checked CheckBox Image>EEEEE .....................<Folder Image>OPTION ..........................................<Checked RadioButton Image>OPTION-1 ..........................................<UNChecked RadioButton Image>OPTION-2 <Folder Image>SECOND GROUP .....................<Checked CheckBox Image>ZZZZZ [OK Button][Cancel Button] EXPLANATION: 1. Folder Image means Windows Folder symbol. FIRST GROUP, SECOND GROUP and OPTION use a Folder Image because they have a few child (they act as PARENT). 2. In front of AAAAA is a Checked CheckBox image referring to this line from List.dat: 00005,CHK,1,AAAAA CHK means CheckBox, 1 means it is CHECKED. 3. Line 00011,RAD,0,OPTION,2 means: RAD is a RadioButton 0: the checked RadioButton is the first RadioButton (which index is 0). 2: there are 2 members in a form of RadioButton 4. The code 00005, 00011 is just a code to make this easier to save the changes, but I don't know how to use them. It is not a sorted number, just random. PROBLEM: 1. How to read the text file so that I can display all its content in a good and correct order? 2. How to display the Tree node as CheckBox, Radio Button and Folder? 3. If I Check / Uncheck the CheckBox AND/OR the RadioButton during the application ran, when I click OK, the application will exit, save the changes and updating List.dat. If I click Cancel, the application will exit and all the changes made will NOT be saved and the file remains like the original... e.g: The original content: 00005,CHK,1,AAAAA after I change it in the application will be: 00005, CHK, 0, AAAAA How to change the content of the text file? Any help will be appreciated.. Thank you very much..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this