I'm trying to have the last column of a ListIcon automatically resized.
(In my case, it would be only when adding items to the list, or modifying the witdh of the first column).
The final goal is to avoid the horizontal scrolling bar that appear only to allow the vertical bar to be displayed...
It would be the equivalent of PureLVSORT_SetLastColumnAutoResize() in one of the excellent Gnozal's libs (PureLVSORT).
But I don't want to be dependent of this lib, because I don't need sorting features, and I'm using Set/GetGadgetItemData().
We can see in the code below what's wrong with scrolling bars:
Code: Select all
Enumeration
#Window
EndEnumeration
Enumeration
#ListIcon
#Button
EndEnumeration
If OpenWindow(#Window, 450, 200, 400, 185, "test", #PB_Window_SystemMenu|#PB_Window_TitleBar)
ListIconGadget(#ListIcon, 15, 20, 200, 150, "1", 160, #PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines|#PB_ListIcon_FullRowSelect)
AddGadgetColumn(#ListIcon, 1, "2", 100)
SendMessage_(GadgetID(#ListIcon), #LVM_SETCOLUMNWIDTH, 1, #LVSCW_AUTOSIZE_USEHEADER)
ButtonGadget(#Button, 240, 20, 140, 30, "Add items", #PB_Button_Toggle)
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
Select EventGadget()
Case #Button
ClearGadgetItems(#ListIcon)
If GetGadgetState(#Button)
For i = 0 To 20
AddGadgetItem(#ListIcon, -1, Str(i))
Next
EndIf
; SendMessage_(GadgetID(#ListIcon), #LVM_SETCOLUMNWIDTH, 1, #LVSCW_AUTOSIZE_USEHEADER) ; <---- I'd like to have this line in a callback proc.
EndSelect
Case #PB_Event_CloseWindow
CloseWindow(#Window)
Break
EndSelect
ForEver
EndIf
For now, I believe I have to use the command:
SendMessage_(GadgetID(#ListIcon), #LVM_SETCOLUMNWIDTH, 1, #LVSCW_AUTOSIZE_USEHEADER)
but it should probably be in a callback procedure associated with the ListIcon to work automatically, shouln't it?
Unfortunately, I'm getting a bit lost when it comes to callback...
A little help would be very appreciated.
