Change treeview item

Discussion in 'C++' started by dexz, Feb 2, 2007.

  1. dexz

    dexz Guest

    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);
    }
    }
     
    dexz, Feb 2, 2007
    #1
    1. Advertising

  2. dexz

    red floyd Guest

    dexz wrote:
    > 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
     
    red floyd, Feb 2, 2007
    #2
    1. Advertising

  3. dexz

    dexz Guest

    Sorry, thanks



    red floyd írta:
    > dexz wrote:
    > > 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
     
    dexz, Feb 2, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ssoss

    Display Related Item or Add Item

    ssoss, Sep 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    507
    ssoss
    Sep 19, 2003
  2. Replies:
    2
    Views:
    638
  3. root

    item[LENGTH] vs. *item and malloc()

    root, Aug 21, 2003, in forum: C Programming
    Replies:
    2
    Views:
    397
    Eric Sosman
    Aug 21, 2003
  4. Steven Bethard
    Replies:
    0
    Views:
    410
    Steven Bethard
    Mar 12, 2005
  5. QUASAR
    Replies:
    6
    Views:
    448
    QUASAR
    Jan 17, 2004
Loading...

Share This Page