Sign in to follow this  
Followers 0
fxg4758

Creating buttons on fly

6 posts in this topic

Hi. I need to make 10 buttons on the fly using anygui and a array for each button that have this fields:

button1channel, button1program, button1time, button1text1, button1text2. These fields are in a ini file - media.ini -

Can anybody show me a example creating the buttons and sorting the buttons by the buttonXprogram or a link to see any code like this. Thanks for any information.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi. I need to make 10 buttons on the fly using anygui and a array for each button that have this fields:

button1channel, button1program, button1time, button1text1, button1text2. These fields are in a ini file - media.ini -

Can anybody show me a example creating the buttons and sorting the buttons by the buttonXprogram or a link to see any code like this. Thanks for any information.

Something kinda like this?

#include <GUIConstants.au3>

$Form1 = GUICreate("Form1", 172, 456)

Dim $Button[10]
$varStartHeight = 16
For $x = 0 to UBound ($Button)-1
    $Button = GUICtrlCreateButton("Button " & $x, 40, $varStartHeight, 75, 25)
    $varStartHeight += 30
Next

GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

*Edit - Guess I didn't see the anygui part before. Ah well, that's at least how you can make controls with an array.

Edited by exodius

Share this post


Link to post
Share on other sites

Hi. I need to make 10 buttons on the fly..

Personally I prefer a zip :)

I'm not sure from your question how much you can already do. If the information on the buttons is in the ini file do you know how to read that?

What is the buttonXprogram and how do you want the buttons sorted?


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

Personally I prefer a zip :)

I'm not sure from your question how much you can already do. If the information on the buttons is in the ini file do you know how to read that?

What is the buttonXprogram and how do you want the buttons sorted?

Hi Martin. I want to know how i can read the five fields for each button and put them in a array. And if is possible to sort the buttons by the "program" field. Thanks.

Share this post


Link to post
Share on other sites

Hi Martin. I want to know how i can read the five fields for each button and put them in a array. And if is possible to sort the buttons by the "program" field. Thanks.

It will be easier for us if you could post a sample ini file. Can you do that?


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

try this, this is not what you request as far as sorting & loading..

will wait for the ini file.

but give this a whurl.

#include <GUIConstants.au3>
#include<array.au3>

Opt("GUIOnEventMode", 1)

$Form1 = GUICreate("Form1", 172, 456)

Dim $Button[15]
$varStartHeight = 16
For $x = 1 To UBound($Button) - 1
    $Button[$x] = GUICtrlCreateButton("Button " & $x, 40, $varStartHeight, 75, 25)
    GUICtrlSetOnEvent(-1, "label_test")
    $varStartHeight += 30
Next

GUISetState(@SW_SHOW)

While 1
    Sleep(50)
WEnd


Func label_test()

    Local $iD = @GUI_CtrlId

    $sea = _ArraySearch($Button, $iD)

    If Not @error Then
        MsgBox(0, "", "This is button no " & $sea, 0)
    EndIf

EndFunc   ;==>label_test

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