示例代码:
HIMAGELIST himl; // handle to image list
HBITMAP hbmp; // handle to bitmap
// Create the image list.
if ((himl = ImageList_Create(16, 16,
ILC_COLOR32, 1, 0)) == NULL)
return ;
// Add the open file, closed file, and document bitmaps.
hbmp = LoadBitmap(hInst, MAKEINTRESOURCE(IDI_FOLDER));
if (-1 == ImageList_Add(himl, hbmp, (HBITMAP)NULL))
return;
DeleteObject(hbmp);
if (ImageList_GetImageCount(himl) < 1)
return;
// Associate the image list with the tree-view control.
TreeView_SetImageList(hTree, himl, TVSIL_NORMAL);
//init normal books
tvs.hInsertAfter = NULL;
tvs.hParent = TVI_ROOT;
tvs.item.pszText = L"Notebook";
tvs.item.mask = TVIF_TEXT;
HTREEITEM rootItem = TreeView_InsertItem(hTree, &tvs);
问题是:我没有设置TVIF_IMAGE
或TVIF_SELECTEDIMAGE
掩码,但结果树视图仍然包含如下图标:
我怎么能隐藏这个图标?
答案 0 :(得分:0)
它显示文件夹,因为您添加的文件夹图标位于图像列表中的位置0,当您创建TVINSERTSTRUCT以添加项目时,所有值都将重置为0.
如果您不希望它显示图标a)将图标移动到位置1或b)将图像索引设置为位图的大小+ 1;