The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on January 23, 2011, 01:40:35 PM

Title: Listbox and ImageList
Post by: ragdog on January 23, 2011, 01:40:35 PM
It is possible to use a ImageList with a listbox

I use a ImageList for listview and treeview to draw a bmp
can i use this for a listbox?

Greets,
Title: Re: Listbox and ImageList
Post by: Tedd on January 23, 2011, 03:42:24 PM
I don't think so, without subclassing and drawing the images yourself. (It doesn't appear to support custom-draw either.)
Why not use a single column listview?
Title: Re: Listbox and ImageList
Post by: ragdog on January 23, 2011, 04:53:04 PM
QuoteWhy not use a single column listview?

Yes this ist the simply way but how i can hide this column header?
disable the column header can i with this

invoke SendMessage,hList,LVM_GETHEADER,0,0
invoke EnableWindow,eax,FALSE

I need a hide column header function then have i a listbox :bg
Title: Re: Listbox and ImageList
Post by: Gunner on January 23, 2011, 05:03:38 PM
Quote from: ragdog on January 23, 2011, 04:53:04 PM
Yes this ist the simply way but how i can hide this column header?
disable the column header can i with this

invoke SendMessage,hList,LVM_GETHEADER,0,0
invoke EnableWindow,eax,FALSE

I need a hide column header function then have i a listbox :bg

Why not just create the listview with the styles:
LVS_REPORT
LVS_NOCOLUMNHEADER
Title: Re: Listbox and ImageList
Post by: ragdog on January 23, 2011, 06:08:06 PM
Ok thanks i Try it
Title: Re: Listbox and ImageList
Post by: donkey on January 25, 2011, 12:00:59 AM
Hi Ragdog,

I didn't see this thread til now. You can use ownerdrawn listboxes for this. I have attached an example that uses an imagelist and displays the images in the listbox.

Edgar
Title: Re: Listbox and ImageList
Post by: ragdog on January 28, 2011, 07:05:03 PM
Thanks Edgar :U
Title: Re: Listbox and ImageList
Post by: ragdog on January 29, 2011, 06:54:18 PM
I have change it to a listview for use a imagelist

now have i a question by a listbox can i use LB_SETITEMDATA and LB_GETITEMDATA
for add True and false (if checked or not) gives this for a listview?
Title: Re: Listbox and ImageList
Post by: donkey on January 30, 2011, 02:42:46 AM
Quote from: ragdog on January 29, 2011, 06:54:18 PM
I have change it to a listview for use a imagelist

Why would you need to do that ? As I showed in my example using an image list with a listbox is a simply an ownerdraw issue.

Quotenow have i a question by a listbox can i use LB_SETITEMDATA and LB_GETITEMDATA
for add True and false (if checked or not) gives this for a listview?

No, those messages are for listboxes only, however you can use LVM_SETITEM and use the LVITEM.lParam or LVITEM.iImage members to track check marks. In my example the ITEMDATA is used to retain the image index.
Title: Re: Listbox and ImageList
Post by: ragdog on January 30, 2011, 03:27:21 AM
Your example if very good but i have thinking about my project and i need more as a one column ::)
Sorry I think your exmple can i use for a other project :U

Thanks for this LVM tip
Title: Re: Listbox and ImageList
Post by: donkey on January 31, 2011, 09:31:15 PM
Quote from: ragdog on January 30, 2011, 03:27:21 AM
Your example if very good but i have thinking about my project and i need more as a one column ::)
Sorry I think your exmple can i use for a other project :U

Thanks for this LVM tip

Ah, well then a listbox was never what you required, a listview handles multiple columns quite well. Though I have used listboxes for columns in the past it was for a custom control and the code is lost in my archives and not very useful in this case. Good luck with the project.