Hi,
I think you use the same TreeIndex for the whole function.
You use the indexes in a wrong way.
First of all, I think the tree index is 0-based.
So if you use your item index for the relative index, the child item use a relative index with a value equal to 1 (should be 0 for the first item).
Then you insert the item with a sibling relation and a relative index equal to 2 (should be 0).
The next items should use an incremental relative index.
The global item index cannot be used for the relative index. You should define a new index.
Here is the code that works for me :
int childTreeIndex = 0; /* relative item index for the items inserted with a sibling relation */ Tok = strtok(chrOutParameterList, ",");
while (Tok != NULL) {
// Anda
if ( g_intTreeIndex == 1 )
{
InsertTreeItem(intDSPanelHandle, intDSControlHandle, VAL_CHILD,
0 /* The item index is 0-based */, VAL_NEXT,
Tok, 0, 0, g_intTreeIndex /* your incremental item value */);
}
else
{
InsertTreeItem(intDSPanelHandle, intDSControlHandle, VAL_SIBLING,
childTreeIndex++ /* incremental relative index */, VAL_NEXT,
Tok, 0, 0, g_intTreeIndex /* your incremental item value */);
}
g_intTreeIndex = g_intTreeIndex + 1;
Tok = strtok(NULL,",");
}
Another way to do that :You can do it in a easier way, without relative index.
Tok = strtok(chrOutParameterList, ",");
while (Tok != NULL) {
// Anda
if ( g_intTreeIndex == 0 )
{
InsertTreeItem (intDSPanelHandle, intDSControlHandle, VAL_CHILD, 0,
VAL_FIRST, Tok, 0, 0, g_intTreeIndex);
}
else
{
InsertTreeItem (intDSPanelHandle, intDSControlHandle, VAL_SIBLING,
0 /* The relative index is always 0 */,
VAL_LAST /* You insert the item at the end */ , Tok, 0, 0, g_intTreeIndex);
}
g_intTreeIndex = g_intTreeIndex + 1;
Tok = strtok(NULL,",");
Hope this help.
Bruno