Jump to content

Checkbox Questions

Recommended Posts

I have two check boxes, I would like to be able to select only one. When one is selected, I would like the other to unselect. Would someone please help.


Lets say you've got checkbox[1] as your first checkbox and checkbox[2] as your second checkbox. Now you have to do

While 2
     $msg = GUIGetMsg()
        Case $msg = $GUI_EVENT_CLOSE
        Case $msg = $checkbox[1]
        Case $msg = $checkbox[2]

Think that would work

My little company: Evotec (PL version: Evotec)

Link to comment
Share on other sites

#include <guiconstants.au3>

$m = GUICreate('test')

$nonms = GUICtrlCreateCheckbox('test checkbox', 10, 10, 120)
$nonms2 = GUICtrlCreateCheckbox('test checkbox 2', 10, 30, 120)


While 1
   $msg = GUIGetMsg()
      Case $msg = $GUI_EVENT_CLOSE
      Case $msg = $nonms
         If BitAND(GUICtrlRead($nonms), $GUI_CHECKED) Then GUICtrlSetState($nonms2,$GUI_UNCHECKED)
      Case $msg = $nonms2
         If BitAND(GUICtrlRead($nonms2), $GUI_CHECKED) Then GUICtrlSetState($nonms,$GUI_UNCHECKED)

SciTE for AutoItDirections for Submitting Standard UDFs


Don't argue with an idiot; people watching may not be able to tell the difference.


Link to comment
Share on other sites

You should really use the radio control (to be consistent with standard user-interface design). Plus, you just need to replace GuiCtrlCreateCheckbox with GuiCtrlCreateRadio without adding additional code :o

#include <GUIConstants.au3>

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
    GUICtrlSetState ($radio1, $GUI_CHECKED)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)

GUISetState ()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
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

  • Recently Browsing   0 members

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