Jump to content

GUICtrlSetImage with an Array, inside a Do Loop


t1ck3ts
 Share

Go to solution Solved by Jos,

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
Link to comment
Share on other sites

  • Developers
  • Solution

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...