SetImageList

CTreeCtrl::SetImageList编辑

CImageList* SetImageList( CImageList *  pImageList , int  nImageListType  );

返回值:

Pointer to the previous image list, if any; otherwise  NULL.
返回指向先前的图像列表的 指针(如果有);否则返回NULL

参数说明:

pImageList
Pointer to the image list to assign. If  pImageList is  NULL, all images are removed from the tree view control.
指向要被分配的图像列表的指针。如果pImageList是NULL,则从tree view控件中删除所有的图像。
nImageListType
Type of image list to set. The image list can be one of the following values:
要设置的图像列表的类型。图像列表可以是下列值之一:l TVSIL_NORMAL 获取常规的图像列表,它包含了该tree view项的被选择的和不被选择的图像。l TVSIL_STATE 获取状态图像列表,它包含了处于用户定义状态的treeview项的图像。
TVSIL_NORMAL Sets the normal image list, which contains the selected and nonselected images for the tree view item. TVSIL_STATE Sets the state image list, which contains the images for tree view items that are in a user-defined state.

备注:

Call this function to set the normal or state image list for a tree view control and redraw the control using the new images.
此成员函数用来设置一个tree view控件的常规或状态图像列表,并使用新的图
CTreeCtrl Overview | Class Members | Hierarchy Chart

相关参考资料:

CImageList, CTreeCtrl::GetImageList

参考事例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//图标句柄数组
HICONhIcon[3];
 
 
 
//加载三个图标,并将它们的句柄保存到数组
 
hIcon[0]=theApp.LoadIcon(IDI_WEB_ICON);
 
hIcon[1]=theApp.LoadIcon(IDI_CATALOG_ICON);
 
hIcon[2]=theApp.LoadIcon(IDI_ARTICLE_ICON);
 
 
 
//创建图像序列CImageList对象
 
m_imageList.Create(32,32,ILC_COLOR32,3,3);
 
 
 
//将三个图标添加到图像序列
 
for (inti=0;i<3;i++)
 
{
 
m_imageList.Add(hIcon[i]);
 
}
 
 
 
//为树形控件设置图像序列
 
m_webTree.SetImageList(&m_imageList,TVSIL_NORMAL);
 
 
 
////////以上为初始化部分///////////
 
 
 
//设置树形控件图标
 
m_webTree.SetItemImage(hParItem,1,1);
 
 
 
第一个参数为:项的句柄
 
第二个参数为:图标列表的索引(非选择状态)
 
第三个参数为:图标列表的索引(选择状态)
词条标签:
计算机学

你可能感兴趣的:(使用方法)