Sign in to follow this  
Followers 0
SagePourpre

[...] assign var to buttons created in a array ?

3 posts in this topic

#1 ·  Posted (edited)

Hi. I'm trying to do a script that open a msgbox when I click on a button. But, buttons are created by an array.

CODE
#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 625, 445, 193, 125)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

Dim $button

For $i = 1 to 24

$button = GUICtrlCreateButton($i,0+$i*12,0,10,10)

GUICtrlSetData(-1,$i)

Next

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $button

for $i = 1 to 24

if $i = $button Then

MsgBox(0,"","")

EndIf

Next

EndSwitch

WEnd

I want each buttons to display something different but i've done something wrong and right now,

it don't react ... any idea ?

thanks, Sage Pourpre

Edited by SagePourpre

Share this post


Link to post
Share on other sites



Each button should have its own variable... right now you don't even have an array

Dim $button[25]
For $i = 1 to 24

$button[$i] = GUICtrlCreateButton($i,0+$i*12,0,10,10)
GUICtrlSetData(-1,$i)

Next

And you can set the parameters in the GUICtrlCreateButton to be whatever you want


Regards,Josh

Share this post


Link to post
Share on other sites

Got it....

Using

GUICtrlSetOnEvent($BUTTON, "smiley")

and

Func Smiley()

$a = ControlGetText($gui, "", @GUI_CtrlId)

...

End Func

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