【发布时间】:2016-04-24 23:44:18
【问题描述】:
我想在 MFC 的列表控件中显示 bmp 图像和文本, 它应该为不同的项目显示不同的bmp图像,但它为所有项目显示相同的bmp
这是我的代码
CListCtrl m_cParentListContrl;
CImageList m_ImageList[3];
m_ImageList[0].Create(IDB_BMP_LISTCTRL,128,1,RGB(150,150,100));
m_ImageList[1].Create(IDB_BMP_CHECKBOX,128,1,RGB(150,150,100));
m_ImageList[2].Create(IDB_BMP_COMBOBOX,128,1,RGB(150,150,100));
m_cParentListContrl.SetImageList(m_ImageList,LVSIL_NORMAL);
for(int i = 0 ; i < 3 ; i++)
{
val.Format(_T("List ::%d"),i);
//third parameter for index of image to be displayed
// if that replaced by i to 0 then it display single image else not
m_cParentListContrl.InsertItem(i,val,i);
}
谢谢
【问题讨论】:
-
为什么要为三个独立的位图使用三个独立的图像列表?我认为您误解了图像列表如何为 CListCtrl 工作。我认为您想要一个包含三张图片的图片列表。
-
我是 MFC 新手,你能举个小例子吗
-
您可能认为您已经创建了一个包含 3 个图像的 ImageList,但没有!您确实创建了一个包含三个 ImageList 的数组!我从没想过它可以像你那样解释!
标签: visual-studio-2010 visual-c++ mfc dev-c++