List Control 插入图片后,选中状态,图片消失了。
取消焦点后又正常显示图片,只是在选择图片在焦点状态下,不正常显示图片,变成空白。
我只是插几张图片,百思不解!~我郁闷了!

解决方案 »

  1.   

    你的CListCtrl是自绘的?
    把你插入部分的代码贴出来看看
      

  2.   

    m_TotCount=m_List.GetItemCount(); 
    //m_List.SetImageList(&m_ImageListThumb,LVSIL_NORMAL);
    // 向图像列表中添加图片
    CBitmap* pImage = NULL; 
    pImage = new CBitmap();   
    pImage->Attach(bitm);

    int imgP=m_ImageListThumb.Add(pImage,RGB(0,0,0));
    delete pImage; CRect bigRect;
    // Link to the added listview item 
    m_List.SetImageList(&m_ImageListThumb,LVSIL_NORMAL);
    m_List.InsertItem(m_TotCount,strFileName,imgP); BOOL b=m_List.SetItemText(m_TotCount,1,dirPath);
      

  3.   

    图片的ID不对应该是:LoadIcon(ID),其中的ID要保证有对应资源
      

  4.   

    直接贴代码:int CMnuView::Init_List(void)
    {
        plist = &GetListCtrl();
    /* LONG lStyle;
    lStyle = GetWindowLong(plist->m_hWnd, GWL_STYLE);   //获取当前窗口风格// lStyle &= ~LVS_TYPEMASK;                           //清除显示方式位 lStyle &= ~LVS_REPORT;                             //设置报表风格
            lStyle |= LVS_SMALLICON;
            SetWindowLong(plist->m_hWnd,GWL_STYLE,lStyle); */
    m_ImageList.Create(32, 32, ILC_COLOR16|ILC_MASK,8, 0); HICON hIcon;
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON1));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON2));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON3));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON4));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON5));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON6));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON7));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON8));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON9));
    m_ImageList.Add(hIcon);
    hIcon = ::LoadIcon (AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON10));
    m_ImageList.Add(hIcon);

    CRect rc;
    plist->GetClientRect(rc);
    int cy;
    cy =  rc.Height()/13;
    plist->SetIconSpacing(rc.Width(),60);   //设置新的图标的位置 plist->SetTextColor(RGB(0,85,229));
    plist->SetTextBkColor(RGB(223,223,223));
    plist->SetBkColor(RGB(223,223,223)); plist->InsertColumn(0, _T("Choices"),LVCFMT_LEFT,30,-1);  //插入卷标     plist->InsertItem(0, _T("原始"), 0);
    plist->InsertItem(1, _T("统计"), 1);
    plist->InsertItem(2, _T("覆盖"), 2);
      plist->InsertItem(3, _T("区域"), 3); 
    plist->InsertItem(4, _T("空值"), 4);
    plist->InsertItem(5, _T("常规"), 5);
    plist->InsertItem(6, _T("域分"), 6);
      plist->InsertItem(7, _T("统计"), 7);
    plist->InsertItem(8, _T("联"), 8);
    plist->InsertItem(9, _T("退出"), 9);

            plist->SetImageList(&m_ImageList, LVSIL_NORMAL);
        return 0;
    }
      

  5.   


    ImageList_Create创建一个新的图象列表HIMAGELIST ImageList_Create(int cx,int cy,UINT flags, int cInitial,int cGrow); 参数:cx:装载的图象的宽尺寸。cy:装载的图象的高尺寸。flags:确定创建的图象列表类型。此参数可能为以下值的组合,但只能有一个ILC_COLOR值。ILC_COLOR  Use the default behavior if none of the other ILC_COLOR* flags is specified. Typically, the default is ILC_COLOR4, but for older display drivers, the default is ILC_COLORDDB. 
    ILC_COLOR4  Use a 4-bit (16-color) device-independent bitmap (DIB) section as the bitmap for the image list.  
    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. 
    ILC_COLORDDB  使用设备独立位图。 
    ILC_MASK  使用掩码。图象列表包含两个位图,其中一个是用做掩码的位图。如果不包括此值,图象列表只包含一个位图。 
    ILC_MIRROR Version 6.00. Microsoft Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left. If the image list is created on a mirrored version of Windows, then the images in the lists are mirrored, that is, they are flipped so they display from right to left. Use this flag on a mirrored version of Windows to instruct the image list not to automatically mirror images.  
    ILC_PERITEMMIRROR Version 6.00. Specify this flag if ILC_MIRROR is used on an image list that contains a strip of images. In order for this flag to have any effect, ILC_MIRROR must also be specified.  
    cInitial:图象列表最初包含的图象数。cGrow:当系统需要改变列表为新图象准备空间时,图象列表可生成的图象数。此参数替代改变的图象列表所能包含的新图象数。返回值
    Returns the handle to the image list if successful, or NULL otherwise。要求:Windows NT/2000: Requires Windows NT 3.51 or later 
    Windows 95/98/Me: Requires Windows 95 or later 
    头文件: Declared in commctrl.h. 
    库文件: comctl32.lib.====================================================
    ILC_MASK  使用掩码。图象列表包含两个位图,其中一个是用做掩码的位图。如果不包括此值,图象列表只包含一个位图。 
    NO~为了这个该死的掩码位图参数,天阿!就是千不该万不该把他给忽略了!!!!
    终于找到原因~真是阿弥陀佛~没你大~! 汗!