Is there a way to get the root item handle from one of its children?
I usually store the parent's handle as the child items user data (SetItemData), which allows for quick traversal back up the tree.
Or you can use the API to get it:
#define TV_FIRST 0x1100
#define TVM_GETNEXTITEM (TV_FIRST + 10)
#define TVGN_PARENT 0x0003
DECLARE IMPORT,SendMessageA(hwnd as UINT,uMsg as UINT,wParam as UINT,lParam as UINT),UINT;
sub GetParentItem(UINT hTreeView,UINT hChildItem),UINT
{
return SendMessageA(hTreeView, TVM_GETNEXTITEM, TVGN_PARENT, hChildItem);
}
Sorry, You asked for the root. You can use the same method but change TVGN_PARENT to TVGN_ROOT:
#define TVGN_ROOT 0x0000
thanks Paul :)