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. CTreeView and CImagelist

CTreeView and CImagelist

Scheduled Pinned Locked Moved C / C++ / MFC
c++csscomhelp
2 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.
  • M Offline
    M Offline
    Monty2
    wrote on last edited by
    #1

    i am facing a weird problem i am using XP icons imporitng them adding them to the imagelist attaching it with the ctreeview

    m_ImageList.Create(16,16,ILC_COLOR32|ILC_MASK,4,4);
    m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));

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

    But the Icons don't show right (seems they are painted with less colors) but he same code and same icons are wokring with CListCtrl just fine any ideas , can CImagelist handle such icons it must cause CListCtrl is painting them just right


    C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
    http://www.mastishk.com

    I 1 Reply Last reply
    0
    • M Monty2

      i am facing a weird problem i am using XP icons imporitng them adding them to the imagelist attaching it with the ctreeview

      m_ImageList.Create(16,16,ILC_COLOR32|ILC_MASK,4,4);
      m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICON1));

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

      But the Icons don't show right (seems they are painted with less colors) but he same code and same icons are wokring with CListCtrl just fine any ideas , can CImagelist handle such icons it must cause CListCtrl is painting them just right


      C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
      http://www.mastishk.com

      I Offline
      I Offline
      inlandchris
      wrote on last edited by
      #2

      Here is a snippet of code I wrote last month. It makes a CTreeview with a list of icons (big size) on the left with a description on the right side (2nd column). Dont forget, icons have 2 sizes, small and big. See if you can understand what I wrote:

      CImageList * m_pImageList; CImageList * m_pImageListSmall; // insert two columns (REPORT mode) and modify the new header items m_ctlDatabaseList.GetWindowRect(&rect); m_ctlDatabaseList.InsertColumn(0, strItem1, LVCFMT_LEFT, rect.Width() * 3/9, 0); //spaces them equally. This is a header of the CTree control m_ctlDatabaseList.InsertColumn(1, strItem2, LVCFMT_LEFT, rect.Width() * 1/3, 1); m_ctlDatabaseList.InsertColumn(2, strItem3, LVCFMT_LEFT, rect.Width() * 2/7, 2); ///create the icons CRect rect; CzScanApp *pApp; pApp = (CzScanApp*)AfxGetApp(); m_pImageList = new CImageList(); m_pImageListSmall = new CImageList(); ASSERT(m_pImageList != NULL && m_pImageListSmall != NULL);// serious allocation failure checking m_pImageList->Create(32, 32, TRUE, 4, 4); //This is a large icon m_pImageListSmall->Create(16, 16, TRUE,4, 4);//this is the small icon from the same file m_pImageList->Add(pApp->LoadIcon(IDI_ICON1)); //Icons have 2 sides to them, small size and large size //.....ADD AS MANY ICONS YOU WANT SO LONG AS YOU HAVE THE ICON FILES STORED TO USE m_pImageList->Add(pApp->LoadIcon(IDI_ICON50)); //Icons have 2 sides to them, small size and large size ///now add the icons to show for (iItem = 0; iItem < Limit; iItem++) // insert the items and subitems into the list view. { if(GROUP[iItem+1][0].NoOfDACs== 0) continue; for (iSubItem = 0; iSubItem < 3; iSubItem++) { if (iSubItem == 0) iIcon = ++a; // choose the icon and legend for the entry lvitem.mask = LVIF_TEXT | (iSubItem == 0? LVIF_IMAGE : 0); lvitem.iItem = (iSubItem == 0)? iItem : iActualItem; lvitem.iSubItem = iSubItem; // calculate the main and sub-item strings for the current item pStrTemp1= strIconShortDesc[iIcon].GetBuffer(strIconShortDesc[iIcon].GetLength()); pStrTemp2= strIconDesc[iIcon].GetBuffer(strIconDesc[iIcon].GetLength()); pStrTemp3= strIcon3rdCol[iIcon].GetBuffer(strIcon3rdCol[iIcon].GetLength()); //lvitem.pszText = iSubItem == 0? pStrTemp1 : pStrTemp2;//2; switch(iSubItem) { case 0: lvitem.pszText = pStrTemp1; break; case 1: lvite

      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