Code: Select all
#Include <Class_LV_AltColoredRows> ; http://www.autohotkey.com/board/topic/76844-class-lv-altcoloredrows-ahk-l/
Gui, Add, ListView, h200 w180 +LV0x2 hwndHLV Grid, Col1|Col2
; Create ImageList
ImageListID := IL_Create(1)
LV_SetImageList(ImageListID)
IL_Add(ImageListID, "shell32.dll", 5)
; Add rows to the ListView
Loop 10
LV_Add("Icon9999", A_Index, A_Index)
; Set icon to column 2 of row 2
LV_SetSI( HLV, 2, 2, 1 )
Gui Show
LV_AltColoredRows.OnMessage()
LV_AltColoredRows.Attach(HLV)
Return
; http://www.autohotkey.com/board/topic/72072-listview-icons-in-more-than-first-column-example/
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("SendMessage", UInt, hList, UInt, LVM_SETITEM, UInt, 0, UInt, &LVITEM)
return result
}
GuiClose:
ExitApp
I even changed the icon background color, but still have 1 pixel white color between icon and text.