Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. cannot add icon to tree control [modified]

cannot add icon to tree control [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tataxin
    wrote on last edited by
    #1

    I want to add some icon to my tree control, so I do like this:

        /\*previous declare CTreeCtrl m\_treeTable \*/
    
        CImageList m\_imageList; //image list used by the tree
    m\_imageList.Create (IDB\_TABLE, 32, 0, RGB(255, 255, 255));
    
    //Manage your tree items......
    CImageList \*p\_imageList = m\_treeTable.SetImageList (&m\_imageList, TVSIL\_NORMAL);
    
    HTREEITEM rootItem = m\_treeTable.InsertItem(\_T("RootItem"), 0, 0);
    
    m\_treeTable.InsertItem(\_T("item 1"), 0, 0, rootItem);
    HTREEITEM aItem = m\_treeTable.InsertItem(\_T("item2"));
    m\_treeTable.SetItemImage(aItem, 0, 0);
    

    When I execute program, the dialog create small spaces for images but without any image. Does anyone know why? Thanks in advance, :)

    modified on Wednesday, May 28, 2008 3:39 AM

    S 1 Reply Last reply
    0
    • T tataxin

      I want to add some icon to my tree control, so I do like this:

          /\*previous declare CTreeCtrl m\_treeTable \*/
      
          CImageList m\_imageList; //image list used by the tree
      m\_imageList.Create (IDB\_TABLE, 32, 0, RGB(255, 255, 255));
      
      //Manage your tree items......
      CImageList \*p\_imageList = m\_treeTable.SetImageList (&m\_imageList, TVSIL\_NORMAL);
      
      HTREEITEM rootItem = m\_treeTable.InsertItem(\_T("RootItem"), 0, 0);
      
      m\_treeTable.InsertItem(\_T("item 1"), 0, 0, rootItem);
      HTREEITEM aItem = m\_treeTable.InsertItem(\_T("item2"));
      m\_treeTable.SetItemImage(aItem, 0, 0);
      

      When I execute program, the dialog create small spaces for images but without any image. Does anyone know why? Thanks in advance, :)

      modified on Wednesday, May 28, 2008 3:39 AM

      S Offline
      S Offline
      SandipG
      wrote on last edited by
      #2

      You are creating the image list on stack. Make the imagelist variable a calss member.

      T 1 Reply Last reply
      0
      • S SandipG

        You are creating the image list on stack. Make the imagelist variable a calss member.

        T Offline
        T Offline
        tataxin
        wrote on last edited by
        #3

        oh, it works. Thank you very much, SandipG

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups