BOOL bRes;
m_hImageList=ImageList_Create(16,16,ILC_COLOR32,0,5);
if(m_hImageList==NULL)
{
MessageBox("Error 1");
return TRUE;
}
bRes=m_ImageList.Attach(m_hImageList);
if(bRes==FALSE)
{
MessageBox("Error 2");
return TRUE;
}
bRes=m_image.LoadBitmap(IDB_BITMAP1);
if(bRes==FALSE)
{
MessageBox("Error 3");
return TRUE;
}
m_ImageList.Add(&m_image,RGB(0,0,0)); LONG lStyle=::GetWindowLong(m_ctrlList.m_hWnd,GWL_STYLE);
::SetWindowLong(m_ctrlList.m_hWnd,GWL_STYLE,LVS_REPORT | lStyle);
m_ctrlList.SetImageList(&m_ImageList,LVSIL_NORMAL);
m_ctrlList.InsertItem(0,"A");
m_ctrlList.InsertItem(0,"B");
m_ctrlList.InsertItem(0,"C");
m_ctrlList.InsertItem(0,"D");
m_ctrlList.InsertItem(0,"E");
UpdateData(FALSE);
CString str;
str.Format("The item count: %d",m_ctrlList.GetItemCount());
MessageBox(str);以上是所有的代碼,最後MessageBox顯示出來,確實有5個Item在裡面了,
但是ListCtrl裡面就是沒圖標,或者是小框框.
其中IDB_BITMAP是16色的Bitmap,我把它修改成24bits的bitmap也不行.
m_hImageList=ImageList_Create(16,16,ILC_COLOR32,0,5);
if(m_hImageList==NULL)
{
MessageBox("Error 1");
return TRUE;
}
bRes=m_ImageList.Attach(m_hImageList);
if(bRes==FALSE)
{
MessageBox("Error 2");
return TRUE;
}
bRes=m_image.LoadBitmap(IDB_BITMAP1);
if(bRes==FALSE)
{
MessageBox("Error 3");
return TRUE;
}
m_ImageList.Add(&m_image,RGB(0,0,0)); LONG lStyle=::GetWindowLong(m_ctrlList.m_hWnd,GWL_STYLE);
::SetWindowLong(m_ctrlList.m_hWnd,GWL_STYLE,LVS_REPORT | lStyle);
m_ctrlList.SetImageList(&m_ImageList,LVSIL_NORMAL);
m_ctrlList.InsertItem(0,"A");
m_ctrlList.InsertItem(0,"B");
m_ctrlList.InsertItem(0,"C");
m_ctrlList.InsertItem(0,"D");
m_ctrlList.InsertItem(0,"E");
UpdateData(FALSE);
CString str;
str.Format("The item count: %d",m_ctrlList.GetItemCount());
MessageBox(str);以上是所有的代碼,最後MessageBox顯示出來,確實有5個Item在裡面了,
但是ListCtrl裡面就是沒圖標,或者是小框框.
其中IDB_BITMAP是16色的Bitmap,我把它修改成24bits的bitmap也不行.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货