Ok, it's a feature of KiXforms (for the moment
)
You need to set the imagelist size before applying the imagelist to the listview object.
Thanks to Shawn for pointing me in the right direction over at the KiXforms forum.
Here's the working stuff, but you still need to code up the execution, work out how to get some of the icons and add the udfError() function which I accidentally stripped out when I tore this code from something else I had.
Code:
$=SetOption("ASCII","ON") $=SetOption("WrapAtEOL","ON") $=SetOption("Explicit","ON") Break ON
; Declare variables {{{
Global $SYSTEM,$FORMS
Global $TRUE,$FALSE
$TRUE=Not 0
$FALSE=Not $TRUE
Dim $sFolderToDisplay
$sFolderToDisplay=%USERPROFILE%+"\Desktop"
; }}}
; Initialise KiXforms system {{{
$SYSTEM=CreateObject("KiXtart.System")
If Not (9=VarType($SYSTEM)) $ERROR=@ERROR funError("Could not create KiXtart system - perhaps KiXforms is not registered?") Exit $ERROR EndIf
; Create a collection to index the forms. {{{
$FORMS=$SYSTEM.Collection()
; Make Form
udfMakeForm("frmMain")
If @ERROR Exit @ERROR EndIf
; }}}
; }}}
; Load the folder into the main form.
udfLoadProgramList($FORMS.Item("frmMain").controls("lvAppIcons"),$sFolderToDisplay)
$FORMS.Item("frmMain").Show
; Form event processing {{{
While $SYSTEM.ActiveForm.Visible
$=Execute($SYSTEM.ActiveForm.DoEvents())
Loop
; }}}
Exit 0
Function udfOnDoubleClick($sControl) ; {{{
Dim $oControl $oControl=$SYSTEM.ActiveForm.Controls($sControl)
Dim $oSelectedItem
;$oControl.View=1+$oControl.View
;If $oControl.View=4 $oControl.View=0 EndIf
Select
Case $oControl.Name="lvAppIcons"
Dim $sCommandToRun
$oSelectedItem=$oControl.FocusedItem
If VarType($oSelectedItem) AND $oSelectedItem.Selected
$sCommandToRun=$oSelectedItem.SubItems(1).Text
"Command to execute: "+$sCommandToRun+@CRLF
EndIf
Case "Unhandled"
"Unhandled double click on '"+$oControl.Name+"'"+@CRLF
EndSelect
EndFunction ; }}}
Function udfMakeForm($n) ; {{{
Dim $ERROR,$oControl,$f,$,$i,$oToolTip,$oSmallImageList,$oLargeImageList
Select
Case $n="frmMain"
$oToolTip=$SYSTEM.ToolTip()
$f=$SYSTEM.Form()
If Not (9=VarType($f)) $ERROR=@ERROR funError("Could not create new form - perhaps KiXforms is not registered?") Exit $ERROR EndIf
$f.Name=$n
$FORMS.Add($f,$f.Name)
$f.Caption="Custom Application Window"
$f.Width=690
$f.Height=335
$f.Center
$oControl=$f.Controls.Listview("lvAppIcons",0,0,688,300)
$oControl.Name="lvAppIcons"
$oControl.MultiSelect=$FALSE
$oControl.View=0 ; Large icons
$oControl.Sorted=$TRUE
$oSmallImageList=$SYSTEM.ImageList()
$oSmallImageList.ImageSize=$SYSTEM.Size(16,16)
$oControl.SmallImageList=$oSmallImageList
$oLargeImageList=$SYSTEM.ImageList()
$oLargeImageList.ImageSize=$SYSTEM.Size(32,32)
$oControl.LargeImageList=$oLargeImageList
$oControl.OnDoubleClick="udfOnDoubleClick('"+$oControl.Name+"')"
$oToolTip.SetToolTip($oControl,"Double click on an application to launch it")
$=$oControl.Columns.Add("Program",688,0)
$=$oControl.Columns.Add("File Path",0,0)
EndSelect
Exit 0
EndFunction ; }}}
Function udfLoadProgramList($oControl,$sFolder) ; {{{
Dim $oNewItem,$sFile,$sSuffix,$iIndex
$sFile=Dir($sFolder)
While Not @ERROR
$iIndex=InStrRev($sFile,".")
$sSuffix=SubStr($sFile,$iIndex+1)
If $sSuffix="exe" OR $sSuffix="lnk"
$oNewItem=$oControl.Items.Add
$oNewItem.SubItems(0).Text=Left($sFile,$iIndex-1)
$oNewItem.SubItems(1).Text=$sFolder+"\"+$sFile
$oNewItem.ImageIndex=udfLoadIcon($sSuffix,$oControl,$oNewItem,$sFolder+"\"+$sFile)
EndIf
$sFile=Dir("")
Loop
Exit 0
EndFunction ; }}}
Function udfLoadIcon($sSuffix,$oControl,$oItem,$sIconPath) ; {{{
Dim $oSmallIcon,$oLargeIcon,$oShell,$oShortCut
$udfLoadIcon=$FALSE
If $sSuffix="lnk"
$oShell=CreateObject("wscript.shell")
If 9=VarType($oShell)
$oShortCut=$oShell.CreateShortCut($sIconPath)
If $oShortCut.IconLocation<>",0"
;$sIconPath=Left($oShortCut.IconLocation,InStrRev($oShortCut.IconLocation,",")-1)
$sIconPath=$oShortCut.IconLocation
EndIf
EndIf
EndIf
$oSmallIcon=$SYSTEM.icon($sIconPath,16,16)
If VarType($oSmallIcon)=9
$udfLoadIcon=$oControl.SmallImageList.Images.Add($oSmallIcon)
$oLargeIcon=$SYSTEM.icon($sIconPath,32,32)
$udfLoadIcon=$oControl.LargeImageList.Images.Add($oLargeIcon)
EndIf
Exit 0
EndFunction ; }}}
; {{{ }}} vim: ai ts=4 sw=4 fdm=marker fdc=4 fml=0: