Lolka

Hi all.

i have treeview control on my dialog. TreeView with cechkboxes. I need to find, on wich item user click.

In NM_CLICK i try to found item through HitTest method:

1) Getting current Cursror coords:

GetCursorPos(&pt);

2) Convert to Client coords:

ScreenToClient(&pt);

3) And trying to recieve HTREEITEM through HitTest:

HTREEITEM hItem = pTree->HitTest(pt,&uFlag)

void CHitTestDlg::OnNMClickTree1(NMHDR *pNMHDR, LRESULT *pResult)

{

CTreeCtrl* pTree = (CTreeCtrl*) GetDlgItem(IDC_TREE1);

UINT uFlags;

CPoint point;

HTREEITEM hItem;

GetCursorPos(&point);

ScreenToClient(&point);

hItem = pTree->HitTest(point,&uFlags);

}

hItem will be 0x00000000... why so

plz help:)



Re: Visual C++ General TreeView Control HitTest doesn't work

Alex Farber

Try this:

pTree->ScreenToClient(&point);





Re: Visual C++ General TreeView Control HitTest doesn't work

Lolka

Yes thanks very much:)!

it was the answer i look about week:)) about 5 mins ago, i found that in old (1996) archives of some forum:)

1) i need to use not GetCursorPos(&point), right will be use of point = GetMessagePos();

2) coords i recieve from GetMessagePos were in absolute coords, i convert them to MY DIALOG coords.

HitTest needs current control coords! :)

so.. i found the solution and i happy:))