Add icon to listview's column?

Hello, I want to add icon to listview's column like outlook.
I mean the sub-item's state can be shown as an icon. when user click a column, I show or hide the icon in the row. Can you help me?
hello2000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

afzalmjCommented:
Easy, use the ListView_??????? (e.g.ListView_DeleteAllItems or ListView_SetItemText, ListView_AddItem (I think - check under commctrl.h)) commands under commctrl.h.
They will be described under this header file, and you must include the library comctl32.lib for win32 apps when linking your prog.


0
hello2000Author Commented:
I want to use icon, not text.
0
afzalmjCommented:
Can't u then use ListView_SetImageList ?
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

WxWCommented:
1.LVM_SETIMAGELIST to make the ListView control to have icons .

2.LVM_INSERITEM with the LV_ITEM's iImage specifying the image index in the image list .

3.LVM_SETITEM to change any subitem's icons .
0
hello2000Author Commented:
It doesn't work. Please show some code. And I want to make it possible with original win95's comctl32.dll, not version 4.70 and later.
0
dspellmanCommented:
I tried to add icons to subitem columns using code from www.codeguru.com and other references, but I couldn't make it work with any combination of style flags.  If you haven't seen the samples at codeguru, you may have better luck than I did.
0
fwilkinsonCommented:
Use this extended listview style:

#define LVS_EX_SUBITEMIMAGES    0x00000002

Version 4.70. Allows images to be displayed for subitems. This style is available only in conjunction with the LVS_REPORT style.  

You should be able to use this macro to set the style:

ListView_SetExtendedListViewStyleEx()

If that macro is not in your version of the SDK, use:

#define LVM_FIRST               0x1000
#define LVM_SETEXTENDEDLISTVIEWSTYLE (LVM_FIRST + 54)
SendMessage( hwndListView, SETEXTENDEDLISTVIEWSTYLE, LVS_EX_SUBITEMIMAGES, LVS_EX_SUBITEMIMAGES);

You will probably have to use an image list and item state flags in order to define the icons to display.



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.