Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
Hi all,

i m using this for TVN_ITEMEXPANDING,here its working fine when i exand or collapse tree item by keyboard.

But when i exand or collapse tree item by mouce click than it is change image of previously selected item.

please tell me where i m wrong.


void CTree::OnTvnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult)<br />{<br />	LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);<br />	<br />	NMTREEVIEW* pnmtv = (NMTREEVIEW*) pNMHDR;<br />	<br />	CTreeCtrl& tc = GetTreeCtrl();<br />	HTREEITEM item = tc.GetSelectedItem(); <br /><br />	if ( pnmtv->action == TVE_EXPAND )<br />	{<br />		tc.SetItemImage(item,1,1);		<br />	}	<br />	else if ( pnmtv->action == TVE_COLLAPSE )<br />	{<br />		tc.SetItemImage(item,0,0);<br />	}<br />	<br />	*pResult = 0;

}

thanks in advance.
Posted
Updated 15-Oct-10 11:32am
v2

1 solution

"_$h@nky_" wrote:
HTREEITEM item = tc.GetSelectedItem();


Because you are setting the image of selected item. Use pnmtv->itemNew.hItem


HTREEITEM item = pnmtv->itemNew.hItem;

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900