The TreeView_GetSelectedNode() function returns the ID of the currently-selected node in a tree view field.
TreeView_GetSelectedNode(tree_view_field)
• tree_view_field – The tree view field containing the selected node.
A long integer containing the node ID of the selected node. If the tree doesn’t have a node selected, TV_NODEINVALID is returned.