我不知道reinterpret_cast<HICON>是干吗的。不过可以肯定是m_imglist.Create 的参数或m_imglist.Add 有错误的地方
我是把图片放在一起象ToolBar那样的。
m_image.Create(IDB_TREEIMAGE, 16, 0, RGB(255, 255, 255));
没有问题。

解决方案 »

  1.   

    SetImageList ( &m_imglist, TVSIL_NORMAL);
      

  2.   

    变成TVSIL_NORMAL后,连左边的空白区域都没了,不知道为什么
      

  3.   

    我快疯了,我对照msdn的例子重新做了一遍,还是不行,估计是imglist的问题,大家有何看法?
      

  4.   

    我不清楚为什么好好的成员函数不用,偏好类SDK的东西。Initializing the image list--------------------------------------------------------------------------------
    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 );
      

  5.   

    (WS_CHILD&brvbar;WS_VISIBLE&brvbar;LVS_REPORT|LVS_SMALLICON)
      

  6.   

    我实验了一下可以呀,可能是样式的问题 WS_CHILD&brvbar;WS_VISIBLE&brvbar;LVS_REPORT|LVS_SMALLICON 试试,在不行就没有办法了。
      

  7.   

    AriDo(AriDo),我试验了还是不行,我已经快崩溃了。
    可不可以把你实验成功的例子发一个给我,我对照一下?
    谢谢!
      

  8.   

    已经解决了,感谢AriDo(AriDo)的大力帮助!
      

  9.   

    我的CImageList变量定义成了局部变量,在函数退出时就销毁了。