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. Image display problem in listcontrol

Image display problem in listcontrol

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studiocsharpc++debugginghelp
4 Posts 2 Posters 1 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
    tianzhili4399
    wrote on last edited by
    #1

    The code can correctly display the bmp image that comes with the IDE, but can't display the image I added. The IDE is visual studio 2012 and I use mfc to display bmp pictures. This is the first piece of code in OnInitDialog():

    static CImageList imgList;
    imgList.Create(48,48,ILC\_COLOR32,1,1);
    imgList.Add(AfxGetApp()->LoadIcon(IDR\_MAINFRAME));
    m\_List.SetImageList(&imgList,LVSIL\_NORMAL);
    
    m\_List.InsertItem(0,\_T("1th Test item"));
    

    and the result of debug ——able to display the picture while the second piece of code in OnInitDialog():

    static CImageList imgList;
    imgList.Create(40,48,ILC\_COLOR32,1,1);
    imgList.Add(AfxGetApp()->LoadIcon(IDB\_BITMAP1));
    m\_List.SetImageList(&imgList,LVSIL\_NORMAL);
    
    m\_List.InsertItem(0,\_T("1th Test item"));
    

    and the result of debug ——unable to display the picture,only blanks are displayed. I am really sorry that I am a new man here and I do not know how to stick debug screenshots here.

    V 1 Reply Last reply
    0
    • T tianzhili4399

      The code can correctly display the bmp image that comes with the IDE, but can't display the image I added. The IDE is visual studio 2012 and I use mfc to display bmp pictures. This is the first piece of code in OnInitDialog():

      static CImageList imgList;
      imgList.Create(48,48,ILC\_COLOR32,1,1);
      imgList.Add(AfxGetApp()->LoadIcon(IDR\_MAINFRAME));
      m\_List.SetImageList(&imgList,LVSIL\_NORMAL);
      
      m\_List.InsertItem(0,\_T("1th Test item"));
      

      and the result of debug ——able to display the picture while the second piece of code in OnInitDialog():

      static CImageList imgList;
      imgList.Create(40,48,ILC\_COLOR32,1,1);
      imgList.Add(AfxGetApp()->LoadIcon(IDB\_BITMAP1));
      m\_List.SetImageList(&imgList,LVSIL\_NORMAL);
      
      m\_List.InsertItem(0,\_T("1th Test item"));
      

      and the result of debug ——unable to display the picture,only blanks are displayed. I am really sorry that I am a new man here and I do not know how to stick debug screenshots here.

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      tianzhili4399 wrote:

      static CImageList imgList; imgList.Create(40,48,ILC_COLOR32,1,1); imgList.Add(AfxGetApp()->LoadIcon(IDB_BITMAP1)); m_List.SetImageList(&imgList,LVSIL_NORMAL); m_List.InsertItem(0,_T("1th Test item"));

      Is the image IDB_BITMAP1 an icon or a bitmap? If it is a bitmap then you have to use CBitmap::LoadBitmap method (or LoadBitmap API function) instead. BTW, what does the

      AfxGetApp()->LoadIcon(IDB_BITMAP1)

      return?

      T 1 Reply Last reply
      0
      • V Victor Nijegorodov

        tianzhili4399 wrote:

        static CImageList imgList; imgList.Create(40,48,ILC_COLOR32,1,1); imgList.Add(AfxGetApp()->LoadIcon(IDB_BITMAP1)); m_List.SetImageList(&imgList,LVSIL_NORMAL); m_List.InsertItem(0,_T("1th Test item"));

        Is the image IDB_BITMAP1 an icon or a bitmap? If it is a bitmap then you have to use CBitmap::LoadBitmap method (or LoadBitmap API function) instead. BTW, what does the

        AfxGetApp()->LoadIcon(IDB_BITMAP1)

        return?

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

        I really appreciate you that I finally achieve my goal!Thank you very much!

        V 1 Reply Last reply
        0
        • T tianzhili4399

          I really appreciate you that I finally achieve my goal!Thank you very much!

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #4

          You are welcome! :)

          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