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. CImagelist and CListCtrl problem.

CImagelist and CListCtrl problem.

Scheduled Pinned Locked Moved C / C++ / MFC
dotnetgraphicshelpquestion
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
    justin223
    wrote on last edited by
    #1

    I'm trying to load a bitmap into a imagelist, and to get a transparent background. The imagelist is used in a CListCtrl. When I load the bitmap directly I get transparent images, but wrong colors. m_ilReport.Create(IDB_TOOLBAR_GRID256, 16, 1, RGB(255,0,255)); If I load it into a CBitmap first the colors look ok, the problem is that the mask color is replaced with black. SetBkColor seems to have no affect. I've tried with regular colors too. m_ilReport.Create(16, 16, ILC_COLOR8, 16, 1); CBitmap bmp; bmp.LoadBitmap(IDB_TOOLBAR_GRID256); m_ilReport.Add(&bmp, RGB(255, 0, 255)); m_ilReport.SetBkColor(CLR_NONE); ctl.SetImageList(&m_ilReport); What have I done wrong?

    D 1 Reply Last reply
    0
    • J justin223

      I'm trying to load a bitmap into a imagelist, and to get a transparent background. The imagelist is used in a CListCtrl. When I load the bitmap directly I get transparent images, but wrong colors. m_ilReport.Create(IDB_TOOLBAR_GRID256, 16, 1, RGB(255,0,255)); If I load it into a CBitmap first the colors look ok, the problem is that the mask color is replaced with black. SetBkColor seems to have no affect. I've tried with regular colors too. m_ilReport.Create(16, 16, ILC_COLOR8, 16, 1); CBitmap bmp; bmp.LoadBitmap(IDB_TOOLBAR_GRID256); m_ilReport.Add(&bmp, RGB(255, 0, 255)); m_ilReport.SetBkColor(CLR_NONE); ctl.SetImageList(&m_ilReport); What have I done wrong?

      D Offline
      D Offline
      Debs 0
      wrote on last edited by
      #2

      You are setting the transparency colour to be the bright pink that has RGB(255,0,255). It's what I do in my code, as it's not a colour I use normally in the actual bitmap. Snip of code that works for me: m_ImageList.Create(IDB_ALARMBANNER ,16,32,RGB(255,0,255)); m_nImageIndex[IMAGE_ALARMBANNER] = nImageIndex++; //array used to reference the image AddBitmapToList(m_ImageList,IDB_ALARMCLIENT,IMAGE_ALARMCLIENT,nImageIndex++); void CMainDialog::AddBitmapToList(CImageList& ImageList, UINT nId, UINT nImageId, UINT nImageIndex) { CBitmap bm; bm.LoadBitmap(nId); ImageList.Add(&bm, RGB(255,0,255)); //set transparency colour m_nImageIndex[nImageId] = nImageIndex; } Debbie

      J 1 Reply Last reply
      0
      • D Debs 0

        You are setting the transparency colour to be the bright pink that has RGB(255,0,255). It's what I do in my code, as it's not a colour I use normally in the actual bitmap. Snip of code that works for me: m_ImageList.Create(IDB_ALARMBANNER ,16,32,RGB(255,0,255)); m_nImageIndex[IMAGE_ALARMBANNER] = nImageIndex++; //array used to reference the image AddBitmapToList(m_ImageList,IDB_ALARMCLIENT,IMAGE_ALARMCLIENT,nImageIndex++); void CMainDialog::AddBitmapToList(CImageList& ImageList, UINT nId, UINT nImageId, UINT nImageIndex) { CBitmap bm; bm.LoadBitmap(nId); ImageList.Add(&bm, RGB(255,0,255)); //set transparency colour m_nImageIndex[nImageId] = nImageIndex; } Debbie

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

        thanks. But that doesnt help me. I want to know why it doesnt work. Why do the colors look fuckedup if I use the same overloaded version of create as you do? (The one where u specify the mask color) Why do the mask become black when I first load the bmp into a CBitmap and then load the CBitmap into the imagelist?

        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