Sign in to follow this  
Followers 0
yucatan

gui checkbox

18 posts in this topic

hi i have a gui with a checkbox and i want that when i check the box a label and a input box disappears and that work with guictrldelete

but now i want that when the box is not checked he brings the label and input box back in the gui how i can do that ?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

hi i have a gui with a checkbox and i want that when i check the box a label and a input box disappears and that work with guictrldelete

but now i want that when the box is not checked he brings the label and input box back in the gui how i can do that ?

Maybe you should use GuiCtrlSetState, and than you can switch SW_SHOW/@SW_HIDE Edited by Andreik

When the words fail... music speaks

Share this post


Link to post
Share on other sites

Maybe you should use GuiCtrlSetState, and than you can switch SW_SHOW/@SW_HIDE

how do you mean ?

Share this post


Link to post
Share on other sites

how do you mean ?

If checkbox is selected than set state of label and input box @SW_HIDE.

If checkbox is not selected than set state of label and input box @SW_SHOW.


When the words fail... music speaks

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

If checkbox is selected than set state of label and input box @SW_HIDE.

If checkbox is not selected than set state of label and input box @SW_SHOW.

Always check the state of a control before setting the state of the control. This is to avoid flickering.

If GUICtrlGetState($Button_1) < 144 Then GUICtrlSetState($Button_1, 144)

Of course in your case it's the state of the label that you will check. I just used the button as an example.

BTW it's also a good policy to check text before updating text as well

While 1
$Txt = GUICtrlRead($Input_1)
If GUICtrlRead($Label_1 <> $Txt Then GUICtrlSetData($Label_1, $Txt)
Wend
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

If checkbox is selected than set state of label and input box @SW_HIDE.

If checkbox is not selected than set state of label and input box @SW_SHOW.

how i can check if the box is selected?

Share this post


Link to post
Share on other sites

how i can check if the box is selected?

If GUICtrlRead($checkbox) = 1 Then
   If GUICtrlGetState($label) <> 32 Then GUICtrlSetState($label, 32)
Else
   If GUICtrlGetState($label) <> 16 Then GUICtrlSetState($label, 16)
EndIf

Of course in tha case of a label there (usually) is really no reason to be checking state anyway. Since the background is transparent just use GUICtrlSetData(). The exception is where you may have a label and another control positioned at the same coordinates and you want to hide the label and display the second control.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

If GUICtrlRead($checkbox) = 1 Then
   If GUICtrlGetState($label) <> 32 Then GUICtrlSetState($label, 32)
Else
   If GUICtrlGetState($label) <> 16 Then GUICtrlSetState($label, 16)
EndIf

Of course in tha case of a label there (usually) is really no reason to be checking state anyway. Since the background is transparent just use GUICtrlSetData(). The exception is where you may have a label and another control positioned at the same coordinates and you want to hide the label and display the second control.

when i do this

if $cal1 = 4 then GUICtrlSetState($subject2,$GUI_SHOW)

if $cal1 = 1 then GUICtrlSetState($subject2,$GUI_HIDE)

it keeps blinking how to fix that ?

Share this post


Link to post
Share on other sites

when i do this

if $cal1 = 4 then GUICtrlSetState($subject2,$GUI_SHOW)

if $cal1 = 1 then GUICtrlSetState($subject2,$GUI_HIDE)

it keeps blinking how to fix that ?

If $cal1 = 4 then

If GuiCtrlGetState($subject2) <> $Gui_Show Then GUICtrlSetState($GUI_SHOW)

ElseIf $cal1 = 1 then

If GuiCtrlGetState($subject2) <> $Gui_Hide Then GUICtrlSetState($GUI_HIDE)

EndIf


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

If $cal1 = 4 then

If GuiCtrlGetState($subject2) <> $Gui_Show Then GUICtrlSetState($GUI_SHOW)

ElseIf $cal1 = 1 then

If GuiCtrlGetState($subject2) <> $Gui_Hide Then GUICtrlSetState($GUI_HIDE)

EndIf

I:\tcp login\client.au3(188,74) : ERROR: GUICtrlSetState() [built-in] called with wrong number of args.

If GuiCtrlGetState($subject2) <> $Gui_Show Then GUICtrlSetState($GUI_SHOW)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Share this post


Link to post
Share on other sites

I:\tcp login\client.au3(188,74) : ERROR: GUICtrlSetState() [built-in] called with wrong number of args.

If GuiCtrlGetState($subject2) <> $Gui_Show Then GUICtrlSetState($GUI_SHOW)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

I left out the first param, sorry

If $cal1 = 4 then
   If GuiCtrlGetState($subject2) <> $Gui_Show Then GUICtrlSetState($subject2, $GUI_SHOW)
ElseIf $cal1 = 1 then
   If GuiCtrlGetState($subject2) <> $Gui_Hide Then GUICtrlSetState($subject2, $GUI_HIDE)
EndIf

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

I left out the first param, sorry

If $cal1 = 4 then
   If GuiCtrlGetState($subject2) <> $Gui_Show Then GUICtrlSetState($subject2, $GUI_SHOW)
ElseIf $cal1 = 1 then
   If GuiCtrlGetState($subject2) <> $Gui_Hide Then GUICtrlSetState($subject2, $GUI_HIDE)
EndIf
when i run the code it keeps blinking

Share this post


Link to post
Share on other sites

Change it to

If $cal1 = 4 then
   If GuiCtrlGetState($subject2) > 80 Then GUICtrlSetState($subject2, 80); Visible = 16 + enabled = 64
ElseIf $cal1 = 1 then
   If GuiCtrlGetState($subject2) <> 96 Then GUICtrlSetState($subject2, 96); not visible = 32 + enabled = 64
EndIf

I also seem to remember something about

If BitAND(GuiCtrlGetState($subject2), $Gui_Show) Then "do whatever" but I forget exactly what it is and I don't have those code snippets handy at the moment.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Change it to

If $cal1 = 4 then
   If GuiCtrlGetState($subject2) > 80 Then GUICtrlSetState($subject2, 80); Visible = 16 + enabled = 64
ElseIf $cal1 = 1 then
   If GuiCtrlGetState($subject2) <> 96 Then GUICtrlSetState($subject2, 96); not visible = 32 + enabled = 64
EndIf

I also seem to remember something about

If BitAND(GuiCtrlGetState($subject2), $Gui_Show) Then "do whatever" but I forget exactly what it is and I don't have those code snippets handy at the moment.

i already got it worked

if $cal1=1 and $subject3 = 80 then GUICtrlSetState($subject2, $GUI_hide)

if $cal1=4 and $subject3 = 96 then GUICtrlSetState($subject2, $GUI_show)

if $cal1=1 and $input = 80 then GUICtrlSetState($subject, $GUI_hide)

if $cal1=4 and $input = 96 then GUICtrlSetState($subject, $GUI_show)

but i have another problem when i check the checkbox and my label and inputbox disappears then the value in the input box need to be set to "call Back Nota"

how i can do that ?

Share this post


Link to post
Share on other sites

I prefer to use _IsChecked()

#include <GUIConstants.au3>


GUICreate("Program Runner")

GUICtrlCreateLabel("Select the program.", 10, 10)
$P1 = GUICtrlCreateRadio("Notepad", 10, 40, 80, 30)
$P2 = GUICtrlCreateRadio("Explorer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($P1, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($P1) Then
                RunWait("Notepad.exe")
                RunWait("Explorer.exe")
                ; do what ever you want
            EndIf
            If _IsChecked($P2) Then RunWait("Explorer.exe")
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

So for your example

If $cal1=1 and _IsChecked($subject3) then GUICtrlSetState($subject2, $GUI_hide)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I prefer to use _IsChecked()

#include <GUIConstants.au3>


GUICreate("Program Runner")

GUICtrlCreateLabel("Select the program.", 10, 10)
$P1 = GUICtrlCreateRadio("Notepad", 10, 40, 80, 30)
$P2 = GUICtrlCreateRadio("Explorer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($P1, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($P1) Then
                RunWait("Notepad.exe")
                RunWait("Explorer.exe")
                ; do what ever you want
            EndIf
            If _IsChecked($P2) Then RunWait("Explorer.exe")
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

So for your example

If $cal1=1 and _IsChecked($subject3) then GUICtrlSetState($subject2, $GUI_hide)

8)

soz i cant get it working

i want that when i check the checkbox $subject="call back nota"

when i uncheck it then $subject=""

when i run it now it keeps blinking ofcourse because its in a while wend so it stays repeating

how i can fix that

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

when i click on the X in the right top of the window my gui quits

i want that he ask are you sure you wanne quit ?

how i can fix that ?

and

when i hit enter i want that a button that i specify is clicked how i can fix that ?

sethothet({enter}) dont work because when i run my prog then in other programs the enter dont work anymore how i can fix it ?

Edited by yucatan

Share this post


Link to post
Share on other sites

BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED

That's the one I couldn't remember. Thanks @Val


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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