Sign in to follow this  
Followers 0
steliyan

Array of control ids

5 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



Check out OnEvent Mode.

It would make this way easier

Share this post


Link to post
Share on other sites

#3 ·  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.

Share this post


Link to post
Share on other sites

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.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

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})?

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  
Followers 0