Function Reference


GUICtrlCreateCheckbox

Creates a Checkbox control for the GUI.

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

Parameters

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.

Remarks

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.

Related

GUICoordMode (Option), GUICtrlUpdate..., GUIGetMsg

Example

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

Example()

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 $idClose = 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, $idClose
                ExitLoop

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

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

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