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?
Bigger icon size in ListIcon (large icon mode)
Bigger icon size in ListIcon (large icon mode)
[Registered PB User since 2006]
[PureBasic 6.20][SpiderBasic 2.2]
[RP4 x64][Win 11 x64][Ubuntu x64]
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!
Have a look at #SM_CXICONSPACING and #SM_CYICONSPACING under GetSystemMetrics_().
I could be wrong though.
**EDIT : damn, blast and curse that Sparkie fella!

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.
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
***Edit to remove code****
I'll repost when I debug it properly

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

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
PB 5.21 LTS (x86) - Windows 8.1
Nice one sparks!
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.

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.