PDA

Click to See Complete Forum and Search --> : Imagelist for Listview


morphman2000
Jun 8th, 2001, 12:24 PM
I am creating a Listview and I want to assign an Image list to my ListView so I can use images in my Items. Next is a peace of my code:


lngImageList = ImageList_Create(32, 32, ILC_MASK, 1, 1)

ImageList_Add lngImageList, LoadResPicture(102, 1).Handle, 0

lngStyle = WS_CHILD Or WS_VISIBLE Or LVS_REPORT
m_hWndLV = CreateWindowEx(WS_EX_CLIENTEDGE, "SysListView32", vbNullString, _
lngStyle, 10, 10, 300, 200, Me.hwnd, 0, App.hInstance, ByVal 0&)

lngtest = SendMessage(m_hWndLV, LVM_SETIMAGELIST, LVSIL_SMALL, lngImageList)


Problem is that 'lngtest' returns a 0-handle (value 0). So when I am adding Items with Images, the Images won't appear, because of this bug.

Does someone has any idea what I did wrong in assigning the imagelist to my listview?

Tnx.

grantfrench
Jun 23rd, 2001, 05:47 PM
Why dont you just use the Imagelist Control from the microsoft common controls then assign the imagelist using the Icons property in the listview control?

Create a imagelist called imglst1
Create a listview called lstview1

example code:
lstview1.icons = imglst1


Now isnt that a hell of a lot simpler?

I knew why you where doing it using api as soon as i looked at your signature, VC gave it away.


Grant French
grant@webxd.co.uk

morphman2000
Jun 24th, 2001, 04:31 PM
Well, it is a lot simpeler, but just for fun and education I wanted to create my own listview + my own imagelist in API. Also because I wanted to add some functions which can't be done with the common dialog control but only can be done by API.

That's why... k?!

but since the time you were posting the previous message, my own listviewcontrol were already done.... :cool: !