Change treeview item

D

dexz

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!
Screemshot and code follows:


http://algotech.extra.hu/menueditor.jpg




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.m_iNodeType)

{
iNodeindex = t;
break;
}
}
if(iNodeindex == -1)
{
//ExitProcess(-12);
CString sMsg;
sMsg.Format("The node type %d missed.", pDoc-
m_pNodes.m_iNodeType);

AfxMessageBox(sMsg);
}

if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType1 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData1) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType2 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData2) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType3 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData3) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType4 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData4) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType5 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData5) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType6 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData6) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType7 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData7) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType8 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData8) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType9 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData9) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType10 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData10) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType11 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData11) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType12 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData12) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType13 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData13) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType14 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData14) == iAnnId))
{
iCount = i;
break;
}
if((pDoc->m_pNodeTypeData[iNodeindex].m_cFeatureParType15 ==
"ComboBox") && (atoi(pDoc->m_pNodes.m_cData15) == iAnnId))
{
iCount = i;
break;
}
}
if(iCount == -1)
{
GetTreeCtrl().SetItemImage(hTemp, 27, 27);

}
else
{
GetTreeCtrl().SetItemImage(hTemp, 1, 1);
}
}
 
R

red floyd

dexz said:
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!
Screemshot and code follows:
Wrong group. Try a group with Microsoft or MFC in its name.
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
 
D

dexz

Sorry, thanks



red floyd írta:
dexz said:
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!
Screemshot and code follows:
Wrong group. Try a group with Microsoft or MFC in its name.
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top