Jump to content

$Gui_Disable not recognized


Ruigerock
 Share

Recommended Posts

Goodmorning people,

I've been busy with a usefull script for work but one part is not working as I thought it would.

I took the known _IsEnabled function, change 3 words to have it check an disabled checkbox status

The code below is not the actual script but it demonstrates the error.

If you select "Check all but disabled" it will select all 3 checkboxes which is not my intention, ehh help?

#include <MsgBoxConstants.au3>
#include <GuiConstants.au3>
#include <GuiConstantsEx.au3>

Local $box[03]

GuiCreate("Test", 300, 300, -1, -1)

$box[00] = GUICtrlCreateCheckbox("Unchecked", 20, 40, 240, 20)
$box[01] = GUICtrlCreateCheckbox("Disabled", 20, 60, 240, 20)
$box[02] = GUICtrlCreateCheckbox("Checked", 20, 80, 240, 20)
GUICtrlSetState($box[00], $GUI_UNCHECKED)
GUICtrlSetState($box[01], $GUI_DISABLE)
GUICtrlSetState($box[02], $GUI_CHECKED)
$Button_Ok = GUICtrlCreateButton("Check all but Disabled", 20 , 110, 180, 45)
$Button_KO = GUICtrlCreateButton("UnCheck all", 20 , 155, 180, 45)

GuiSetState()

Func _IsDisable($control)
    Return BitAND(GUICtrlRead($control), $GUI_DISABLE) = $GUI_DISABLE
EndFunc

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $Button_Ok
            For $i = 0 to 2
                If _IsDisable($box[$i]) Then
                    GUICtrlSetState($box[$i], $GUI_UNCHECKED)
                Else
                    GUICtrlSetState($box[$i], $GUI_CHECKED)
                EndIf
            Next
        Case $msg = $Button_KO
            For $i = 0 to 2
                GUICtrlSetState($box[$i], $GUI_UNCHECKED)
            Next
    EndSelect
WEnd
Link to comment
Share on other sites

It seems that GUICtrlRead() returns for checkbox only $GUI_UNCHECKED/$GUI_CHECKED

so use GUICtrlGetState() instead of GUICtrlRead() which returns all states together.

Func _IsDisable($control)
    Return BitAND(GUICtrlGetState($control), $GUI_DISABLE) = $GUI_DISABLE
EndFunc
Edited by Zedna
Link to comment
Share on other sites

Thank you Zedna, It works like a charm.

The help about GUICtrlRead confused me, it links to GUICtrlGetState without hinting to start using that function to retrieve the value

GUICtrlRead (ControlID [, advanced = 0] )

Default = 0 and it links to the table

Type                       Value

Checkbox, Radio state of the button. See State table

 

The topic has been solved :)

Edited by Ruigerock
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

×
×
  • Create New...