Function Reference


Creates a Checkbox control for the GUI.

GUICtrlCreateCheckbox ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )


text The text of the control checkbox.
left The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width [optional] The width of the control (default text autofit in width).
height [optional] The height of the control (default text autofit in height).
style [optional] Defines the style of the control. See GUI Control Styles Appendix.
    default ( -1) : $BS_AUTOCHECKBOX.
    forced styles : $WS_TABSTOP, and $BS_AUTOCHECKBOX if no checkbox style defined.
exStyle [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: the identifier (controlID) of the new control.
Failure: 0.


To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

A Checkbox control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage() to specify the picture to use.

To combine styles with the default style use BitOR ( $GUI_SS_DEFAULT_CHECKBOX, newstyle, ... ).

To use the values specified above you must #include <ButtonConstants.au3> in your script.

Default resizing is $GUI_DOCKHEIGHT.


GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg


#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>


Func Example()
        ; Create a GUI with various controls.
        Local $hGUI = GUICreate("Example", 300, 200)

        ; Create a checkbox control.
        Local $idCheckbox = GUICtrlCreateCheckbox("Standard Checkbox", 10, 10, 185, 25)
        Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)

        ; Display the GUI.
        GUISetState(@SW_SHOW, $hGUI)

        ; Loop until the user exits.
        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE, $idButton_Close

                        Case $idCheckbox
                                If _IsChecked($idCheckbox) Then
                                        MsgBox($MB_SYSTEMMODAL, "", "The checkbox is checked.", 0, $hGUI)
                                        MsgBox($MB_SYSTEMMODAL, "", "The checkbox is not checked.", 0, $hGUI)


        ; Delete the previous GUI and all controls.
EndFunc   ;==>Example

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