Jump to content
Sign in to follow this  
GabrielSumner

Making controls appear when a checkbox is (being) checked

Recommended Posts

GabrielSumner

Hi everybody!

I am new to AutoIt but I have some Java programming background so I was able to figure a lot of stuff on my own. But this time I am really stuck muttley

my script is running in "GUIOnEventMode". What I want to do is: if one activates a checkbox the GUI shall display another control next to it, lets say an image. If on the other hand the checkbox is being unckecked the GUI shall set the visibility of the control to "false".

The question is: is it possible to query the GUI constantly in "GUIOnEventMode"?

Here is an example code, just some snippets:

$H = GUICtrlCreateCheckbox("Higlight Mode", 54, 384, 97, 25)
           GUICtrlSetOnEvent(-1, "showHelp_H")


;------ Function -------
Func showHelp_H()
    If $H = $GUI_CHECKED Then
        GUICtrlSetState($help_me_H,$GUI_SHOW)  ; $help_me_H is an image declared on some other place in the script
    ElseIf $H = $GUI_UNCHECKED Then
       GUICtrlSetState($help_me_H,$GUI_HIDE)
    EndIf
EndFunc

Thanks a lot :) !

Share this post


Link to post
Share on other sites
billthecreator

two things wrong...

this is how it is

$H = GUICtrlCreateCheckbox("Higlight Mode", 54, 384, 97, 25)
           GUICtrlSetOnEvent(-1, "showHelp_H")


;------ Function -------
Func showHelp_H()
    If BitAND(GUICtrlRead($h), $GUI_CHECKED) = $GUI_CHECKED Then; this is if it is checked when you press it then.
    GUICtrlSetState($$help_me_H, $GUI_HIDE)
    Else; but if it is unchecked when you press it then.
    GUICtrlSetState($$help_me_H, $GUI_SHOW)
    EndIf
EndFunc
Edited by billthecreator

[font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap

Share this post


Link to post
Share on other sites
GabrielSumner

Great! Thanks a lot - it worked :-) Still have to learn a lot. I only had to put the two "Show" & "Hide" lines in the right order like this:

GUICtrlSetState($$help_me_H,$GUI_SHOW )
        Else
    GUICtrlSetState($$help_me_H, $GUI_HIDE)

Ohterwise the control item got hidden when the checkbox was checked :P

Thanks again!

two things wrong...

this is how it is

$H = GUICtrlCreateCheckbox("Higlight Mode", 54, 384, 97, 25)
           GUICtrlSetOnEvent(-1, "showHelp_H")


;------ Function -------
Func showHelp_H()
    If BitAND(GUICtrlRead($h), $GUI_CHECKED) = $GUI_CHECKED Then; this is if it is checked when you press it then.
    GUICtrlSetState($$help_me_H, $GUI_HIDE)
    Else; but if it is unchecked when you press it then.
    GUICtrlSetState($$help_me_H, $GUI_SHOW)
    EndIf
EndFunc

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  

×