Sign in to follow this  
Followers 0
Capone

Check Box Question

7 posts in this topic

how would i make one check box uncheck another/others if checked?

here's what i have

$GUI = GUICreate("Test", 364, 600)
$Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20)
GuiCtrlSetState(-1, $GUI_CHECKED)
$Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20)
GUISetState(@SW_SHOW)

While 1
    GuiGetMsg($Normal)
    If $Box1 = $GUI_CHECKED Then
        GUISetState($Box2, $GUI_UNCHECKED)
    EndIf
    If $Box2 = $GUI_CHECKED Then
        GUISetState($Box1, $GUIUNCHECKED)
    EndIf
WEnd

Share this post


Link to post
Share on other sites



If I understand correctly, you want to have if one box is checked then other predefined boxes unchecked if checked.

$GUI = GUICreate("Test", 364, 600)
$Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20)
GuiCtrlSetState(-1, $GUI_CHECKED)
$Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Switch $msg
      Case $box1
        If $Box2 = $GUI_CHECKED Then
           GUISetState($Box2, $GUI_UNCHECKED)
        Else
           GUISetState($Box2, $GUI_CHECKED)
        EndIf
      Case $Box2
         If $Box1 = $GUI_CHECKED Then
           GUISetState($Box1, $GUI_UNCHECKED)
         Else
           GUISetState($Box1, $GUI_CHECKED)
         EndIf
    EndSwitch
WEnd

Triton

Share this post


Link to post
Share on other sites

If I understand correctly, you want to have if one box is checked then other predefined boxes unchecked if checked.

$GUI = GUICreate("Test", 364, 600)
$Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20)
GuiCtrlSetState(-1, $GUI_CHECKED)
$Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20)
GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Switch $msg
      Case $box1
        If $Box2 = $GUI_CHECKED Then
           GUISetState($Box2, $GUI_UNCHECKED)
        Else
           GUISetState($Box2, $GUI_CHECKED)
        EndIf
      Case $Box2
         If $Box1 = $GUI_CHECKED Then
           GUISetState($Box1, $GUI_UNCHECKED)
         Else
           GUISetState($Box1, $GUI_CHECKED)
         EndIf
    EndSwitch
WEnd

i tried your idea and it didnt work properly but i see what your trying to do

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Capone

Example:

#include <GuiConstantsEx.au3>

$GUI = GUICreate("Test", 364, 600)

$Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20)
GuiCtrlSetState(-1, $GUI_CHECKED)

$Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20)

GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
      Case $box1
        If GUICtrlRead($Box2) = $GUI_CHECKED Then
            GUICtrlSetState($Box2, $GUI_UNCHECKED)
        Else
            GUICtrlSetState($Box2, $GUI_CHECKED)
        EndIf
    Case $Box2
        If GUICtrlRead($Box1) = $GUI_CHECKED Then
            GUICtrlSetState($Box1, $GUI_UNCHECKED)
        Else
            GUICtrlSetState($Box1, $GUI_CHECKED)
        EndIf
    EndSwitch
WEnd
Edited by rasim

Share this post


Link to post
Share on other sites

Capone

Example:

#include <GuiConstantsEx.au3>

$GUI = GUICreate("Test", 364, 600)

$Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20)
GuiCtrlSetState(-1, $GUI_CHECKED)

$Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20)

GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
      Case $box1
        If GUICtrlRead($Box2) = $GUI_CHECKED Then
            GUICtrlSetState($Box2, $GUI_UNCHECKED)
        Else
            GUICtrlSetState($Box2, $GUI_CHECKED)
        EndIf
    Case $Box2
        If GUICtrlRead($Box1) = $GUI_CHECKED Then
            GUICtrlSetState($Box1, $GUI_UNCHECKED)
        Else
            GUICtrlSetState($Box1, $GUI_CHECKED)
        EndIf
    EndSwitch
WEnd
YOU ROCK! THANKS :)

Share this post


Link to post
Share on other sites

why not just use Radios?


Giggity

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

why not just use Radios?

Perhaps the options are mutually exclusive, but neither is mandatory -- which is what I was looking to do.

So, in my instance, this is what the code needs to look like:

#include <GuiConstantsEx.au3>

$GUI = GUICreate("Test", 364, 600)

$Box1 = GuiCtrlCreateCheckbox("", 0, 400, 80, 20)
GuiCtrlSetState(-1, $GUI_CHECKED)

$Box2 = GUICtrlCreateCheckbox("", 0, 430, 100, 20)

GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
      Case $Box1
        If GUICtrlRead($Box2) = $GUI_CHECKED Then
            GUICtrlSetState($Box1, $GUI_CHECKED)
            GUICtrlSetState($Box2, $GUI_UNCHECKED)
        EndIf
      Case $Box2
        If GUICtrlRead($Box1) = $GUI_CHECKED Then
            GUICtrlSetState($Box2, $GUI_CHECKED)
            GUICtrlSetState($Box1, $GUI_UNCHECKED)
        EndIf
    EndSwitch
WEnd

Many thanks to Capone and rasim for getting me on the right track with this.

Edited by TheSovereign

[font="Courier New"]__________________________________________________There is always another way, usually a better one.[/font]

Share this post


Link to post
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
Sign in to follow this  
Followers 0