图象列表与列表视图诀别什么意思
图象列表与列表视图分别什么意思?
SetImageList指定一个图象列表到列表视图控件。//CListCtrl类
------解决方案--------------------
在 MFC 中,图像列表类名为 CImageList。调用 CImageList 类的 Create 函数创建一个图像列表对象,然后用 Add 函数添加位图或者图标。位图或图标的索引是按照添加的顺序从 0 开始。CListCtrl::SetImageList 这其实就是将图像列表与列表视图控件关联起来。图像列表是包含多个 BMP 或者 ICON 的对象。当建立关联后,你插入项目时可指定图像索引,这样这个项目就会显示图像列表中指定索引的图像或图标。如:
pListView = new CListCtrl;
pImageList = new CImageList ;
pImageList->Create(32, 32, ILC_MASK|ILC_COLORDDB, 0, 0);
pImageList->Add(LoadIcon(NULL, MAKEINTRESOURCE(IDI_QUESTION)));
pImageList->Add(LoadIcon(NULL, MAKEINTRESOURCE(IDI_EXCLAMATION)));
pListView->SetImageList(pImageList, LVSIL_NORMAL);
pListView->InsertItem(0, TEXT("Question Icon"), 0);
pListView->InsertItem(1, TEXT("Exclamation Icon"), 1);
SetImageList指定一个图象列表到列表视图控件。//CListCtrl类
------解决方案--------------------
在 MFC 中,图像列表类名为 CImageList。调用 CImageList 类的 Create 函数创建一个图像列表对象,然后用 Add 函数添加位图或者图标。位图或图标的索引是按照添加的顺序从 0 开始。CListCtrl::SetImageList 这其实就是将图像列表与列表视图控件关联起来。图像列表是包含多个 BMP 或者 ICON 的对象。当建立关联后,你插入项目时可指定图像索引,这样这个项目就会显示图像列表中指定索引的图像或图标。如:
pListView = new CListCtrl;
pImageList = new CImageList ;
pImageList->Create(32, 32, ILC_MASK|ILC_COLORDDB, 0, 0);
pImageList->Add(LoadIcon(NULL, MAKEINTRESOURCE(IDI_QUESTION)));
pImageList->Add(LoadIcon(NULL, MAKEINTRESOURCE(IDI_EXCLAMATION)));
pListView->SetImageList(pImageList, LVSIL_NORMAL);
pListView->InsertItem(0, TEXT("Question Icon"), 0);
pListView->InsertItem(1, TEXT("Exclamation Icon"), 1);