Sign in to follow this  
Followers 0
BoBo

get Value from Checkbox

5 posts in this topic

hiho

I have searched and searched but i cant find any help.

maybe you are able to help me

my problem is that ... i want to use checkboxes and i want to check if they are activated or not

if i use GuiCtrlRead($Checkbox) ill get only the Controlid from the box

if i use GuiCtrlgetState($Checkbox) ill only get an 80 dont know what it is for.

but whether they are checked or not i get only the same value but i need to work with

TRUE or FALSE ... 0 or 1 something that let me decide.

plz help guys

Share this post


Link to post
Share on other sites



hi,

hope that helps you

#include <GUIConstants.au3>

GUICreate ("CheckState", 120, 60)

$check = GUICtrlCreateCheckbox ("My Checkbox", 10, 10, 100, 20)

$but = GUICtrlCreateButton ("Get State", 10, 30, 100, 20)

GuiSetState()

While 1

$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then

ExitLoop

ElseIf $msg = $but Then

$state = GuiCtrlRead ($check)

If $state = 1 Then

$state_text = "Checked"

Else ;unchecked=4

$state_text = "Unchecked"

EndIf

MsgBox (0,"State", $state_text)

EndIf

Wend

greets, chris

Share this post


Link to post
Share on other sites

hiho

I have searched and searched but i cant find any help.

maybe you are able to help me

my problem is that ... i want to use checkboxes and i want to check if they are activated or not

if i use GuiCtrlRead($Checkbox) ill get only the Controlid from the box

if i use GuiCtrlgetState($Checkbox) ill only get an 80 dont know what it is for.

but whether they are checked or not i get only the same value but i need to work with

TRUE or FALSE ... 0 or 1 something that let me decide.

plz help guys

GuiCtrlRead($Checkbox) return the state so you can test it with $GUI_CHECKED. remember you can have several state so the correct checking must be done with BitAnd(GuiCtrlRead($Checkbox), $GUI_CHECKED)

GuiCtrlgetState($Checkbox) as stated in the doc

As opposed to GUICtrlRead this function returns only the state of a control (disabled/hidden/etc)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

thx chris that helped alot ;)

thx thx needed that

Edited by BoBo

Share this post


Link to post
Share on other sites

Hi, here's another example with GUIEvent mode, shall you prefer this one.

We get the state of the checkbox and display it in the label below it.

Jakub (see att.)

chkbox.au3

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