However, setting 'single expand' style has also a drawback. It is that expanded item once will be collapsed again when it is unselected. This behaviour is different with usual applications' behaviour. Therefore, if remaining unselected item, you should write code like below.
void CExpandTestDlg::OnItemexpandingTree(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
//Getting a current item
HTREEITEM hCurItem = m_Tree.GetSelectedItem();
//Comparing to a received item and then,
//if the received item is not same,
//just return for protecting notify TVN_ITEMEXPANDED
if(hCurItem != pNMTreeView->itemNew.hItem)
{
*pResult = 1;
return;
}
*pResult = 0;
}
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
//Getting a current item
HTREEITEM hCurItem = m_Tree.GetSelectedItem();
//Comparing to a received item and then,
//if the received item is not same,
//just return for protecting notify TVN_ITEMEXPANDED
if(hCurItem != pNMTreeView->itemNew.hItem)
{
*pResult = 1;
return;
}
*pResult = 0;
}
reference from MSDN
No comments:
Post a Comment