我不知道reinterpret_cast<HICON>是干吗的。不过可以肯定是m_imglist.Create 的参数或m_imglist.Add 有错误的地方
我是把图片放在一起象ToolBar那样的。
m_image.Create(IDB_TREEIMAGE, 16, 0, RGB(255, 255, 255));
没有问题。
我是把图片放在一起象ToolBar那样的。
m_image.Create(IDB_TREEIMAGE, 16, 0, RGB(255, 255, 255));
没有问题。
The list view control should be initialized in the OnInitDialog() function of the CDialog or in the OnInitialUpdate() function of the CFormView. A list view control can have up to three image lists associated with it: two of them for icons and the third for state images.
Here are the steps involved Declare variables of the type CImageList in your CDialog or CFormView sub class.
In the OnInitDialog() or OnInitialUpdate() function call the Create() function for the CImageList member variables.
Call the SetImageList() member function of the list view control.
Here is a sample code.
m_imgIcon.Create( IDB_LARGEICONS, 32, 1, (COLORREF)-1 ); //Create from bitmap resource
m_listctrl.SetImageList( &m_imgIcon, LVSIL_NORMAL ); //Set the image list
m_imgIconSmall.Create( IDB_SMALLICONS, 16, 1, (COLORREF)-1 );
m_listctrl.SetImageList( &m_imgIconSmall, LVSIL_SMALL );
The image list set using LVSIL_NORMAL is used only for the LVS_ICON mode. For this mode a 32x32 icon is usually used. For all other view modes the image list set with LVSIL_SMALL is used. The standard icon size for this is 16x16 pixels. You do not have to use the standard sizes though. For that matter, you do not have to use square images either, the images can have any aspect you want.
//////////////////////////////
Setting or removing an image for an item--------------------------------------------------------------------------------
The image for an item can be set when an item is first added to the list view control.
m_listctrl.InsertItem( LVIF_TEXT | LVIF_IMAGE, nRow, sItemText, 0, 0, nImage, NULL);
The image can later be changed by calling the SetItem() function. The CListCtrl class does not have a SetImage() function.
m_listctrl.SetItem( 0, 0, LVIF_IMAGE, NULL, nImage, 0, 0, 0 );
To remove the image, use a value of -1 for nImage, else nImage should be a zero based index of the image in the image list.
////////////////////////////////////////////
Setting a non-standard size image--------------------------------------------------------------------------------
Although icons always have to be a square, the images we use in the list view control does not. For instance, the following code will create images that are 62 pixels wide. The height of the image will be the same as the bitmap height in the resource.
m_img.Create( IDB_CUSTOMBITMAP, 62, 1, (COLORREF)-1 );
m_listctrl.SetImageList( &m_img, LVSIL_SMALL );
可不可以把你实验成功的例子发一个给我,我对照一下?
谢谢!