Jump to content
Sign in to follow this  
sroprogger

Checkbox

Recommended Posts

sroprogger

Hi

How can I check if a checkbox is checked or not.

I tried

If $check = $GUI_CHECKED Then

MsgBox(0,"","checked")

but it wont work and i think its false !

so pls help me :D

Share this post


Link to post
Share on other sites
Swift

You must use GUICtrlRead() If it's a GUI Control! :D

Share this post


Link to post
Share on other sites
Squirrely1

I heard that using BitAND is more reliable for this:

$CBox = GUICtrlCreateCheckbox("My checkbox", 11, 11)
If BitAND(GuiCtrlRead($CBox), $GUI_CHECKED) = $GUI_CHECKED Then
;If GuiCtrlRead($CBox) = $GUI_CHECKED Then
    Msgbox(0,"","$CBox is Checked!")
Else
    Msgbox(0,"","$CBox is Not Checked!")
EndIf

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites
Valuater

First, Squirrely1 is correct

Secondly...

Generally, there is more that one checkbox or radio to be check and many use an array to create/check these controls, so I use this.... ( from Zedna in Autoit Wrappers )

Func _IsChecked($control)
    Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED
EndFunc

example

If _IsChecked($control_name) then....

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
Swift

I've never had any problems with:

If GUICtrlRead($Control) = $GUI_CHECKED Then

Share this post


Link to post
Share on other sites
monoceres

I've never had any problems with:

If GUICtrlRead($Control) = $GUI_CHECKED Then
Try use GUICtrlSetState($Control,$GUI_DISABLE) and then use your method :D

Broken link? PM me and I'll send you the file!

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  

×