Jump to content

Checkbox Enabled after button


JSmith312
 Share

Recommended Posts

Hello Everyone! 
I'm attempting to create a checklist app that performs other functions. For performance, I would like to check the box, then have the button to the right enabled. After that button is pressed, the second checkbox is enabled, and ready to be checked, allowing the second button to be pressed. After the second button is pressed, the completion/exit button is enabled/shown. I have my code that currently creates the GUI, creates the checkbox, but when you check it it enables the button and the next checkbox. Can't seem to figure out a Case for GUISetOnEvent. Any assistance would be appreciated!

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>


; Below is the GUI interface
_DeploymentProcess()

Func _DeploymentProcess()
    $aStep1 = GUICreate("Deployment Process", 475, 345, 500, 175)
    $CBcStep1 = GUICtrlCreateCheckbox("1. Step 01.", 15, 25, 300, 25)
      $BTNS1 = GUICtrlCreateButton("Email 01", 365, 25, 90, 20)
    $CBcStep2 = GUICtrlCreateCheckbox("2. Step 02.", 15, 50, 300, 25)
      $BTNS2 = GUICtrlCreateButton("Email 02", 365, 50, 90, 20)
        GUICtrlSetState($CBcStep2, $GUI_DISABLE)
        GUICtrlSetState($BTNS1, $GUI_DISABLE)
    $CBcStep3 = GUICtrlCreateButton("Hurray! You're Complete!", 85, 276, 300, 60)
      GUICtrlSetState($CBcStep3, $GUI_SHOW)

; Below are the button and checkbox enables/disables.
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($aStep1)
                Return
            ; Step 1
            Case $CBcStep1
                If GUICtrlRead($CBcStep1) = $GUI_CHECKED Then
                    GUICtrlSetState($BTNS1, $GUI_ENABLE)
                    GUICtrlSetState($CBcStep2, $GUI_ENABLE)
                Else
                    GUICtrlSetState($BTNS1, $GUI_DISABLE)
                    GUICtrlSetState($CBcStep2, $GUI_DISABLE)
                EndIf

            ; Step 2
            Case $CBcStep2
                If GUICtrlRead($CBcStep2) = $GUI_CHECKED Then
                    GUICtrlSetState($BTNS2, $GUI_ENABLE)
                    GUICtrlSetState($CBcStep3, $GUI_ENABLE)
                Else
                    GUICtrlSetState($BTNS2, $GUI_DISABLE)
                    GUICtrlSetState($CBcStep3, $GUI_DISABLE)
                 EndIf

            Case $CBcStep3
                If GUICtrlRead($CBcStep2) = $GUI_CHECKED Then
                    GUICtrlSetState($BTNS10, $GUI_ENABLE)
                    GUICtrlSetState($CBcStep3, $GUI_SHOW)
                Else
                    GUICtrlSetState($CBcStep3, $GUI_EVENT_CLOSE)
                 EndIf
              Case $GUI_EVENT_CLOSE, $CBcStep3
              #comments-end
                  Exit
            EndSwitch
    WEnd

EndFunc

 

Link to comment
Share on other sites

  • Developers

Like this?:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>
#include <MsgBoxConstants.au3>


; Below is the GUI interface
_DeploymentProcess()

Func _DeploymentProcess()
    $aStep1 = GUICreate("Deployment Process", 475, 345, 500, 175)
    $CBcStep1 = GUICtrlCreateCheckbox("1. Step 01.", 15, 25, 300, 25)
    $BTNS1 = GUICtrlCreateButton("Email 01", 365, 25, 90, 20)
    $CBcStep2 = GUICtrlCreateCheckbox("2. Step 02.", 15, 50, 300, 25)
    $BTNS2 = GUICtrlCreateButton("Email 02", 365, 50, 90, 20)
    GUICtrlSetState($CBcStep2, $GUI_DISABLE)
    GUICtrlSetState($BTNS1, $GUI_DISABLE)
    $CBcStep3 = GUICtrlCreateButton("Hurray! You're Complete!", 85, 276, 300, 60)
    GUICtrlSetState($CBcStep3, $GUI_HIDE)

    ; Below are the button and checkbox enables/disables.
    GUISetState(@SW_SHOW)
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($aStep1)
                Return
                ; Step 1
            Case $CBcStep1
                If GUICtrlRead($CBcStep1) = $GUI_CHECKED Then
                    GUICtrlSetState($BTNS1, $GUI_ENABLE)
                Else
                    GUICtrlSetState($BTNS1, $GUI_DISABLE)
                EndIf
            Case $BTNS1
                    GUICtrlSetState($CBcStep2, $GUI_ENABLE)
                ; Step 2
            Case $CBcStep2
                If GUICtrlRead($CBcStep2) = $GUI_CHECKED Then
                    GUICtrlSetState($BTNS2, $GUI_ENABLE)
                Else
                    GUICtrlSetState($BTNS2, $GUI_DISABLE)
                    GUICtrlSetState($CBcStep3, $GUI_HIDE)
                EndIf

            Case $BTNS2
                    GUICtrlSetState($CBcStep3, $GUI_SHOW)

            Case $GUI_EVENT_CLOSE, $CBcStep3
                ;
                Exit
        EndSwitch
    WEnd

EndFunc   ;==>_DeploymentProcess

Jos :)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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

×
×
  • Create New...