Does anyone know if it's possible to change the padding/distance between each row when using the gadget in List/Details mode?
I've had a good scour of the the API and Purearea, no dice :/
Any help, once again, much appreciated!
Is it possible to change row spacing in a ListIconGadget?
This works on WinXPhome SP2 with PB 3.93...
Code: Select all
#MyWindow = 0
#myListIcon = 0
Procedure myWindowCallback(hWnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_MEASUREITEM
If wParam = #myListIcon
*mis.MEASUREITEMSTRUCT = lParam
;--> We'll increase row height by 5 pixels
*mis\itemHeight + 5
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(#MyWindow, 0, 0, 320, 200, #PB_Window_SystemMenu | #PB_Window_ScreenCentered,"ListIconGadget Set Row Height") And CreateGadgetList(WindowID(0))
SetWindowCallback(@myWindowCallback())
ListIconGadget(#myListIcon, 10, 10, 299, 160, "", 139, #PB_ListIcon_AlwaysShowSelection | #PB_ListIcon_FullRowSelect | #PB_ListIcon_GridLines)
ChangeListIconGadgetDisplay(#myListIcon, 2)
;--> Temporarily set ListIconGadget to #LVS_OWNERDRAWFIXED so we get the #WM_MEASUREITEM message
SetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE, GetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE) | #LVS_OWNERDRAWFIXED)
For i = 0 To 29
AddGadgetItem(#myListIcon, -1, "Item " + Str(i))
Next i
;--> Init #WM_MEASUREITEM with a resize
ResizeGadget(#myListIcon, 10, 10, 300, 160)
;--> Remove #LVS_OWNERDRAWFIXED
SetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE, GetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE) &~#LVS_OWNERDRAWFIXED)
;--> Redraw items with our new row height
SendMessage_(GadgetID(#myListIcon), #LVM_REDRAWITEMS, 0, CountGadgetItems(0) -1 )
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
quit = #True
EndSelect
Until quit = #True
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
You're welcome P-J 
Once you receive the #WM_MEASUREITEM message, you set the row height by adding your pixel count to the MEASUREITEMSTRUCT (*mis\itemHeight) member
You can now remove the #LVS_OWNERDRAWFIXED flag from the ListIconGadget, and let Windows continue to do the drawing.

In order to change the row height, you need to receive the #WM_MEASUREITEM message. This is only sent when the ListIconGadget style has the #LVS_OWNERDRAWFIXED flag.P-J wrote:I'll make a point of scouring that code so I know exactly how it works, better to learn I reckon
Code: Select all
SetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE, GetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE) | #LVS_OWNERDRAWFIXED)
Code: Select all
*mis\itemHeight + 5
Code: Select all
SetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE, GetWindowLong_(GadgetID(#myListIcon), #GWL_STYLE) &~#LVS_OWNERDRAWFIXED)
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1