TreeView control doesn't show icons if IconType = 2 was specified

Report problems with documented functionality
teadrinker
Posts: 2064
Joined: 29 Mar 2015, 09:41
Contact:

TreeView control doesn't show icons if IconType = 2 was specified

12 Jan 2021, 18:21

Compare:

Code: Select all

ImageListID := IL_Create(10)  ; Create an ImageList with initial capacity for 10 icons.
Loop 10  ; Load the ImageList with some standard system icons.
    IL_Add(ImageListID, "shell32.dll", A_Index)
Gui, Add, TreeView
TV_Add("Name of Item", 0, "Icon4")  ; Add an item to the TreeView and give it a folder icon.
TV_SetImageList(ImageListID)
Gui Show
and

Code: Select all

ImageListID := IL_Create(10)  ; Create an ImageList with initial capacity for 10 icons.
Loop 10  ; Load the ImageList with some standard system icons.
    IL_Add(ImageListID, "shell32.dll", A_Index)
Gui, Add, TreeView
TV_Add("Name of Item", 0, "Icon4")  ; Add an item to the TreeView and give it a folder icon.
TV_SetImageList(ImageListID, 2)
Gui Show
User avatar
kczx3
Posts: 1223
Joined: 06 Oct 2015, 21:39

Re: TreeView control doesn't show icons if IconType = 2 was specified

12 Jan 2021, 21:10

Are you sure?
Otherwise, specify 2 for state icons (which are not yet directly supported, but could be used via SendMessage)
teadrinker
Posts: 2064
Joined: 29 Mar 2015, 09:41
Contact:

Re: TreeView control doesn't show icons if IconType = 2 was specified

12 Jan 2021, 21:25

Yes, I need this to recognise an item icon index in the image list by TVM_GETITEMSTATE.
teadrinker
Posts: 2064
Joined: 29 Mar 2015, 09:41
Contact:

Re: TreeView control doesn't show icons if IconType = 2 was specified

12 Jan 2021, 22:04

Got it, sorry :)

Code: Select all

ImageListID := IL_Create(10)  ; Create an ImageList with initial capacity for 10 icons.
Loop 10  ; Load the ImageList with some standard system icons.
    IL_Add(ImageListID, "shell32.dll", A_Index)
Gui, Add, TreeView, hwndhTreeView
hItem := TV_Add("Name of Item", 0)  ; Add an item to the TreeView and give it a folder icon.
TV_SetImageList(ImageListID, 2)

VarSetCapacity(TVITEM, A_PtrSize*4 + 4*6, 0)
NumPut(TVIF_STATE := 8, TVITEM)
NumPut(hItem, TVITEM, A_PtrSize)
NumPut(0x4000, TVITEM, A_PtrSize*2, "UInt")
NumPut(TVIS_STATEIMAGEMASK := 0xF000, TVITEM, A_PtrSize*2 + 4, "UInt")
SendMessage, TVM_SETITEM := 4415,, &TVITEM,, ahk_id %hTreeView%
Gui Show 

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests