I want my tree view control to show an item with a folder icon next to it.
so, i wrote this piece of code :
HBITMAP hFolderBitmap = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),_T("info.bmp"),IMAGE_BITMAP,20,20,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if(hFolderBitmap)
{
cil.Create(20,20,ILC_COLOR32,0,5);
bmp.FromHandle(hFolderBitmap);
cil.Add(&bmp,RGB(255,0,255));
}
GetTreeCtrl().SetImageList(&cil,TVSIL_NORMAL);
hrootFolder = GetTreeCtrl().InsertItem(_T("Subscriptions"),0,0,TVI_ROOT);
but, this does not add a folder icon next to my subscription label. it works correctly but doesn’t display any image.
instead of using :
bmp.FromHandle(hFolderBitmap);
I had to use :
bmp.Attach(hFolderBitmap);