CImageList & Icons

hello,

I want to use a list control to display files. i would like to give an icon to these files . I tried with a CImageList but, i dont know why, the icons does not appear !!

there is the piece of code :

CFilemanagementApp *pApp;
pApp = (CFilemanagementApp *)AfxGetApp();

m_pImageList = new CImageList();
m_pImageList->Create(32, 32, TRUE, 2, 2);
m_pImageList->Add(pApp->LoadIcon(IDI_ICON1));
m_pImageList->Add(pApp->LoadIcon(IDI_ICON2));

m_list.SetImageList(m_pImageList, LVSIL_NORMAL);

m_list.InsertItem(1,"c:\toto",0); //insert an item with icon 0 in the image list !
// there is probably the pb !!!!!!!!!!!
[703 byte] By [arkam] at [2007-11-16 10:24:18]
# 1 Re: CImageList & Icons
Nobody can help me ?
arkam at 2007-11-10 5:11:06 >
# 2 Re: CImageList & Icons
Hi

It's pretty nice replying to your own post
so you can forward it, instead of reposting
another one :)

Well Your Error Is On Create

m_pImageList->Create(32, 32, TRUE, 2, 2);
TRUE == ILC_MASK == 0x0001

you need
m_pImageList->Create(32, 32, ILC_COLOR, 2, 2);

Hope This Helps
y_s_y_s at 2007-11-10 5:12:06 >
# 3 Re: CImageList & Icons
Hello,

Use a bitmaplist istead of Icons.

CListCtrl m_ListCtrl;
m_pImageList = new CImageList();
m_pImageList.Create( IDB_IMAGELIST, 16, 64, RGBLTGREEN ) ;
m_ListCtrl.SetImageList( &m_pImageList, TVSIL_NORMAL ) ;

Goodluck
theGeko
at 2007-11-10 5:13:01 >
# 4 Re: CImageList & Icons
nice try :=) but none did work ...

it still acts like the image list isn't stored in the list !!!

any other idea ?
arkam at 2007-11-10 5:14:07 >
# 5 Re: CImageList & Icons
Hi Again

Have you tried

m_list.InsertItem(0 ,"c:\toto", 0);
y_s_y_s at 2007-11-10 5:15:06 >
# 6 Re: CImageList & Icons
In fact the insertion works, the items appears in my list but not the icons !

in my prog i use a int and a for loop to include multiple items with the same icon !!
arkam at 2007-11-10 5:16:06 >
# 7 Re: CImageList & Icons
Hi

I haven't tried it myself
but is there any posibility the list cannot
handle your icons ?

I mean are your icons 32x32 only, or
do you have double resolution icons
32x32 and 16x16 as the ones the
wizard creates with the project ?

I think this has troubled some people
who wanted a diferent Icon in their Dialogs.
y_s_y_s at 2007-11-10 5:17:10 >
# 8 Re: CImageList & Icons
ok the error was not far from your answer, in fact my program was using a wrong Image list witch was badly constructed !! thanks !!
arkam at 2007-11-10 5:18:09 >