[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1309
  • Last Modified:

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?
0
hello2000
Asked:
hello2000
1 Solution
 
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
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
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

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now