Code
//动态加载位图到imagelist
HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR24 |ILC_MASK , 0, 1);
m_imgNormal.Attach(hList);
for (int i=0;i<arr.GetSize();++i)
{
CString filename;
filename.Format(L".\\TT32\\%s",arr.GetAt(i));
HBITMAP bmpHandle = (HBITMAP)LoadImage(NULL,
filename,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE);
if (bmpHandle==NULL)
{
MessageBox(L"Can't get the bitmap");
}
CBitmap bmpPicture;
CBitmap *bmpFromHandle = bmpPicture.FromHandle(bmpHandle);
m_imgNormal.Add(bmpFromHandle,RGB(255,0, 255));
}
m_listCtrl.SetImageList(&m_imgNormal,LVSIL_NORMAL);
//把位图显示到imagelist ctrl中
for (int i=0;i<arr.GetSize();i++)
{
LVITEM lvi;
lvi.mask = LVIF_IMAGE;
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.iImage =i;
m_listCtrl.InsertItem(&lvi);
}
//动态加载位图到imagelist
HIMAGELIST hList = ImageList_Create(32,32, ILC_COLOR24 |ILC_MASK , 0, 1);
m_imgNormal.Attach(hList);
for (int i=0;i<arr.GetSize();++i)
{
CString filename;
filename.Format(L".\\TT32\\%s",arr.GetAt(i));
HBITMAP bmpHandle = (HBITMAP)LoadImage(NULL,
filename,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE);
if (bmpHandle==NULL)
{
MessageBox(L"Can't get the bitmap");
}
CBitmap bmpPicture;
CBitmap *bmpFromHandle = bmpPicture.FromHandle(bmpHandle);
m_imgNormal.Add(bmpFromHandle,RGB(255,0, 255));
}
m_listCtrl.SetImageList(&m_imgNormal,LVSIL_NORMAL);
//把位图显示到imagelist ctrl中
for (int i=0;i<arr.GetSize();i++)
{
LVITEM lvi;
lvi.mask = LVIF_IMAGE;
lvi.iItem = i;
lvi.iSubItem = 0;
lvi.iImage =i;
m_listCtrl.InsertItem(&lvi);
}