Guest_imported
New member
- Jan 1, 1970
- 0
Hello,
I am not usually programming C++, so this question is probably simple to many of you.
I am making a user interface where a CTreeCtrl with only one level and checkboxes is going to represent different paths to executable files on that computer. This part of the program is to load a list of filenames from a textfile and then display those files in the tree, and if they exist on that computer have its checkbox checked.
I think that I have the code correct... but something must be missing, or I am simply just wrong
because I set the boxes checked in the code, but they do not become checked in the user interface.
I write the code below in a dialog's onInitDialog().
m_tree is defined in the dialog class ( CTreeCtrl m_tree; )
// ** FileReader is a class that reads in a textfile and you can then acces each line seperatly ***
// ** fileSearchWithPath(...) is simply a global function that tests if the file exists (with fopen()) **
// ****************************************************
// ****************************************************
FileReader inFile("C:/temp/programs.txt"
;
int numLines = inFile.getNumberOfLines();
for (int i = 0; i < numLines; i++)
{
HTREEITEM myItem = m_tree.InsertItem(inFile.getLine(i));
if (fileSearchWithPath(inFile.getLine(i)))
{
m_tree.SetCheck(myItem, TRUE);
}
}
If someone could help me i would be very grateful.
Robert
I am not usually programming C++, so this question is probably simple to many of you.
I am making a user interface where a CTreeCtrl with only one level and checkboxes is going to represent different paths to executable files on that computer. This part of the program is to load a list of filenames from a textfile and then display those files in the tree, and if they exist on that computer have its checkbox checked.
I think that I have the code correct... but something must be missing, or I am simply just wrong

I write the code below in a dialog's onInitDialog().
m_tree is defined in the dialog class ( CTreeCtrl m_tree; )
// ** FileReader is a class that reads in a textfile and you can then acces each line seperatly ***
// ** fileSearchWithPath(...) is simply a global function that tests if the file exists (with fopen()) **
// ****************************************************
// ****************************************************
FileReader inFile("C:/temp/programs.txt"

int numLines = inFile.getNumberOfLines();
for (int i = 0; i < numLines; i++)
{
HTREEITEM myItem = m_tree.InsertItem(inFile.getLine(i));
if (fileSearchWithPath(inFile.getLine(i)))
{
m_tree.SetCheck(myItem, TRUE);
}
}
If someone could help me i would be very grateful.
Robert