Your tree has ATTR_SELECTION_MODE set to VAL_SELECTION_MULTIPLE (which is the default setting). If you want to allow the user to select multiple items (or no items, as you pointed out) and you need to programmatically find all the selected items, then use GetTreeItem. An example is provided below.
However, if you want the user to select exactly one item, then change the ATTR_SELECTION_MODE to VAL_SELECTION_SINGLE, and then you can use GetCtrlIndex (or GetActiveTreeItem) to find the one item that is selected. In this case, the active item is always the only one that is selected.
To find all the selected items when ATTR_SELECTION_MODE is VAL_SELECTION_MULTIPLE, use GetTreeItem in a loop.
int GetSelectedTreeItems (int panel, int tree)
{
int curItem, numSelected,
direction;
curItem = VAL_FIRST;
direction = VAL_NEXT_PLUS_SELF;
numSelected = 0;
while (1)
{
GetTreeItem (panel, tree, VAL_ALL, 0, curItem, direction, VAL_SELECTED, &curItem);
if (curItem < 0)
break;
numSelected++;
direction = VAL_NEXT;
}
return numSelected;
}