How would one, such as myself, add an image to items in a ListView control? Would it be the same as the tree view control? I'm having trouble getting icons and bitmaps to load. The system Icons work fine, ie IDI_APPLICATION, I just can't load custom. Thanks again.
Posted on 2001-03-20 10:55:00 by Schwartzteufel
I've never used a list view control, but it should be the same as for a tree view. Here's a code fragment:

    invoke ImageList_Create,16,16,ILC_COLOR16,2,10
    mov hImageList,eax
    ; add project image
    ; add group image
    invoke LoadBitmap,hInstance,IDB_GROUP
    mov hBitmap,eax
    invoke ImageList_Add,hImageList,hBitmap,NULL
    invoke DeleteObject,hBitmap
    invoke SendMessage,hwndTreeView,TVM_SETIMAGELIST,0,hImageList
The bitmap I used was a horizontal strip of 16x16 16 color bitmaps. While this bitmap actually has 14 images on it, I only told the create function there were 10 in the ImageList_Create function. It still worked, it must ignore extras. Anyway, you define the list, assign a bitmap to it, then use the TVM_SETIMAGELIST message to fix the list to the listview. This is for a fresh control, if you're appending images to an existing list, ignore this. This would replace the entire list, and someone else is gonna have to help you there. :-) -------------------------- "You couldn’t fool your mother on the foolingest day of your life if you had an electrified fooling machine."
Posted on 2001-03-20 11:19:00 by Ernie