I have a CTreeCtrl in a dialog and catch TVN_SELCHANGED messages, but execution doesn't go into handlers. What can be wrong? My code:
BEGIN_MESSAGE_MAP(CMaterParamExtDlg, CDialog)
ON_NOTIFY(TVN_ITEMCHANGING, IDC_MATERIAL_PROP_TREE, OnSelChangingTreeCtrl)
ON_NOTIFY(TVN_ITEMCHANGED, IDC_MATERIAL_PROP_TREE, OnSelChangedTreeCtrl)
END_MESSAGE_MAP()
void CMaterParamExtDlg :: OnSelChangedTreeCtrl (NMHDR* pNMHDR, LRESULT* pResult)
{
if (m_TreeCtrl != 0)
{
HTREEITEM treeitem = m_TreeCtrl->GetSelectedItem();
CString treeitemtext = m_TreeCtrl->GetItemText(treeitem);
MessageBox(treeitemtext);
}
*pResult = 0;
}
void CMaterParamExtDlg :: OnSelChangingTreeCtrl (NMHDR* pNMHDR, LRESULT* pResult)
{
if (m_TreeCtrl != 0)
{
HTREEITEM treeitem = m_TreeCtrl->GetSelectedItem();
CString treeitemtext = m_TreeCtrl->GetItemText(treeitem);
MessageBox(treeitemtext);
}
*pResult = 0;
}
I tried to use breakpoints to see if execution goes into handlers but nothing happens.
Tree Control properties:
CONTROL "",IDC_MATERIAL_PROP_TREE,"SysTreeView32",TVS_HASBUTTONS
| TVS_HASLINES | TVS_LINESATROOT | TVS_DISABLEDRAGDROP
| TVS_TRACKSELECT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,4,4,115,218
Pretty simple. Use TVN_SELCHANGED instead of TVN_ITEMCHANGED. Ditto for TVN_ITEMCHANGING.