Jump to content

Setting Listviewitem background colour


lyledg
 Share

Recommended Posts

I have a listview of machine names, and am trying to change the colour of the listview item based on the outcome of the ping result as shown below:

The listbox is populated from another query with machine names.

Basically want the background colour of the listviewitem to change once the ping select statement has run on each listed item(Machine name) in the listview?

$COLLISTBOX = GUICtrlCreateList("", 305, 150, 210, 133)
$COLLECTIONEDIT = GUICtrlCreateEdit("", 8, 296, 521, 177, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL), BitOR($WS_EX_CLIENTEDGE, $WS_EX_STATICEDGE))

$Listcontents = _display_list_items($COLLISTBOX)

$Array = StringSplit($Listcontents, "|")

;Clear and Update the main edit box
GUICtrlSetData($COLLECTIONEDIT, "")

;Delete first element of Array      
_ArrayDelete($Array, 0)     
    
    For $Arraydata In $Array            

         $Pingrslt = Ping($Arraydata, 3000)
                        
        $Errmsg = @error

            Select
                
                Case $Errmsg = 0
                    
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " is online" & @CRLF, 1)       

                Case $Errmsg = 1
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " is offline" & @CRLF, 1)
                    
                Case $Errmsg = 2
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " is unreachable" & @CRLF, 1)

                Case $Errmsg = 3
                    GUICtrlSetData($COLLECTIONEDIT, $Arraydata & " has a bad destination address" & @CRLF, 1)
                Case $Errmsg = 4
                    GUICtrlSetData($COLLECTIONEDIT, "Ping request could not find host " & $Arraydata & ". Please check the name and try again." & @CRLF, 1)     

            EndSelect
       Next

Func _display_list_items($a_listctrl)
    For $i = 0 To _GUICtrlListCount($a_listctrl) - 1
        If $i = 0 Then
            $listctrl_content = _GUICtrlListGetText($a_listctrl, $i)
        Else
            $listctrl_content = $listctrl_content & '|' & _GUICtrlListGetText($a_listctrl, $i)
            
        EndIf
    Next
    Return $listctrl_content
    
EndFunc   ;==>_display_list_items

Any ideas?

Cheers

Link to comment
Share on other sites

^ bump

:whistle:

The only way you can do this is to handle the custom draw notification message from the list view and draw the items yourself. Arcker was working with this using Auto3Lib, so you might want to see how far he got.
Auto3Lib: A library of over 1200 functions for AutoIt
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...