複製鏈接
請複製以下鏈接發送給好友

SetImageList

鎖定
SetImageList是一個函數。
中文名
SetImageList
相關資料
CImageList, CTreeCtrl
備    註
設置一個tree view控件
性    質
函數

SetImageList函數聲明

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

SetImageList返回值

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

SetImageList參數説明

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.

SetImageList其他信息

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

SetImageList相關資料

CImageList, CTreeCtrl::GetImageList

SetImageList參考事例

//圖標句柄數組
HICON hIcon[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);



第一個參數為:項的句柄

第二個參數為:圖標列表的索引(非選擇狀態)

第三個參數為:圖標列表的索引(選擇狀態)