TreeView filling

Hi every one. Wanna fill my TreeView object recursively. I have some troubles with that. Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
struct tagElem { 
    wchar_t tagName[20]; 
    wchar_t value[256]; 
    int status; 
    tagElem *parent; 
    tagElem *firstChild; 
    tagElem *nextChild; 
    int output(TTreeNodes*, tagElem*, int); 

}; 

int tagElem::output(TTreeNodes *treeNode, tagElem *printNode, int index) { 
    if (treeNode->GetFirstNode() == NULL) { 

        treeNode->Add(NULL, printNode->tagName); 
    } 

    if (printNode->firstChild != NULL) { 
        printNode = printNode->firstChild; 
        treeNode->AddChild(treeNode->Item[index], printNode->tagName); 

        printNode->output(treeNode,printNode, index+1); 
    } 

    printNode = this; 
    if (printNode->nextChild != NULL) { 

        printNode = this->nextChild; 
        treeNode->Add(treeNode->Item[index], printNode->tagName); 
        index = printNode->output(treeNode,printNode, index+1); 
    } 
    return index; 
} 


firstChild points to the first element of the sequence of "children" of the "parent" Element. So because of index this code working wrong. Can't figure out by my self. Can't find other ways to fill this tree. May be i shoudn't use Add() and AddChild() functions? Didn't find equival replacement.
Topic archived. No new replies allowed.