Removing ImageList from ListView

Windows specific forum
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I agree - or keep two copies of the ListIcon, one with and one without the images. A bit of overkill though! :)
I may look like a mule, but I'm not a complete ass.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Nah, it's alright unless you got a really big amount of data. :)
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

OpenWindow(0,0,0,400,300,"Test 2",#PB_Window_SystemMenu | 1)
hwndLV = ListIconGadget(0,10,10,380,250,"Column 1",120,#PB_ListIcon_FullRowSelect)
AddGadgetColumn(0,1,"Column 2",120)
ButtonGadget(1,10,265,120,25,"Remove ImageList")
ButtonGadget(2,150,265,120,25,"Set ImageList")

LoadImage(0,#PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico")
himlIcons = ImageList_Create_(16,16,#ILC_COLOR32 | #ILC_MASK,0,0)
himIcons = ImageList_Create_(16,16,#ILC_COLOR32 | #ILC_MASK,0,0)
ImageList_AddIcon_(himlIcons,ImageID(0))
ImageList_AddIcon_(himIcons,ImageID(0))
SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)

For i=1 To 100
AddGadgetItem(0,-1,"Lorem Ipsum" + Chr(10) + Str(i))
Next

Repeat

Select WaitWindowEvent()
Case #PB_Event_CloseWindow : End
Case #PB_Event_Gadget
Select EventGadget()
Case 1
ImageList_SetIconSize_(himlIcons,0,16)
SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)

Case 2
SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himIcons)
EndSelect
EndSelect
ForEver
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

That actually works! :o

PS: RASHAD, code you please use code tags?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Very simple! :) Nice one. Works fine on Vista with or without themes.
I may look like a mule, but I'm not a complete ass.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Seems an effective implementation of Sparkie's first idea, good work.
BERESHEIT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

Code: Select all

OpenWindow(0,0,0,400,300,"Test 1",#PB_Window_SystemMenu | 1)
hwndLV = ListIconGadget(0,10,10,380,250,"Column 1",120,#PB_ListIcon_FullRowSelect)
AddGadgetColumn(0,1,"Column 2",120)
ButtonGadget(1,10,265,120,25,"Remove ImageList")
ButtonGadget(2,150,265,120,25,"Set ImageList")

LoadImage(0,#PB_Compiler_Home + "Examples\Sources\Data\CdPlayer.ico")
himlIcons = ImageList_Create_(16,16,#ILC_COLOR32 | #ILC_MASK,0,0)
ImageList_AddIcon_(himlIcons,ImageID(0))
SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)

For i=1 To 100
    AddGadgetItem(0,-1,"Lorem Ipsum" + Chr(10) + Str(i))
Next

Repeat

   Select WaitWindowEvent()
      Case #PB_Event_CloseWindow : End
      Case #PB_Event_Gadget
      Select EventGadget()
         Case 1         
          ImageList_SetIconSize_(himlIcons,1,16)
          SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)
                   
         Case 2
          ImageList_SetIconSize_(himlIcons,16,16)
          ImageList_AddIcon_(himlIcons,ImageID(0))
          SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)
      EndSelect
   EndSelect
ForEver
No second ImageList but 1 pixel at the left

RASHAD
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

RASHAD wrote:No second ImageList but 1 pixel at the left
You can set the width to NULL so it's pixel-perfect :wink:
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Post by RASHAD »

No it is not the same
It gives me grayed Icons

agreed?
RASHAD
Post Reply