Page 1 of 2

Removing ImageList from ListView

Posted: Wed Apr 01, 2009 9:29 pm
by Fluid Byte
I'm trying to completely remove an ImageList from ListView-Control. But whenever I reset the ImageList there will still be whitespace which was occupied by the icons before.

I tried everything but it doesn't even work with a native ListView created via API.

Code: Select all

OpenWindow(0,0,0,400,300,"Test",#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 5
    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
 			SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,0)
 						
			Case 2
			SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)			
		EndSelect
   EndSelect
ForEver
* ACTIVATES BATSIGNAL *

Posted: Wed Apr 01, 2009 10:04 pm
by Sparkie
Sounds like it's time for another Bat-hack. :P

I'm still at work but I'll take a look after I get home and put some bat seed in my belly :wink:

Posted: Wed Apr 01, 2009 10:11 pm
by Fangbeast
You guys are great entertainment (and I learn something int he process) ROFL!

Posted: Thu Apr 02, 2009 12:47 am
by Sparkie
Be careful what you say Fangles or we may have to charge you for the entertainment. :P

@Fluid Byte: So far all I can come up with is to create an ImageList with 1x16 blank images and use it as your #Null ImageList.

I'll keep looking.

Posted: Thu Apr 02, 2009 11:22 am
by srod
Will this do you my man?

Code: Select all

OpenWindow(0,0,0,400,300,"Test",#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 5 
  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 
          SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,0) 
          SetGadgetAttribute(0, #PB_ListIcon_DisplayMode, #PB_ListIcon_SmallIcon)
          SetGadgetAttribute(0, #PB_ListIcon_DisplayMode, #PB_ListIcon_Report)
                    
         Case 2 
         SendMessage_(GadgetID(0),#LVM_SETIMAGELIST,#LVSIL_SMALL,himlIcons)          
      EndSelect 
   EndSelect 
ForEver
A dirty hack to be sure! :)

It seems that putting the ListIcon temporarily into small icon mode is enough to 'reset' the 'SnapToGrid' option.

Strange that I could not get it to work by simply forcing the column justification to left etc. Not even with an api created ListView!

Posted: Thu Apr 02, 2009 12:43 pm
by Sparkie
Sorry srod but that doesn't work here on XP Home (themes and no themes).

Posted: Thu Apr 02, 2009 12:52 pm
by srod
Weird - works okay here on Vista; although only if XP themes are enabled!

I'll keep poking around.

Posted: Thu Apr 02, 2009 1:34 pm
by srod
Yea, it really doesn't want to work!!!

Reckon then Sparks that your using a dummy image_list is probably the way to go.

Posted: Thu Apr 02, 2009 1:40 pm
by Fluid Byte
Sparkie wrote:@Fluid Byte: So far all I can come up with is to create an ImageList with 1x16 blank images and use it as your #Null ImageList.
I tried that too but it's still not pixel-perfect. Plus there will be a useless ImageList floating around in memory.
It seems that putting the ListIcon temporarily into small icon mode is enough to 'reset' the 'SnapToGrid' option.
I've done that yesterday as well after finding this thread via Google:

http://social.msdn.microsoft.com/forums ... 51a5db7ac/

Like Sparkie mentioned, this doesn't seem to work with XP. :?

Maybe I should call someone else for help? :P
Image

Posted: Thu Apr 02, 2009 1:44 pm
by srod
:lol:

Yes I stumbled upon that same thread as well.

Posted: Thu Apr 02, 2009 1:53 pm
by Sparkie
I am NOT feeling the love here Fluid Byte :P

Superman...Shmooperman...show that dork a little Kryptonite and he goes to a corner and curls up in the fetal position. I eat Kryptonite for breakfast and shit diamonds for lunch 8)

Posted: Thu Apr 02, 2009 2:01 pm
by Fangbeast
Sparkie wrote:I am NOT feeling the love here Fluid Byte :P

Superman...Shmooperman...show that dork a little Kryptonite and he goes to a corner and curls up in the fetal position. I eat Kryptonite for breakfast and shit diamonds for lunch 8)
Sorry to butt into the thread FluidByte but after what Sparkie just said, I just crawled back off the floor after laughing my head off and hurting myself.

I'm using extensive imagelists in MultiBase and haven't got as far as you yet, although I noticed that white space last year when I was fiddling and wondered why it happened. Thanks for clearing up the mystery.

Posted: Thu Apr 02, 2009 2:07 pm
by srod
Sparkie wrote:...I eat Kryptonite for breakfast and shit diamonds for lunch 8)
Ahhh, I knew my second hobby of sifting through bat poo would eventually pay off! Now, where's my shovel?

Posted: Thu Apr 02, 2009 2:19 pm
by Sparkie
:lol: :lol:

Posted: Fri Apr 03, 2009 1:11 pm
by Fluid Byte
I think the easiest way at the moment would be to recreate the control itself, wouldn't it?