Jump to content

If Checkbox Read Only Situation


Recommended Posts

How can I make checkbox "B" readonly if checkbox "A" is checked and release, and the vice versa. This is wht I have, but it doesn't work.

If GUICtrlRead($removeMD) = $GUI_CHECKED then
            GUICtrlSetStyle($exportmaster, $WS_DISABLED)    
        EndIf
        If GUICtrlRead($removeMD) = $GUI_UNCHECKEDCHECKED then
            GUICtrlSetStyle($exportmaster, $GUI_ENABLE) 
        EndIf
        If GUICtrlRead($exportmaster) = $GUI_CHECKED then
            GUICtrlSetStyle($removeMD, $WS_DISABLED)    
        EndIf
        If GUICtrlRead($removeMD) = $GUI_UNCHECKEDCHECKED then
            GUICtrlSetStyle($removeMD, $GUI_ENABLE) 
        EndIf
Link to comment
Share on other sites

  • Moderators

Yes, I thought of that. However, it is a part of a larger set of inputs that are all checkboxes. Two radios out of several checkboxes are not very aesthetically pleasing.

Edit:

Bad Example, I'll see if I can come up with something else :D

Edit2:

You could set it up something like this I guess:

#include <guiconstants.au3>
Global $DisableBox = 0
Local $CheckBox[3]
$Main = GUICreate('Test Checkbox', 200, 100)
$CheckBox[1] = GUICtrlCreateCheckbox('Box 1', 10, 10, 50, 20)
$CheckBox[2] = GUICtrlCreateCheckbox('Box 2', 10, 35, 50, 20)

GUISetState()

While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = - 3
            Exit
        Case $Msg = $CheckBox[1]
            If Not $DisableBox Then
                _CheckBoxDisable()
            ElseIf $DisableBox Then
                If BitAND(GUICtrlRead($CheckBox[2]), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUICtrlSetState($CheckBox[1], $GUI_UNCHECKED)
                    _CheckBoxDisable()
                EndIf
            EndIf
        Case $Msg = $CheckBox[2]
            If Not $DisableBox Then
                _CheckBoxDisable()
            ElseIf $DisableBox Then
                If BitAND(GUICtrlRead($CheckBox[1]), $GUI_CHECKED) = $GUI_CHECKED Then
                    GUICtrlSetState($CheckBox[2], $GUI_UNCHECKED)
                    _CheckBoxDisable()
                EndIf
            EndIf
    EndSelect
WEnd

Func _CheckBoxDisable()
    $DisableBox = Not $DisableBox
EndFunc

Edit3:

Or just do what Simucal said, that example looks much easier :( (Damn I over think things so often :))

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Search for "checkbox" returned this result on the first page:

http://www.autoitscript.com/forum/index.ph...386&hl=checkbox

When one is checked, uncheck the other

Edit: Like Valuater said, you are using GuiCtrlSetStyle, not SetState.

Edited by Simucal
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

Thanks both of you. I used Simucal's link, it was much simpler. I did do a search, but I used "readonly +checkbox" because I figured "checkbox" would return way too many pages.

SmOke_N, with your code if you Check "A", then go to check "B" once, it works. However, if you try and check "B" a second time, it goes through. Thanks anyway.

I didn't even notice what Valuater said there, I just saw radio.

Edited by Champak
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...