Jump to content

Recommended Posts

Posted (edited)

So here's the deal. I have an array of control ids:

for $i = 0 to $rows-1
    for $j = 0 to $cols-1
        $hImage[$i][$j] = GUICtrlCreatePic("00.bmp", $j*$size, $offset+($i*$size), $size, $size)
    next
next

Everything is working OK, but I want to catch the message when any of these images is clicked. For a single one is easy:

Case $hImage[0][0]
    GUICtrlSetImage($hImage[0][0], "01.bmp")

I'm new to AutoIt, so I'm wondering if there's an easier way to do the trick for all of them. :)

Edited by steliyan
Posted (edited)

Maybe (not tested)

Switch $Msg
Case $hImage[0][0] to $hImage[ $rows][$cols]
     $id = 0
     for $i = 0 to $rows-1
    for $j = 0 to $cols-1
        $id += 1
        if $hImage[$i][$j] = $msg then 
                 ExitLoop 2
    next
     next
     GUICtrlSetImage($msg, StringFormat("%02d.bmp",$id))
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted

Or like this:

$MSG = GUIGetMsg()
For $INDEX1 = 0 to $ROWS-1
    For $INDEX2 = 0 to $COLS-1
        If $MSG = $hImage[$INDEX1][$INDEX2] Then
            MsgBox(0,"CLICK",$INDEX1 & @CRLF & $INDEX2)
        EndIf
    Next
Next

but Paulie method is more good.

Posted

I've done it using event. I catch the message of left button up event, then get the coordinates and calculate the image.

Another question about array, is there a way to set a value for all the elements of the array without going through them? Like in C++ (int array[5] = {0})?

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