這邊使用的Icon為BitMap,建立的圖形長度為16bits。
因此在CImageList::Create()要輸入的cx值為16。
建立好CImageList後,再把把他透過CTreeList::SetItemImage()塞給所要使用的CTreeList即可。
程式碼如下:
header
....
CImageList m_cImageList;
....
CPP:
if ( !m_cImageList.Create(IDB_BMP_ICON, 16, 2, RGB(0, 0, 0)) ) {
CDSMsgShower::ShowMsgByErrorBox(this->m_hWnd, "ACCERT", MB_OK, "Fail to create image list."); };
this->m_treEnvItems.SetImageList(&m_cImageList, TVSIL_NORMAL);
....
this->m_treEnvItems.SetItemImage(hEnvItemsTree, 0, 1);
如圖形無法顯示,有可能是輸入的bitmap長度有錯。
Sorry for that I may not be able to read your comment. Would you mind to comment again in English? thanks
ReplyDelete