Assuming:
1) the 30 icon controls are already created (visible or hidden)
2) first Icon Control ID is 134
3) the 29 other Icon IDs are in order, thus 163 is the last ID
4) the list (filenames) has ID 100
5) that list contains filenames without extension ".jpg" or path
6) the path to the actual JPGs is static (<some core dir>\images\)
7) the ID for the button (show thumbs on sclick) is 85
; dialog event definition
on *:dialog:Autolist:*:*: {
; ... other dialog event code ...
; event is sclick
if ($devent == sclick) {
; ... other dialog sclick events ...
; selecting lines in the list
if ($did == 100) {
; check for max 30 items selected - just a suggestion
if ($did($dname,$did,0).sel > 30) {
; some action as the number of selected items exceeds 30
; e.g. unselecting the item just selected via: did -ku $dname $did $v1
; or by disabling the "show thumbs" button (re-enable via else { })
}
}
; sklick on "show thumbs" button
if ($did == 85) {
; loop, starting with the first selected line in the list and the first Icon ID
var %iconID = 134, %nr = 1
; as long as 1) the nr of selected lines in the list is <= 30 (superfluous if
; you prevent a selection of more than 30 lines in the list click definition)
; and 2) there is a selected line of that %nr:
while ((%nr <= 30) && ($did($dname,100,%nr).sel)) {
; set the full path for this file
var %file = $qt($+(<core dir>,\images\,$did($dname,100,$v1).text,.jpg))
; if the file is valid
if ($isfile(%file)) {
; use file N (%nr) as icon for icon control N (%iconID)
did -g $dname %iconID %file
; if the iconID is not visible, set it visible
if (!$did($dname,%iconID).visible) { did -v $dname %iconID }
; and inc the N for %iconID, as this ID is now occupied with an icon/thumb
inc %iconID
}
; proceed with next selected line
inc %nr
}
; hide alle the remaining icon IDs (there might be a list-selection of less
; than 30 files and/or an invalid file)
while (%iconID < 164) {
did -h $dname %iconID
inc %iconID
}
}
; ... other dialog sclick events ...
}
; ... other dialog event code ...
}
Please note that I didn't actually test this with a dialog/jpgs - hope it helps nevertheless
Edit: Apparently erroneously I presumed you wanted a list to pick/select the icons - a list that may hold more than 30 lines. I'm sorry about that.
The main suggestion (a while loop to set all
selected files to respective Icon IDs, show "occupied" IDs and hide the remaining Icon IDs) isn't affected by this.