AHK_ImageListID Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
inseption86
Posts: 205
Joined: 19 Apr 2018, 00:24

AHK_ImageListID

Post by inseption86 » 19 Mar 2024, 01:53

Good afternoon How to set icons according to conditions, in the current code they are set to all lines

Code: Select all

Gui,Screen_form: Color, black 
Gui,Screen_form: Add, ListView,   vLV gLv , One|Two|Three
Gui,Screen_form: Show,, visitor

ImageListID := IL_Create(1)
IL_Add(ImageListID, "shell32.dll", 147) 
LV_SetImageList(ImageListID)
SetTimer, qq, 500
return

qq:
Gui, default
Gui, ListView, LV
list++

if (list > 5)
	LV_Modify(list, "Icon")

else
	LV_Modify(list, "-Icon" ) 

return





User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

Re: AHK_ImageListID

Post by mikeyww » 19 Mar 2024, 06:40

One needs to read the documentation here.

Code: Select all

LV_Modify(list, "Icon-1" )
Icon: Specify the word Icon followed immediately by the number of this row's icon, which is displayed in the left side of the first column. If this option is absent, the first icon in the ImageList is used. To display a blank icon, specify -1 or a number that is larger than the number of icons in the ImageList.
Source: ListView (GUI) - Syntax & Usage | AutoHotkey v1

inseption86
Posts: 205
Joined: 19 Apr 2018, 00:24

Re: AHK_ImageListID

Post by inseption86 » 23 Apr 2024, 08:37

How to add an icon only to a specific row?

Code: Select all


Gui, Add, ListView, r20 w700 gLV vLV, Name|Size (KB)

ImageListID := IL_Create(1)
IL_Add(ImageListID, "shell32.dll", 147) 

Loop, %A_MyDocuments%\*.*
    LV_Add("", A_LoopFileName, A_LoopFileSizeKB)
	
LV_ModifyCol() 
LV_ModifyCol(2, "Integer")  

Gui, Show
return


LV:
if (A_GuiEvent = "DoubleClick")
{
	LV_SetImageList(ImageListID)
	LV_Modify(LV_GetNext(), "Icon1")
}
return

User avatar
mikeyww
Posts: 26972
Joined: 09 Sep 2014, 18:38

Re: AHK_ImageListID  Topic is solved

Post by mikeyww » 23 Apr 2024, 09:37

Add an icon to a ListView row

Code: Select all

#Requires AutoHotkey v1.1.33.11
Gui Add, ListView,, One|Two|Three
ImageListID := IL_Create(1), IL_Add(ImageListID, "shell32.dll", 147), LV_SetImageList(ImageListID)
LV_Add(, 3), LV_Add(, 4), LV_Add(, 5)
icon()                                ; Remove icon from all rows
Gui Show,, Visitor
Return

F2::icon(ROW := 2, ICON := 1)         ; Add icon #1 to row #2
F3::icon(ROW := 2)                    ; Remove icon from row #2

icon(row := "ALL", icon := False) {   ; Add icon to, or remove icon from, a row
 iconStr := "Icon" (icon ? icon : -1)
 If (row != "ALL")
  LV_Modify(row, iconStr)
 Else Loop % LV_GetCount()
  LV_Modify(A_Index, iconStr)
}

inseption86
Posts: 205
Joined: 19 Apr 2018, 00:24

Re: AHK_ImageListID

Post by inseption86 » 23 Apr 2024, 10:08

Thanks

Post Reply

Return to “Ask for Help (v1)”