Jump to content

_GUICtrlListView_AddArray won't work with imagelist bitmap

Recommended Posts

Hi everyone again!

I have a problem I just can't find the solution of :(

Context: I've made a program that goes into chrome and captures one table as an array and adds it to the gui, all good so far.

The problem comes when i'm trying to use the table items background color as a bitmap in the listview. (doens't need to be this way but it seemed the easiest way to me).

As I use the function '_GUICtrlListView_AddArray' to add the table to the gui, when I try to put the little colored squares it just put them all with the first color in the array BUT if I use '_GUICtrlListView_AddItem' function it works alternating the colors just fine. Idk if I'm doing something wrong or it just wont work this way.


Thanks in advance and sorry for my noobness :( 

;~ #include <array.au3> (already included in guilistview)
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
;~ #include <GuiListBox.au3>
;~ #include <WindowsConstants.au3>
#include <GuiImageList.au3>

Global $array_table[10][6] = _
[['asd00','asd10','asd20','asd30','asd40','asd50'] _
,['asd01','asd11','asd21','asd31','asd41','asd51'] _
,['asd02','asd12','asd22','asd32','asd42','asd52'] _
,['asd03','asd13','asd23','asd33','asd43','asd53'] _
,['asd04','asd14','asd24','asd34','asd44','asd54'] _
,['asd05','asd15','asd25','asd35','asd45','asd55'] _
,['asd06','asd16','asd26','asd36','asd46','asd56'] _
,['asd07','asd17','asd27','asd37','asd47','asd57'] _
,['asd08','asd18','asd28','asd38','asd48','asd58'] _

#Region Gui
Global $gui = GUICreate("color", 1320, 720, @DesktopWidth / 9, @DesktopHeight / 6, -1)
Global $boton_go = GUICtrlCreateButton("Go", 10, 510, 75, 25)
Global $idButton_Salir = GUICtrlCreateButton("Salir", 10, 600, 75, 25)

Global $idListview = GUICtrlCreateListView(" Hub  | Equipo  | Comentario Interfaz |     Alarma | Tiempo | Grafico", 10, 10, 1300, 490, -1, $LVS_EX_FULLROWSELECT)     ;$LVS_EX_GRIDLINES ,$LVS_SORTDESCENDING)  Hub  | Equipo  | Comentario Interfaz | Alarma | Tiempo | Grafico

#EndRegion Gui

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        Case $idButton_Salir
        Case $boton_go

Func GOOO()

$hImage = _GUIImageList_Create()

Local $array_colore[10] = ["0xFF9B9B", "0xFF9B9B", "0x74DC96","0xFF9B9B", "0x74DC96", "0x74DC96","0xFF9B9B", "0x74DC96", "0x74DC96","0xFF9B9B"]


    For $i = 0 To UBound($array_colore)-1
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap(GUICtrlGetHandle($idListview), $array_colore[$i], 16, 16))

_GUICtrlListView_SetImageList($idListview, $hImage, 1)

    _GUICtrlListView_AddArray($idListview, $array_table) ;--------####### doesn't work

    ; Add items                                         ;------##### does work
;~     _GUICtrlListView_AddItem($idListview, "Item 1", 0)
;~     _GUICtrlListView_AddItem($idListview, "Item 2", 1)
;~     _GUICtrlListView_AddItem($idListview, "Item 3", 2)
;~  _GUICtrlListView_AddItem($idListview, "Item 4", 3)
;~  _GUICtrlListView_AddItem($idListview, "Item 5", 4)

EndFunc   ;==>GOOO


gui color.png

Link to comment
Share on other sites

Link to comment
Share on other sites

17 hours ago, Nine said:

_GUICtrlListView_AddArray cannot set image list.  So you will need to use _GUICtrlListView_SetItemImage in a loop afterward to set for each item.

I've managed to make it work thanks to your help:

for $i = 0 to _GUICtrlListView_GetItemCount($idListview)
        _GUICtrlListView_SetItemImage($idListview, $i, $i)

just with that 3 lines of code... Don't know why it doesn't work in the other way.


Thanks 9


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...