Can't display icon in tree. Help!

Discussion in 'MFC' started by BGSU98, Oct 4, 2010.

  1. BGSU98

    BGSU98 New Member

    Joined:
    Oct 4, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello. I created a new icon in the resource view called "IDI_OBJECT_GLOBAL_VAR". In my "View" cpp, I added the icon to my HICON ( along with a bunch of other icons that work) using the following:

    hIcon[ICON_INDEX_OBJ_GLOBAL_VAR] = AfxGetApp()->LoadIcon(IDI_OBJECT_GLOBAL_VAR);

    This is then added to a tree list :

    for( GUShort index = 0;
    index < ICON_INDEX_MAXIMUM;
    index++ )
    {
    m_TreeImageList.Add( hIcon[ index ] );
    }

    GetTreeCtrl().SetImageList( &m_TreeImageList, TVSIL_NORMAL );


    When I go to insert an item with the icon, I use the following:

    // Add the new item into the tree beneath the parent item
    hNewItem = GetTreeCtrl().InsertItem( label,
    ICON_INDEX_OBJ_GLOBAL_VAR,
    ICON_INDEX_OBJ_GLOBAL_VAR,
    parentTreeItem,
    hInsertAfter );


    The item itself is placed in the tree, but the icon NEVER displays. It's just blank. Any help on this would be appreciated. Thanks!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice