NM_CLICK on Tree Control

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,

I have a dialog box where I have a tree control and a ListBox. The tree control has list of directories and when user clicks on any one of the mp3 files , it will be updated in the ListBox.

My problem here is when I click on the one mp3 files , the one which is below the clicked file will be selected and is updated in ListBox.

Here is my code

void CCombine::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
{<span style="white-space:pre // TODO: Add your control notification handler code here
<span style="white-space:pre NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
<span style="white-space:pre UINT nFlag;<span style="white-space:pre
<span style="white-space:pre CString str,buf,ext,m_strPath;
<span style="white-space:pre CPoint curPoint;
<span style="white-space:pre GetCursorPos(&curPoint);
<span style="white-space:pre ScreenToClient(&curPoint);
<span style="white-space:pre HTREEITEM hItemSel = m_TreeCtrl.HitTest(curPoint, &nFlag);<span style="white-space:pre
<span style="white-space:pre str = m_TreeCtrl.GetItemText(hItemSel);<span style="white-space:pre
<span style="white-space:pre buf = str;
<span style="white-space:pre ext = buf.Right(4);
<span style="white-space:pre if(ext == ".mp3")
<span style="white-space:pre {
<span style="white-space:pre <span style="white-space:pre m_list.InsertItem(LVIF_TEXT|LVIF_STATE, 0, str,(0%2)==0 ? LVIS_SELECTED : 0, LVIS_SELECTED, 0, 0);<span style="white-space:pre
<span style="white-space:pre <span style="white-space:pre }
<span style="white-space:pre *pResult = 0;
}
Im not able to find the mistake here. Please help me to solve ...
<br/>
Thanks


View the full article
 
Back
Top