SAKryukov gave you some very important information, I want to add some with this:
You can Process WM_NOTIFY windows message and NM_CLICK action, you can get the proper Tree Object
here is a simple example:
case WM_NOTIFY:
NMHDR *nmhdr;
nmhdr=(NMHDR *)lParam;
switch(nmhdr->code)
{
case NM_CLICK:
TVHITTESTINFO tv;
HTREEITEM htr,htr_tblName;
RECT rc_tree;
POINT ms_pt;
GetCursorPos(&ms_pt);
GetWindowRect(nmhdr->hwndFrom, &rc_tree);
tv.pt.x=ms_pt.x-rc_tree.left;
tv.pt.y=ms_pt.y-rc_tree.top;
htr=TreeView_HitTest(nmhdr->hwndFrom,&tv);
}
good luck