I needed a way to loop through a listicon gadget's columns but couldn't find a way to determine the number of columns a listview has. So, I modified some code from the CodeArchiv and came up with ....
Code: Select all
Procedure.w liColumnIsValid(Gadget, index)
; Returns TRUE if a ListIcon Column (index) exists.
lvc.LVCOLUMN
lvc\Mask = #LVCF_TEXT
txt.s = Space(255)
lvc\pszText = @txt
lvc\cchTextMax = 255
SendMessage_(GadgetID(Gadget),#LVM_GETCOLUMN,index,@lvc)
If Asc(Right(PeekS(lvc\pszText),1)) = 32 And Len(PeekS(lvc\pszText)) = 255 : ProcedureReturn #False : EndIf
ProcedureReturn #True
EndProcedure
Anyway, I needed it for this code:
Code: Select all
Procedure lvAutosizeControl(inGadget.l)
;Size Each column based On the maximum of EITHER the
; columnheader Text Width, Or, if the items below it
; are wider, the widest list Item in the column
iLoop.l=0
While liColumnIsValid(inGadget,iLoop) = #True
SendMessage_(GadgetID(inGadget),#LVM_SETCOLUMNWIDTH,iLoop,#LVSCW_AUTOSIZE_USEHEADER)
iLoop = iLoop + 1
Wend
EndProcedure
I'd love to see a proper way to do this. I just threw this together inbetween small breaks at work.