Jump to content
Sign in to follow this  
Xtupid

[GUI trouble] Enable and Disable

Recommended Posts

Xtupid

Hi everybody! I having a trouble with enable and disable some component. Here is it:

I create this:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 421, 243, 203, 125)
$Input1 = GUICtrlCreateInput("Input1", 48, 64, 289, 21)
$Start = GUICtrlCreateButton("Start", 344, 64, 73, 25, 0)
$Radio1 = GUICtrlCreateRadio("Radio1", 56, 192, 273, 25)
$Radio2 = GUICtrlCreateRadio("Radio1", 56, 152, 273, 25)
$Group1 = GUICtrlCreateGroup("Group1", 8, 128, 393, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd

Now, I want when user press the Start button it will change to Stop. And other component are Disabled. When Stop button are pressed it will change to Start againt and other component are enabled.

I hope everybody can understand what I am talking about! ( I speak English very bad )


Please don't angry if I wrote something wrong because my English vocabulary is very little....

Share this post


Link to post
Share on other sites
martin

Hi everybody! I having a trouble with enable and disable some component. Here is it:

I create this:

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 421, 243, 203, 125)
$Input1 = GUICtrlCreateInput("Input1", 48, 64, 289, 21)
$Start = GUICtrlCreateButton("Start", 344, 64, 73, 25, 0)
$Radio1 = GUICtrlCreateRadio("Radio1", 56, 192, 273, 25)
$Radio2 = GUICtrlCreateRadio("Radio1", 56, 152, 273, 25)
$Group1 = GUICtrlCreateGroup("Group1", 8, 128, 393, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

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

    EndSwitch
WEnd

Now, I want when user press the Start button it will change to Stop. And other component are Disabled. When Stop button are pressed it will change to Start againt and other component are enabled.

I hope everybody can understand what I am talking about! ( I speak English very bad )

Try this

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 421, 243, 203, 125)

$Start = GUICtrlCreateButton("Start", 344, 64, 73, 25, 0);<- keep separate from controls to be enabled or disabled

$Input1 = GUICtrlCreateInput("Input1", 48, 64, 289, 21)
$Radio1 = GUICtrlCreateRadio("Radio1", 56, 192, 273, 25)
$Radio2 = GUICtrlCreateRadio("Radio1", 56, 152, 273, 25)
$Group1 = GUICtrlCreateGroup("Group1", 8, 128, 393, 113)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$startBtn = True
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            If $startBtn Then
                GUICtrlSetData($Start,"STOP")
                For $n = $Input1 To $Group1
                    GUICtrlSetState($n,$GUI_DISABLE)
                Next
                $StartBtn = False
            Else
                GUICtrlSetData($Start,"Start")
                For $n = $Input1 To $Group1
                    GUICtrlSetState($n,$GUI_ENABLE)
                Next
                $StartBtn = True
            EndIf
            
            
    EndSwitch
WEnd

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

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  

×