Jump to content
Sign in to follow this  
Capone

Check Box Question

Recommended Posts

Capone

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
Triton

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
Capone

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
rasim

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

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
youknowwho4eva

why not just use Radios?


Giggity

Share this post


Link to post
Share on other sites
TheSovereign

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.