07-02-2007 12:46 PM
07-02-2007 03:28 PM
Hello Oliveira,
I am a bit confused about your code:
int val = 0;
GetCtrlVal(Handle, TREE, &val);
SetCtrlAttribute(Handle, TREE, ATTR_SHOW_MARKS, val);
If you want to show marks on the tree control. You should use this line of code:
SetCtrlAttribute(Handle, TREE, ATTR_SHOW_MARKS, 1);
To answer your question: special tree functions are located in the User Interface Library -> Controls/Graphs/Strip Charts -> List/Tree(Lable/Value) Controls. From this library, use the IsListItemChecked (Handle, TREE, index, &checked) function. If the item with the given index is checked, the variable "checked" will be 1. If not, "checked" is 0. To get the item's label, use the function GetLabelFromIndex (Handle, TREE, index, label), where the variable label is a string (array of chars):
int index ,num_indices;
int checked;
char label[100];
char message[100];
GetNumListItems (Handle, TREE, &num_indices);
for (index = 0; index < num_indices; index++){
IsListItemChecked (Handle, TREE, index, &checked);
if (checked){
GetLabelFromIndex (Handle, TREE, index, label);
Fmt (message, "List item %s is checked.", label);
MessagePopup ("Tree", message);
}
}
Hope this helps...
07-03-2007 10:41 AM
This will do the trick:
int item;
char buf[100];
/* this gets the first item that is marked */
GetTreeItem(panel, PANEL_TREE, VAL_ALL, 0, VAL_FIRST, VAL_NEXT_PLUS_SELF,
VAL_MARKED, &item);
while (item >= 0)
{
GetTreeItemAttribute(panel, PANEL_TREE, item, ATTR_LABEL_TEXT, buf);
printf("%s\n", buf);
/* this gets the next item that is marked */
GetTreeItem(panel, PANEL_TREE, VAL_ALL, item, item, VAL_NEXT, VAL_MARKED, &item);
}