Bigger icon size in ListIcon (large icon mode)

Just starting out? Need help? Post your questions and find answers here.
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Bigger icon size in ListIcon (large icon mode)

Post by JCV »

How to make the icons in ListIcon larger than the default size in large icon mode?
The icon size is very small in my screen and I want to make it larger than the default large size.

Anyone?

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Not sure you can (at least without using custom / owner draw) because Window's list view controls rely on system settings as provided by GetSystemMetrics_() when positioning icons in icon view etc,

Have a look at #SM_CXICONSPACING and #SM_CYICONSPACING under GetSystemMetrics_().

I could be wrong though.


**EDIT : damn, blast and curse that Sparkie fella!

:) Only kidding of course Sparks!
Last edited by srod on Sun Sep 23, 2007 2:25 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Not fully tested but seems to work ok on WinXPSP2 with PB4.10B3

***Edit to remove code****
I'll repost when I debug it properly ;)

***Edit to replace code*** There was no bug, it was me :P

Code: Select all

;...New icon size 
iconW = 100 
iconH = 100 

;...Create some images for this example 
zeroImg = CreateImage(0, iconW, iconH) 
StartDrawing(ImageOutput(0)) 
Box(0, 0, iconW, iconH, RGB(0, 0, 0)) 
StopDrawing() 

greenImg = CreateImage(1, iconW, iconH) 
StartDrawing(ImageOutput(1)) 
Box(0, 0, iconW, iconH, RGB(0, 255, 0)) 
StopDrawing() 

blueImg = CreateImage(2, iconW, iconH) 
StartDrawing(ImageOutput(2)) 
Box(0, 0, iconW, iconH, RGB(0, 0, 255)) 
StopDrawing() 

redImg = CreateImage(3, iconW, iconH) 
StartDrawing(ImageOutput(3)) 
Box(0, 0, iconW, iconH, RGB(255, 0, 0)) 
StopDrawing() 



;...Create our newly sized image list 
newIL = ImageList_Create_(iconW, iconH, #ILC_COLOR32, 0, 20) 

;...Add our images 
ImageList_Add_(newIL, ImageID(0), 0) 
ImageList_Add_(newIL, ImageID(1), 0) 
ImageList_Add_(newIL, ImageID(2), 0) 
ImageList_Add_(newIL, ImageID(3), 0) 

If OpenWindow(0, 0, 0, 700, 500, "",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  ListIconGadget(0, 10, 10, 680, 480, "", 200) 
  ChangeListIconGadgetDisplay(0, #PB_ListIcon_LargeIcon) 
  For i = 0 To 3 
    item$ = "Item " + Str(i) 
    AddGadgetItem(0 , i, item$, greenImg) 
  Next  i 
  FreeImage(1) 
  For i = 4 To 7 
    item$ = "Item " + Str(i) 
    AddGadgetItem(0 , i, item$, blueImg) 
  Next  i 
  FreeImage(2) 
  For i = 8 To 11 
     item$ = "Item " + Str(i) 
     AddGadgetItem(0 , i, item$, redImg) 
  Next  i 
  FreeImage(3) 
  FreeImage(0) 
  ;...Get handle to current ListIconGadget normal image list 
  oldIL = SendMessage_(GadgetID(0), #LVM_GETIMAGELIST, #LVSIL_NORMAL, 0) 
  ;...Replace the old image list with our new one 
  SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_NORMAL, newIL) 
  ;...Destroy the old image list 
  ImageList_Destroy_(oldIL) 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
End
Last edited by Sparkie on Sun Sep 23, 2007 2:16 pm, edited 1 time in total.
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Nice one sparks! :wink:

A slight ammendment to provide a mask allows Windows to blend the images when an item is selected. Just add the #ILC_MASK flag to the Image_List_Create function.

Code: Select all

;...New icon size 
iconW = 100
iconH = 100

;...Create some images for this example 
zeroImg = CreateImage(0, iconW, iconH) 
StartDrawing(ImageOutput(0)) 
Box(0, 0, iconW, iconH, RGB(0, 0, 0)) 
StopDrawing() 

greenImg = CreateImage(1, iconW, iconH) 
StartDrawing(ImageOutput(1)) 
Box(0, 0, iconW, iconH, RGB(0, 255, 0)) 
StopDrawing() 

blueImg = CreateImage(2, iconW, iconH) 
StartDrawing(ImageOutput(2)) 
Box(0, 0, iconW, iconH, RGB(0, 0, 255)) 
StopDrawing() 

redImg = CreateImage(3, iconW, iconH) 
StartDrawing(ImageOutput(3)) 
Box(0, 0, iconW, iconH, RGB(255, 0, 0)) 
StopDrawing() 



;...Create our newly sized image list 
newIL = ImageList_Create_(iconW, iconH, #ILC_COLOR32|#ILC_MASK, 0, 20) 

;...Add our images 
ImageList_Add_(newIL, ImageID(0), 0) 
ImageList_Add_(newIL, ImageID(1), 0) 
ImageList_Add_(newIL, ImageID(2), 0) 
ImageList_Add_(newIL, ImageID(3), 0) 

If OpenWindow(0, 0, 0, 700, 500, "",  #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0)) 
  ListIconGadget(0, 10, 10, 680, 480, "", 200) 
  ChangeListIconGadgetDisplay(0, #PB_ListIcon_LargeIcon) 
  For i = 0 To 3 
    item$ = "Item " + Str(i) 
    AddGadgetItem(0 , i, item$, greenImg) 
  Next  i 
  FreeImage(1) 
  For i = 4 To 7 
    item$ = "Item " + Str(i) 
    AddGadgetItem(0 , i, item$, blueImg) 
  Next  i 
  FreeImage(2) 
  For i = 8 To 11 
     item$ = "Item " + Str(i) 
     AddGadgetItem(0 , i, item$, redImg) 
  Next  i 
  FreeImage(3) 
  FreeImage(0) 
  ;...Get handle to current ListIconGadget normal image list 
  oldIL = SendMessage_(GadgetID(0), #LVM_GETIMAGELIST, #LVSIL_NORMAL, 0) 
  ;...Replace the old image list with our new one 
  SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_NORMAL, newIL) 
  ;...Destroy the old image list 
  ImageList_Destroy_(oldIL) 
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf 
End
Last edited by srod on Sun Sep 23, 2007 2:24 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Thanks for adding the mask flag srod. :)

There was no bug so we should be good to go 8)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I thought of trying simply replacing the image list as you've done, but having read what was in the WinAPI help guide, decided that it wouldn't work if we increased the image size!

Teach me to swear by that help guide! :wink:
I may look like a mule, but I'm not a complete ass.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Nothing ventured...nothing gained :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

Thanks guys! 8)

[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
Post Reply