只需要重载OnTvnItemexpanded函数,在函数中进行处理即可。
void CTreeCtrlEx::OnTvnItemexpanded(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
TVITEM tviNew = pNMTreeView->itemNew;
if (pNMTreeView->action == 1)
{
//设置非展开的图标
SetItemImage(tviNew.hItem,ICON_FOLDER_FILE_T,ICON_FOLDER_FILE_T);
}
else
{
//设置展开的图标
SetItemImage(tviNew.hItem,ICON_FOLDER_FILE_OPEN_T,ICON_FOLDER_FILE_OPEN_T);
}
*pResult = 0;
}