Skip to content

Instantly share code, notes, and snippets.

Created April 24, 2014 05:31
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
ListView: Icons in more than first column example #ahk #function
; Set Icon for row "subItem" within Listview
; Author: Tseug (
LV_SetSI(hList, iItem, iSubItem, iImage){
VarSetCapacity(LVITEM, 60, 0)
LVM_SETITEM := 0x1006 , mask := 2 ; LVIF_IMAGE := 0x2
iItem-- , iSubItem-- , iImage-- ; Note first column (iSubItem) is #ZERO, hence adjustment
NumPut(mask, LVITEM, 0, "UInt")
NumPut(iItem, LVITEM, 4, "Int")
NumPut(iSubItem, LVITEM, 8, "Int")
NumPut(iImage, LVITEM, 28, "Int")
result := DllCall("SendMessageA", UInt, hList, UInt, LVM_SETITEM, UInt, 0, UInt, &LVITEM)
return result
; Set Icon for row "subItem" within Listview
; Author: Tseug (
; example for adding icons to listview columns > the first
; after Drugwash:
#Include LV_SetSI.ahk
Gui, add, ListView, w600 h400 +LV0x2 HwndHLV, Name|Size|Ext
ImageListID := IL_Create(10)
Loop 10
IL_Add(ImageListID, "shell32.dll", A_Index)
Loop, %A_WinDir%\*.* ; fill Listview
{ if a_Index > 100
i := Mod(a_index,10)+1 ; since I only added 10 icons
LV_Add("icon" i, A_LoopFileName, A_LoopFileSize, A_LoopFileExt)
LV_SetSI(hLV, A_Index, 3, i) ; now add icons (i) to the rows of the third column
; can also call function later for individual cells
Gui, Show, , Icons in more than 1 Listview column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment