Jump to content

Arrays passing into GUICreate's


Recommended Posts

HI. Here is one that is stumping me.

$Glist has an array already in it. I can run this minus the ctrlsetonevent and it builds the buttons just like i want. I cannot figure out how to get the variable into the function spot on that OnEvent line though. I have tried lot's of different structuring of the variable, with and without quotes in most all spots. It checks ok in scite, but errors out once you come to it, saying it is an unknown function. As you can see the function is not complete. Stuck on this line.

Any ideas?

$bHT = 0
For $z = 1 to $Glist[0] - 1
    $bHT = $bHT + 50
    $btn = "btnG" & $z
    $dloadV = "_dload($Glist[" 
    $dloadVa = $z & "])"
    $dloadVal = '"' & $dloadV & $dloadVa & '"'
    $btn = GUICtrlCreateButton(StringTrimRight($Glist[$z], 1), 30, $bHT)
    GUICtrlSetOnEvent($btn, $dloadVal)
Next



Func _dload($DLname)
;   MsgBox(0, "", "G" & $z " is " & $DLname)
EndFunc;===> END DLOAD

Thnx,

sul

Link to comment
Share on other sites

arguments for functions used in events are not allowed.

if you set the variable to just the function name, and take the argument out of the function you get no errors.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I am unable to solve this.

I tried to understand what you were saying, so I just concentrated on properly naming each button so I could use that later in the function, but ....

The goal. Dump a list of app names into the array $Glist. Next, create a button for each value in the array. Next, define a function that starts to download the value of the array based on the variable assigned to the create button function, in other words make the $variable = SetOnEvent the same as the $variable = CreateButton. This way I can edit that text file and have the form change on the fly.

Here is the code I have now, which gets to the function, but I don't think it has a $variable = for the createbutton function.

$bHT = 0
Dim $btn[$Glist[0]], $btnG, $btn1
For $z = 1 to $Glist[0] - 1
    $bHT = $bHT + 50
;$btnG[$x] = "$btnG" & $x & " create button " & $Glist[$x]
;$btnG =  $z
;$btn = "$btnG" & $z
;$btnG = $btn[$z]
    $btn[$z] = "$btn" & $z = GUICtrlCreateButton(StringTrimRight($Glist[$z], 1), 30, $bHT)
    GUICtrlSetOnEvent(-1, "_dload")
Next


Func _dload()
    MsgBox(0, "you clicked", "something")
EndFunc;===> END DLOAD

Like I said, I can get each button to run the _dload function, but I cannot refer to what the button should be called, which in this case should be $btn1 - $btn4.

I am at a loss.

Any ideas here?

Thnx,

sul

Edited by sulfurious
Link to comment
Share on other sites

  • 4 months later...

I use a walk around like this...

Global $Last_clicked_control_var

For $a = to 4

Create the controls....

Next

While 1

$msg = GUIGetMsg(1)

select

case ...

case ...

Endselect

$Last_clicked_control_var = $msg[0] ; this global variable would automatically point to last pressed control

WEnd

This is a walkaround and it would be nice to be able to pass arrays or just a value to event functions included the hotkey opt but as this one could get the values available in event functions...

kjactive :P

Edited by kjactive
Link to comment
Share on other sites

Ah, ok thanks. I ended up doing something a little different as the variable I wanted to pass was just the button number that was pressed.

GUICtrlSetOnEvent($hButton[$i], "RunProg"); where $i is the button number

Func RunProg()
For $i = 1 to $iLastButton
    If @GUI_CtrlId = $hButton[$i] Then ExitLoop
Next

....

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