List View item with icons..

Started by Exploration Gaming , December 13, 2010, 07:20:46 PM

Previous topic - Next topic

Exploration Gaming

Can someone provide a sample of using the ListView with icons? I noticed there isn't an Additem function only Insert. And I also wanted to know if the column commands are disable/ignored when in Icon mode.  There doesn't appear to be a "key" for the items added so how do you reference the items?

Any help would be appreciated..
Explorations RPG System
"RPG Makers come & Go, But Explorations is Forever!"
http://www.explore-rpg.com

Paul Squires

Hi Tye,

I think that you're asking for an example of showing icons in a Listview set to LVS_ICON style. I have attached a project that shows one way of creating it.

I add the icons to the FireFly Image Library and then load them into a Listview Imagelist that I attach to the Listview.

See the attached project.


'--------------------------------------------------------------------------------
Function FRMMAIN_WM_CREATE ( _
                           hWndForm As Dword, _      ' handle of Form
                           ByVal UserData As Long _  ' optional user defined Long value
                           ) As Long

   Local hImageList As Dword
   Local hIcon      As Dword
   Local nPosition1 As Long
   Local nPosition2 As Long
   Local nPosition3 As Long
   
   ' Create an ImageList and add icons to it
   hImageList = ImageList_Create(32, 32, %ILC_COLOR16, 3, 1)

   ImageList_SetBkColor hImageList, GetSysColor(%COLOR_WINDOW)
   
   ' The icons would have been already added to the Image Library
   hIcon = LoadIcon( App.hInstance, "IMAGE_33")
   nPosition1 = ImageList_AddIcon( hImageList, hIcon )
   DestroyIcon hIcon
   
   hIcon = LoadIcon( App.hInstance, "IMAGE_34")
   nPosition2 = ImageList_AddIcon( hImageList, hIcon )
   DestroyIcon hIcon

   hIcon = LoadIcon( App.hInstance, "IMAGE_35")
   nPosition3 = ImageList_AddIcon( hImageList, hIcon )
   DestroyIcon hIcon

   
   ' Attach the ImageList to the ListView
   FF_ListView_SetImageList HWND_FRMMAIN_LISTVIEW1, hImageList, %TVSIL_NORMAL
   
   ' Insert the items into the Listview Icon mode. 
   FF_ListView_InsertItem HWND_FRMMAIN_LISTVIEW1, 0, 0, "Icon 33", 0, nPosition1
   FF_ListView_InsertItem HWND_FRMMAIN_LISTVIEW1, 0, 0, "Icon 34", 0, nPosition2
   FF_ListView_InsertItem HWND_FRMMAIN_LISTVIEW1, 0, 0, "Icon 35", 0, nPosition3
   
End Function

Paul Squires
PlanetSquires Software