Jump to content
Sign in to follow this  
t1ck3ts

GUICtrlSetImage with an Array, inside a Do Loop

Recommended Posts

Im trying to use GUICtrlSetImage inside a Do loop, problem is im not sure if i can use GUICtrlSetImage with an array inside the Do loop.

Not sure if I'm doing this correctly.

Local $Sites[3][3] = [["Google"     , "google.com"  , "$Google"], _
                      ["Localhost"  , "127.0.0.1"   , "$localhost"], _
                      ["Google2"    , "google.com"  , "$Google2"]]

$GUI = GUICreate("GUI", 405, 294, 539, 252)
GUICtrlCreateLabel("Google", 16, 16, 61, 17)
$Google = GUICtrlCreateIcon("", -1, 150,16,16,16)
GUICtrlCreateLabel("Localhost", 16, 16, 61, 17)
$Localhost = GUICtrlCreateIcon("", -1, 150,16,16,16)
GUICtrlCreateLabel("Google2", 16, 16, 61, 17)
$Google2 = GUICtrlCreateIcon("", -1, 150,16,16,16)

GUISetState(@SW_SHOW)

Local $i = 0

Do
    $Ping = Ping($Sites[$i][1])

    If $Ping = 0 Then
        GUICtrlSetImage($Sites[$i][2], "bullet_red.ico", -1)
    EndIf
    If $Ping > 500 Then
        GUICtrlSetImage($Sites[$i][2], "bullet_orange.ico", -1)
    Else
        GUICtrlSetImage($Sites[$i][2], "bullet_green.ico", -1)
    EndIf

    $i = $i + 1
Until $i = UBound($Sites)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

The first parameter should contain the value of the handle returned by GUICtrlCreateIcon()

So guess this should work:

GUICtrlSetImage(Eval($Sites[$i][0]), "bullet_red.ico", -1)

Jos

Edited by Jos

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...