Image display problem in listcontrol
-
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.
-
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.
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?
-
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?
I really appreciate you that I finally achieve my goal!Thank you very much!
-
I really appreciate you that I finally achieve my goal!Thank you very much!
You are welcome! :)