Jump to content

set icon on listview


Recommended Posts

Hello all, I recently asked how to insert an image into a listbox but it seems this is perhaps not possible

 

So now I'm wondering how I insert an icon into the leftmost field of a listview.

 

My code I am using below doesn't work, it sets both columns to the username of the user(edit: I got the listview showing the text in the right-most column but I still need the leftmost column to show an icon), but I want the leftmost field to be an icon and the rightmost field to be the username.

 

Thanks in advance

Func _getcontacts()

        $oHTTP.Open("GET", "https://pdglobal.net?sid=contactslist&session=" & $session, False)
        $oHTTP.Send()
        $contacts = $oHTTP.ResponseText
    $clist = StringSplit(StringTrimLeft($contacts, 1), "|")
    $index = 0

    _GUICtrlListBox_ResetContent($List2)
    For $i = 1 To $clist[0]
        If $clist[$i] <> "" Then
            $conversations[0][0] += 1
            $conversations[$i][0] = $clist[$i]
            $conversations[$i][2] = _bang(FileRead(IniRead(@ScriptDir & "\settings.ini", "userkeys", $clist[$i], "NA")))
            $conversations[$i][3] = 0
            $conversations[$i][4] = _GUICtrlListView_AddItem($List2, "")
            GUICtrlSetImage($conversations[$i][4], "offline.ico")
            $index += 1
        EndIf
    Next
EndFunc   ;==>_getcontacts

func _getonlinestatus()
$index_old = _GUICtrlListView_GetHotItem($list2)

    for $i = 1 to $conversations[0][0]
        $oHTTP.Open("GET", "https://pdglobal.net?sid=getonlinestatus&USER="&$conversations[$i][0], False)
        $oHTTP.Send()
        $online = $oHTTP.ResponseText
        ConsoleWrite($conversations[$i][0]&"-"&$online&";")
        if $online = 1 Then
            _GUICtrlListView_BeginUpdate($list2)
            if $conversations[$i][3] > 0 Then
                $conversations[$i][5] = _GUICtrlListView_AddSubItem($list2, $conversations[$i][4], $conversations[$i][0]&" ("&$conversations[$i][3]&")", 1)
                GUICtrlSetImage($conversations[$i][4], "online.ico")
            Else
                $conversations[$i][5] = _GUICtrlListView_AddSubItem($list2, $conversations[$i][4], $conversations[$i][0], 1)
                GUICtrlSetImage($conversations[$i][4], "online.ico")
            EndIf
            _GUICtrlListView_EndUpdate($list2)
        Else
            _GUICtrlListView_BeginUpdate($list2)
            if $conversations[$i][3] > 0 Then
                $conversations[$i][5] = _GUICtrlListView_AddSubItem($list2, $conversations[$i][4], $conversations[$i][0]&" ("&$conversations[$i][3]&")", 1)
                GUICtrlSetImage($conversations[$i][4], "offline.ico")
            Else
                $conversations[$i][5] = _GUICtrlListView_AddSubItem($list2, $conversations[$i][4], $conversations[$i][0], 1)
                GUICtrlSetImage($conversations[$i][4], "offline.ico")
            EndIf
            _GUICtrlListView_EndUpdate($list2)
        EndIf

    Next
    if $index_old <> -1 Then
    ;_GUICtrlListBox_ClickItem($list2, $index_old)
    _GUICtrlListView_SetHotItem($list2, $index_old)
    EndIf
    ConsoleWrite(@CRLF)

EndFunc

 

Edited by AlecSadler
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...