qq_28254507
ProgJ
2016-02-20 15:13

MFC CListView 加载小图标的问题

5
  • c++
  • mfc
m_editFont.CreatePointFont(160, "宋体");
    SetFont(&m_editFont);

    CImageList m_Imagelist;
    CBitmap bitmap;
    m_Imagelist.Create(32, 32, ILC_COLOR24, 2, 1);
    bitmap.LoadBitmap(IDB_BITMAP11);

    CRect rect;
    GetClientRect(&rect);

    ptheList = &GetListCtrl();
    ptheList->ModifyStyle(0, LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SORTASCENDING);
    ptheList->SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);

    ptheList->SetImageList(&m_Imagelist, LVSIL_SMALL);

    ptheList->InsertColumn(0, "默认笔记", LVCFMT_LEFT, rect.Width(), 0);

    int pos;
    pos = ptheList->InsertItem(1, "123", 0);
    pos = ptheList->InsertItem(2, "321", 0);
}

这样运行出来的图标是空白的。。调试发现 m_Imagelist 和 bitmap 都没有成功把位图加载进去。。为什么。。是哪里错了?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答

为你推荐