Jump to content
Sign in to follow this  
Scinner

GUI question?

Recommended Posts

Scinner

Hello!
 

Id like some help finishing this little GUI-problem.

What I want is to show one new func in the GUI everytime I press the "+button" and take away the last func everytime I press "-button".

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_2, $Button_3
    $create = GUICreate("Edit:", 200, 200)
    GUISetBkColor(0xEBD7AC)
    $Button_2 = GUICtrlCreateButton("+", 90, 150, 20)
    $Button_3 = GUICtrlCreateButton("-", 112, 150, 20)
    GUISetState(@SW_SHOW)


    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $Button_2
                Call("Send1") ;first time $Button_1 is pressed the "Call("Send1")" function will show up in Gui. Second time its pressed "Call("Send1")" and "Call("Send2") will show and third time the "Call("Send1")", "Call("Send2") and "Call("Send3") will show.
            Case $Button_3
                ;every time $Button_3 is pressed the last "Call("Send1-3")" will disappear.
        EndSwitch
    WEnd
EndFunc   ;==>Example

Func Send1()
    GUICtrlCreateLabel("1.", 10, 30)
    $x = GUICtrlCreateInput("000", 22, 27, 27, 20)
EndFunc

Func Send2()
GUICtrlCreateLabel("2.", 10, 55)
    $x2 = GUICtrlCreateInput("000", 22, 52, 27, 20)
EndFunc

Func Send3()
GUICtrlCreateLabel("3.", 10, 80)
    $x3 = GUICtrlCreateInput("000", 22, 77, 27, 20)
EndFunc

Share this post


Link to post
Share on other sites
JohnOne

Since you've been around for a while I'll just give you some hints/ideas to develop

Array of vars to hold control handles id's

Global variable to keep a count

From that you ought to get what I'm driving at.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Danyfirex

hi, Maybe something like this:

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_2, $Button_3
    $create = GUICreate("Edit:", 200, 200)
    GUISetBkColor(0xEBD7AC)
    $Button_2 = GUICtrlCreateButton("+", 90, 150, 20)
    $Button_3 = GUICtrlCreateButton("-", 112, 150, 20)

    ;labels and inputs
    local $labels[3]=[0,0,0]
    local $Inputs[3]=[0,0,0]
    $labels[0]=GUICtrlCreateLabel("1.", 10, 30)
    $Inputs[0] = GUICtrlCreateInput("000", 22, 27, 27, 20)
    $labels[1]=GUICtrlCreateLabel("2.", 10, 55,Default,Default)
    $Inputs[1]= GUICtrlCreateInput("000", 22, 52, 27, 20)
    $labels[2]=GUICtrlCreateLabel("3.", 10, 80)
    $Inputs[2] = GUICtrlCreateInput("000", 22, 77, 27, 20)


    GUICtrlSetState($labels[0],$GUI_HIDE)
    GUICtrlSetState($Inputs[0],$GUI_HIDE)

    GUICtrlSetState($labels[1],$GUI_HIDE)
    GUICtrlSetState($Inputs[1],$GUI_HIDE)

    GUICtrlSetState($labels[2],$GUI_HIDE)
    GUICtrlSetState($Inputs[2],$GUI_HIDE)



    GUISetState(@SW_SHOW)

    Local $num=0

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $Button_2
            if $num>=0 and $num<=2 then
             GUICtrlSetState($labels[$num],$GUI_SHOW)
             GUICtrlSetState($Inputs[$num],$GUI_SHOW)
             $num+=1
            endif
         Case $Button_3
             if $num>=0 then
              if not($num=0) then $num-=1
              GUICtrlSetState($labels[$num],$GUI_HIDE)
              GUICtrlSetState($Inputs[$num],$GUI_HIDE)
            endif

        EndSwitch
    WEnd
EndFunc   ;==>Example

saludos

Share this post


Link to post
Share on other sites
Scinner

Since you've been around for a while I'll just give you some hints/ideas to develop

Array of vars to hold control handles id's

Global variable to keep a count

From that you ought to get what I'm driving at.

Thx, Im a newb but have been registered quiet a while. Wouldn't have made it with your info though.

hi, Maybe something like this:

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $Button_2, $Button_3
    $create = GUICreate("Edit:", 200, 200)
    GUISetBkColor(0xEBD7AC)
    $Button_2 = GUICtrlCreateButton("+", 90, 150, 20)
    $Button_3 = GUICtrlCreateButton("-", 112, 150, 20)

    ;labels and inputs
    local $labels[3]=[0,0,0]
    local $Inputs[3]=[0,0,0]
    $labels[0]=GUICtrlCreateLabel("1.", 10, 30)
    $Inputs[0] = GUICtrlCreateInput("000", 22, 27, 27, 20)
    $labels[1]=GUICtrlCreateLabel("2.", 10, 55,Default,Default)
    $Inputs[1]= GUICtrlCreateInput("000", 22, 52, 27, 20)
    $labels[2]=GUICtrlCreateLabel("3.", 10, 80)
    $Inputs[2] = GUICtrlCreateInput("000", 22, 77, 27, 20)


    GUICtrlSetState($labels[0],$GUI_HIDE)
    GUICtrlSetState($Inputs[0],$GUI_HIDE)

    GUICtrlSetState($labels[1],$GUI_HIDE)
    GUICtrlSetState($Inputs[1],$GUI_HIDE)

    GUICtrlSetState($labels[2],$GUI_HIDE)
    GUICtrlSetState($Inputs[2],$GUI_HIDE)



    GUISetState(@SW_SHOW)

    Local $num=0

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $Button_2
            if $num>=0 and $num<=2 then
             GUICtrlSetState($labels[$num],$GUI_SHOW)
             GUICtrlSetState($Inputs[$num],$GUI_SHOW)
             $num+=1
            endif
         Case $Button_3
             if $num>=0 then
              if not($num=0) then $num-=1
              GUICtrlSetState($labels[$num],$GUI_HIDE)
              GUICtrlSetState($Inputs[$num],$GUI_HIDE)
            endif

        EndSwitch
    WEnd
EndFunc   ;==>Example

saludos

Thx, that works like a charm!

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  

×