Sign in to follow this  
Followers 0
CWorks

Need to hide or unhide controls

4 posts in this topic

I finally found how to hide controls until a checkbox is clicked

now how to get them to hide again when unchecked

I think i got to page 27 here before finding out how to hide them

must have read at least 10 of those :whistle:

#include <GUIConstants.au3>

GUICreate("Testing", 150, 80, -1, -1)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 0, 121, 17)
;$test = GUICtrlRead($Checkbox1)
GUISetState(@SW_SHOW)
;GuiSetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If $msg = $Checkbox1 Then
                ;If BitAND(GUICtrlRead($Checkbox1),$GUI_UNCHECKED) Then
                $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 32, 97, 17)
                $input = GUICtrlCreateInput("input", 8, 56, 137, 21, -1, $WS_EX_CLIENTEDGE)
            EndIf
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites



Should have asked... lol

No need to keep drawing it like that though:

#include <guiconstants.au3>
$Main = GUICreate("Testing", 150, 80, -1, -1)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 0, 121, 17)
$input = GUICtrlCreateInput("input", 8, 56, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 16, 32, 97, 17)
ControlHide($Main, '', GUICtrlGetHandle($input))
ControlHide($Main, '', GUICtrlGetHandle($Checkbox2))
GUICtrlSetState($Checkbox2, @SW_HIDE)
GUISetState(@SW_SHOW)
;GuiSetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            If $msg = $Checkbox1 Then
                If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
                    ControlShow($Main, '', GUICtrlGetHandle($input))
                    ControlShow($Main, '', GUICtrlGetHandle($Checkbox2))
                Else
                    ControlHide($Main, '', GUICtrlGetHandle($input))
                    ControlHide($Main, '', GUICtrlGetHandle($Checkbox2))
                EndIf
            EndIf
    EndSelect
WEnd
Exit
:whistle:

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I tend to learn a lot more by trying to find the answers myself

plus I found lots of other things along the way


Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

And now for something completely different....

#include <GUIConstants.au3>
$Form1 = GUICreate("", 501, 290, 193, 126)
$Edit1 = GUICtrlCreateEdit("", 184, 24, 273, 225)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlSetData($Edit1, "")
$Checkbox1 = GUICtrlCreateCheckbox("Edit box is hidden", 40, 56, 113, 17)
$Label = GUICtrlCreateLabel("", 40, 112, 43, 17)
$State = 0 ; 0 = Hidden   1 = Visible
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Checkbox1
            _State()
    EndSwitch
WEnd

Func _State()
    If $State = 0 Then
        GUICtrlSetState($Edit1, $GUI_SHOW)
        GUICtrlSetData($Checkbox1,"Edit box is visible")
        $State = 1
    Else
        GUICtrlSetState($Edit1, $GUI_HIDE)
        GUICtrlSetData($Checkbox1,"Edit box is hidden")
        $State = 0
    EndIf
EndFunc
Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

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