LIstctrl添加图像
CImageList m_ImageList;
m_ListCtrl.SetExtendedStyle(m_ListCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT |LVS_EX_SUBITEMIMAGES);
imglist.Create(32,16,ILC_COLOR,8,4);
int m_nIdxIco1 = m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO1)); //使用索引
int m_nIdxIco2 = m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO2));
int m_nIdxIco3 = m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO3));
int m_nIdxIco4 = m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO4));
m_ListCtrl.SetImageList(&imglist, LVSIL_SMALL);
m_ListCtrl.InsertColumn(0, "ColName1", LVCFMT_CENTER, 40);
m_ListCtrl.InsertColumn(1, "ColName2", LVCFMT_LEFT, 50);
m_ListCtrl.InsertItem(0, "", m_nIdxIco1);
m_ListCtrl.InsertItem(1, "", m_nIdxIco2);
m_ListCtrl.InsertItem(2, "", m_nIdxIco3);
m_ListCtrl.InsertItem(3, "", m_nIdxIco4);
或者
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO1)); //不使用索引
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO2));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO3));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_ICO4));
m_ListCtrl.SetImageList(&imglist, LVSIL_SMALL);
m_ListCtrl.InsertColumn(0, "ColName1", LVCFMT_CENTER, 40);
m_ListCtrl.InsertColumn(1, "ColName2", LVCFMT_LEFT, 50);
m_ListCtrl.InsertItem(0, "", 0);
m_ListCtrl.InsertItem(1, "", 1);
m_ListCtrl.InsertItem(2, "", 2);
m_ListCtrl.InsertItem(3, "", 3);
m_ListCtrl.SetItem( 0, 1, LVIF_TEXT, "111", 0, 0, 0, 0);
m_ListCtrl.SetItem( 1, 1, LVIF_IMAGE, "222", 1, 0, 0, 0);
m_ListCtrl.SetItem( 2, 1, LVIF_TEXT, "333", 2, 0, 0, 0);
m_ListCtrl.SetItem( 3, 1, LVIF_IMAGE, "444", 3, 0, 0, 0);