Sign in to follow this  
Followers 0
vladedoty

How do I gray out (disable) areas if checkbox is unchecked?

2 posts in this topic

#1 ·  Posted (edited)

here is my variables

now I want the input boxes and labels to be "grayed out" (disabled) if the checkbox is unchecked and enabled if checked.

$chkUseProgram = GUICtrlCreateCheckbox("Program", 20, 35, 110, 17)
$lblBasic = GUICtrlCreateLabel("Basic Options:", 20, 57, 80, 17)
GUICtrlSetColor(-1, 0xff0000)
$lblProgramPath = GUICtrlCreateLabel("Exe path:", 50, 74, 80, 17)
$txtProgramPath = GUICtrlCreateInput("", 105, 71, 129, 19)
$cmdProgramPath = GUICtrlCreateButton("...", 238, 71, 20, 19)
$lblProfile = GUICtrlCreateLabel(" Profile to load:", 25, 96, 80, 17)
$txtProfile = GUICtrlCreateInput("", 105, 94, 129, 19)
$cmdProfile = GUICtrlCreateButton("...", 238, 94, 20, 19)
$lblBatchPath = GUICtrlCreateLabel("Batch path:", 39, 119, 80, 17)
$txtBatchPath = GUICtrlCreateInput("", 105, 117, 129, 19)
$cmdSelectBatchPath = GUICtrlCreateButton("...", 238, 117, 20, 19)
Edited by vladedoty

Share this post


Link to post
Share on other sites



You can use a For-loop:

#include <GUIConstantsEx.au3>

GUICreate("Test", 320, 320)
$chkUseProgram = GUICtrlCreateCheckbox("Program", 20, 35, 110, 17)
$lblBasic = GUICtrlCreateLabel("Basic Options:", 20, 57, 80, 17)
GUICtrlSetColor(-1, 0xff0000)
$lblProgramPath = GUICtrlCreateLabel("Exe path:", 50, 74, 80, 17)
$txtProgramPath = GUICtrlCreateInput("", 105, 71, 129, 19)
$cmdProgramPath = GUICtrlCreateButton("...", 238, 71, 20, 19)
$lblProfile = GUICtrlCreateLabel(" Profile to load:", 25, 96, 80, 17)
$txtProfile = GUICtrlCreateInput("", 105, 94, 129, 19)
$cmdProfile = GUICtrlCreateButton("...", 238, 94, 20, 19)
$lblBatchPath = GUICtrlCreateLabel("Batch path:", 39, 119, 80, 17)
$txtBatchPath = GUICtrlCreateInput("", 105, 117, 129, 19)
$cmdSelectBatchPath = GUICtrlCreateButton("...", 238, 117, 20, 19)

For $X = $lblProgramPath To $cmdSelectBatchPath
    GUICtrlSetState($X, $GUI_DISABLE)
Next
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $chkUseProgram
            If BitAnd(GUICtrlRead($chkUseProgram),$GUI_CHECKED) Then
                For $X = $lblProgramPath To $cmdSelectBatchPath
                    GUICtrlSetState($X, $GUI_ENABLE)
                Next
            Else
                For $X = $lblProgramPath To $cmdSelectBatchPath
                    GUICtrlSetState($X, $GUI_DISABLE)
                Next
            EndIf
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
1 person likes this

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