我的程序中包含三个窗口,一个父窗口,一个TabControl子窗口还有一个ListView子窗口
我想在ListView中显示icon图标
具体操作为:
       hImageListS=ImageList_Create(50,50,FALSE,3,0);
hImageListL=ImageList_Create(65,65,FALSE,3,0);
ImageList_AddIcon(hImageListS,hicon[0]);
ImageList_AddIcon(hImageListL,hicon[0]);
ListView_SetImageList(hwndList,LVSIL_SMALL,hImageListS);
ListView_SetImageList(hwndList,LVSIL_NORMAL,hImageListL);
…………………………………………
…………………………………………
 for(iIndex=0;iIndex<5;iIndex++)
 {
 lvi.iItem=iIndex;
 lvi.iImage=iIndex;
 lvi.iSubItem=0;
 lvi.pszText=LPSTR_TEXTCALLBACK;
 ListView_InsertItem(hwndList,&lvi)
}
…………………………………………………………
要怎么改呀??? lvi.pszText=LPSTR_TEXTCALLBACK                            
 }

解决方案 »

  1.   

    hImageListL=ImageList_Create(65,65,FALSE,3,0);最后一个为0 好象不行吧,应该是比 0 大的整数.
    每三个参数也要指定一下,下面的是可选的,
    ILC_COLOR8
    Use an 8-bit DIB section. The colors used for the color table are the same colors as the halftone palette. 
    ILC_COLOR16
    Use a 16-bit (32/64k-color) DIB section.
    ILC_COLOR24
    Use a 24-bit DIB section.
    ILC_COLOR32
    Use a 32-bit DIB section.
    如:ImageList_Create( 16, 16, ILC_COLOR32|ILC_MASK, 3, 3);
      

  2.   

    lvi.iImage=iIndex?
    how large is your image list?
      

  3.   

    改成ImageList_Create( 16, 16, ILC_COLOR32|ILC_MASK, 3, 3);
    还是不能显示lvi.iImage is Index of the item's icon in the control's image list
      

  4.   

    你的LIST 的图片有多少?iIndex 会不会超出了这个范围??
      

  5.   

    即使超出了范围也应该显示有图标啊~~
    我的hicon[w]数组是通过GetClassLongPtr(hwnd,GCLP_HICON)的到的,是不是不可以直接用ImageList_AddIcon(hImageListS,hicon[0])?