Jump to content

Checkbox Question


fraudh8er
 Share

Recommended Posts

How would I make it so check a checkbox and that checkbox check multiple chec box's. I have my GUI made and it works and everything is great. I just need something that will let me check one check box on the GUI and it will know to check multiple of the checkbox's or uncheck them for ease of use.

I can provide code is that would be helpful, hopefully that make sense, I realize it is a bit confusing.

Thank you, Everyone on the Forum is more than heplful and great.

Link to comment
Share on other sites

Verify the Checkbox's state(main).

A small example:

#include "GUIConstants.au3"

GUICreate("Check test", 150, 100)
$MainCheck = GUICtrlCreateCheckbox("Select/Unselect", 5, 20, 120,20)
$check1 = GUICtrlCreateCheckbox("Check1", 5, 40, 70,20)
$check2 = GUICtrlCreateCheckbox("Check2", 5, 60, 70,20)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    IF $msg = $GUI_EVENT_CLOSE Then ExitLoop
       
    If $msg = $MainCheck Then
       If GUIRead($MainCheck)= $GUI_CHECKED Then
          $stateChk= $GUI_CHECKED
       Else
          $stateChk= $GUI_UNCHECKED
       EndIf
       GUICtrlSetState($check1, $stateChk)
       GUICtrlSetState($check2, $stateChk)
    EndIf
          
WEnd
GUIDelete()
Exit
Link to comment
Share on other sites

So I am assuming I have to run this with the most recent unstable verison. I cant seem to find GUICtrlCreateCheckbox in the version that I have. Is it a good idea to use the most recent version? Thank you

Verify the Checkbox's state(main).

A small example:

#include "GUIConstants.au3"

GUICreate("Check test", 150, 100)
$MainCheck = GUICtrlCreateCheckbox("Select/Unselect", 5, 20, 120,20)
$check1 = GUICtrlCreateCheckbox("Check1", 5, 40, 70,20)
$check2 = GUICtrlCreateCheckbox("Check2", 5, 60, 70,20)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()
    
    IF $msg = $GUI_EVENT_CLOSE Then ExitLoop
       
    If $msg = $MainCheck Then
       If GUIRead($MainCheck)= $GUI_CHECKED Then
          $stateChk= $GUI_CHECKED
       Else
          $stateChk= $GUI_UNCHECKED
       EndIf
       GUICtrlSetState($check1, $stateChk)
       GUICtrlSetState($check2, $stateChk)
    EndIf
          
WEnd
GUIDelete()
Exit

<{POST_SNAPBACK}>

Link to comment
Share on other sites

if you dont test the unstable version then who will ? :)

I used the good old :

$checkstate = 0

;some code to do prep etc and to point to the checkbox

; ASSuMing that Button5 is your check box

ControlFocus("RUNNING PROG", "", "Button5") .......

if $checkstate = 0 then

send(" ")

$checkstate =1

endif

; this assumes you will only change the check box once if you want

; to get fancy then you are on your own with keeping track of check state

if $checkstate = 1 then

send(" ")

$checkstate =0

endif

Link to comment
Share on other sites

Recent or old version? Really both are 'unstable' versions... :)

But, of course, recent version has new GUI features. :)

Ok, here the same code for you GUI version(I think):

#include "GUIConstants.au3"

GUICreate("Check test", 150, 100)
$MainCheck = GUISetControl("Checkbox", "Select/Unselect", 5, 20, 120,20)
GUISetControlNotify()

$check1 = GUISetControl("Checkbox", "Check1", 5, 40, 70,20)
$check2 = GUISetControl("Checkbox","Check2", 5, 60, 70,20)
GUIShow()

While 1
    $msg = GUIMsg()
    
    If $msg = -3 Then ExitLoop
       
    If $msg = $MainCheck Then
       If GUIRead($MainCheck)= $GUI_CHECKED Then
          $stateChk= $GUI_CHECKED
       Else
          $stateChk= $GUI_UNCHECKED
       EndIf
       GUISetControlEx($check1, $stateChk)
       GUISetControlEx($check2, $stateChk)
    EndIf
          
WEnd
GUIDelete()
Exit
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...