Jump to content

How to know if a checkbox state is changed


imani
 Share

Recommended Posts

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox")
$checkCN = GUICtrlCreateCheckbox ("CHECKBOX 1", 10, 10, 120, 20)
$label1 = GUICtrlCreateLabel ("unchecked", 10, 50, 120, 20)
GUISetState ()

While 1
    $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    If $msg = $checkCN Then 
        If IsChecked($checkCN ) Then 
            $state = 'checked'
        Else
            $state = 'unchecked'
        EndIf
        GUICtrlSetData ($label1 , $state)
    EndIf
Wend

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

See AutoIt helpfile for details...

Link to comment
Share on other sites

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox")
$checkCN = GUICtrlCreateCheckbox ("CHECKBOX 1", 10, 10, 120, 20)
$label1 = GUICtrlCreateLabel ("unchecked", 10, 50, 120, 20)
GUISetState ()

While 1
    $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then ExitLoop

    If $msg = $checkCN Then 
        If IsChecked($checkCN ) Then 
            $state = 'checked'
        Else
            $state = 'unchecked'
        EndIf
        GUICtrlSetData ($label1 , $state)
    EndIf
Wend

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

See AutoIt helpfile for details...

Thanks Zedna For your help
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...