Hi
Using the following code I defined that when Im loading the Announcements into the program it marks the some of them with various icons in the TreeView. This was fairly easy, because when I pasted a new element into the tree (hTemp = GetTreeCtrl().InsertItem(pDoc->m_pAnnouncements[ann].m_cAnnouncementName, SecondParentItem, TVI_LAST), I got the tree element back into the hTemp variable, and I could easily change the picture.
My question would be that how could I go through the Announcements and modify their icons, but without clicking anywhere in the tree.
Thanks for any help in forward!
Screenshot and code follows:
Using the following code I defined that when Im loading the Announcements into the program it marks the some of them with various icons in the TreeView. This was fairly easy, because when I pasted a new element into the tree (hTemp = GetTreeCtrl().InsertItem(pDoc->m_pAnnouncements[ann].m_cAnnouncementName, SecondParentItem, TVI_LAST), I got the tree element back into the hTemp variable, and I could easily change the picture.
My question would be that how could I go through the Announcements and modify their icons, but without clicking anywhere in the tree.
Thanks for any help in forward!
Screenshot and code follows:
Code:
for(int ann = 0; ann < pDoc->m_iAnnouncements; ann++)
{
hTemp = GetTreeCtrl().InsertItem(pDoc->m_pAnnouncements[ann].m_cAnnouncementName, hSecondParentItem, TVI_LAST);
GetTreeCtrl().SetItemData(hTemp, TREEITEM_TE_ANN_ANN);
CString sSelItemText;
sSelItemText = GetTreeCtrl().GetItemText(hTemp);
DWORD type = GetTreeCtrl().GetItemData(hTemp);
int iAnnId;
for(j = 0; j < pDoc->m_iAnnouncements; j++)
{
if(pDoc->m_pAnnouncements[j].m_cAnnouncementName == sSelItemText)
{
iAnnId = pDoc->m_pAnnouncements[j].m_iAnnouncement;
break;
}
}
int iCount = -1;
for(i= 0; i < pDoc->m_iNodes; i++)
{
int iNodeindex = -1;
for(int t=0;t<pDoc->m_iNodeTypes;t++)
{
if((UINT)pDoc->m_pNodeTypeData[t].m_iNodeType == pDoc->m_pNodes[i].m_iNodeType)
{
iNodeindex = t;
break;
}
}
if(iNodeindex == -1)
{
//ExitProcess(-12);
CString sMsg;
sMsg.Format("The node type %d missed.", pDoc->m_pNodes[i].m_iNodeType);
AfxMessageBox(sMsg);
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType1 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData1) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType2 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData2) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType3 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData3) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType4 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData4) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType5 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData5) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType6 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData6) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType7 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData7) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType8 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData8) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType9 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData9) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType10 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData10) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType11 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData11) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType12 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData12) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType13 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData13) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType14 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData14) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType15 == "ComboBox") && (atoi(pDoc->m_pNodes[i].m_cData15) == iAnnId))
{
iCount = i;
break;
}
}
if(iCount == -1)
{
GetTreeCtrl().SetItemImage(hTemp, 27, 27);
}
else
{
GetTreeCtrl().SetItemImage(hTemp, 1, 1);
}
}