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. Adding icons to an imagelist that is used in a listctrl

Adding icons to an imagelist that is used in a listctrl

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
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.
  • J Offline
    J Offline
    Jochem
    wrote on last edited by
    #1

    I use a CListCtrl on a dialog. The problem is that the background of the icons is somehow changed to black when the dialog pops up. But the background is supposed to be transparent. Who knows how to prevent this? This is the code that i use: CMyDlg::OnInitDialog() { m_imageList.Create(32, 32, ILC_COLOR4, 2, 2); //adding the icons for(int i=0; i<2; i++) { int nID = GetIconID( i ); //code taken from CWinApp::LoadIcon(int nID ) HICON hIcon = ::LoadIcon(AfxFindResourceHandle(MAKEINTRESOURCE(nID), RT_GROUP_ICON), MAKEINTRESOURCE(nID)); m_imageList.Add(hIcon); } m_listCtrl.SetImageList(&m_imageList, LVSIL_NORMAL); //inserting items in the listctrl for(int nIndex=0; nIndex<2; nIndex++) { m_type.InsertItem(nIndex, "some text", nIndex); nIndex++; } } Thanks in advance, Jochem

    R 1 Reply Last reply
    0
    • J Jochem

      I use a CListCtrl on a dialog. The problem is that the background of the icons is somehow changed to black when the dialog pops up. But the background is supposed to be transparent. Who knows how to prevent this? This is the code that i use: CMyDlg::OnInitDialog() { m_imageList.Create(32, 32, ILC_COLOR4, 2, 2); //adding the icons for(int i=0; i<2; i++) { int nID = GetIconID( i ); //code taken from CWinApp::LoadIcon(int nID ) HICON hIcon = ::LoadIcon(AfxFindResourceHandle(MAKEINTRESOURCE(nID), RT_GROUP_ICON), MAKEINTRESOURCE(nID)); m_imageList.Add(hIcon); } m_listCtrl.SetImageList(&m_imageList, LVSIL_NORMAL); //inserting items in the listctrl for(int nIndex=0; nIndex<2; nIndex++) { m_type.InsertItem(nIndex, "some text", nIndex); nIndex++; } } Thanks in advance, Jochem

      R Offline
      R Offline
      RobJones
      wrote on last edited by
      #2

      not sure but it could be this Jochem wrote: m_imageList.Create(32, 32, ILC_COLOR4, 2, 2); try using ILC_COLOR16|ILC_MASK instead of ILC_COLOR4 Rob Whoever said nothing's impossible never tried slamming a revolving door!

      J 1 Reply Last reply
      0
      • R RobJones

        not sure but it could be this Jochem wrote: m_imageList.Create(32, 32, ILC_COLOR4, 2, 2); try using ILC_COLOR16|ILC_MASK instead of ILC_COLOR4 Rob Whoever said nothing's impossible never tried slamming a revolving door!

        J Offline
        J Offline
        Jochem
        wrote on last edited by
        #3

        Adding ILC_MASK did the trick

        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