Jump to content

Need help with checkboxes


Recommended Posts

So for example I have

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 173, 81, 192, 124)
$Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 8, 8, 97, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 8, 32, 97, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 8, 56, 97, 17)
$Button1 = GUICtrlCreateButton("Button1", 88, 8, 75, 65)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
EndSwitch
WEnd

How to make it when you mark one check box and hit button it do one function, switching other checkbox and hitting button it do another function? Its like tree view when you click directly on it and starts func but this one need to hit button if i need to start. I should read values or what?

Also I dont want here to be able to check all boxes . for exmpl one box is checked when you hit on other chekbox then previos x dissapears.

Link to comment
Share on other sites

Opt("GUIOnEventMode", 1)
GUICreate("test",100,50)
GUISetOnEvent(-3,"_Exit")
Global $Test = GUICtrlCreateCheckbox("test",10,10,50,17)
GUICtrlSetOnEvent(-1,"testfunc")
Global $Test2 = GUICtrlCreateCheckbox("test2",10,30,50,17)
GUISetState()
Sleep(9999999999)
Func testfunc()
Switch GUICtrlRead($Test)
Case 1
Beep(100,100)
GUICtrlSetState($Test2,4)
Case 4
GUICtrlSetState($Test2,1)
Beep(300,100)
EndSwitch
EndFunc
Func _Exit()
Exit
EndFunc

look for examples in the help file, there are lots.

Link to comment
Share on other sites

And what about button?

Ah, the new in this one is strong.

Opt("GUIOnEventMode", 1)
GUICreate("test", 150, 60)
GUISetOnEvent(-3, "_Exit")
Global $Test = GUICtrlCreateCheckbox("test", 10, 10, 50, 17)
GUICtrlSetOnEvent(-1, "testfunc")
Global $Test2 = GUICtrlCreateCheckbox("test2", 10, 30, 50, 17)
Global $damnbutton = GUICtrlCreateButton("stupid button",60,8,70,50)
GUICtrlSetOnEvent(-1, "redundentness")
GUISetState()
Sleep(9999999999)
Func testfunc()
Switch GUICtrlRead($Test)
  Case 1
   Beep(100, 100)
   GUICtrlSetState($Test2, 4)
  Case 4
   GUICtrlSetState($Test2, 1)
   Beep(300, 100)
EndSwitch
EndFunc   ;==>testfunc
Func redundentness()
Select
  Case GUICtrlRead($Test) = 1 And GUICtrlRead($Test2) = 1
   Beep(520,100)
  Case GUICtrlRead($Test) = 1 And GUICtrlRead($Test2) = 4
   Beep(670,100)
  Case GUICtrlRead($Test) = 4 And GUICtrlRead($Test2) = 1
   Beep(850,100)
  Case GUICtrlRead($Test) = 4 And GUICtrlRead($Test2) = 4
   Beep(1000,100)
EndSelect
EndFunc
Func _Exit()
Exit
EndFunc   ;==>_Exit
Link to comment
Share on other sites

Opt("GUIOnEventMode", 1)
GUICreate("test", 150, 60)
GUISetOnEvent(-3, "_Exit")
Global $Test = GUICtrlCreateCheckbox("test", 10, 10, 50, 17)
GUICtrlSetOnEvent(-1, "testfunc")
Global $Test2 = GUICtrlCreateCheckbox("test2", 10, 30, 50, 17)
GUICtrlSetOnEvent(-1, "testfunc2")
Global $damnbutton = GUICtrlCreateButton("stupid button",60,8,70,50)
GUICtrlSetOnEvent(-1, "redundentness")
GUISetState()
Sleep(9999999999)
Func testfunc()
Switch GUICtrlRead($Test)
  Case 1
   Beep(100, 100)
   GUICtrlSetState($Test2, 4)
  Case 4
   GUICtrlSetState($Test2, 1)
   Beep(300, 100)
EndSwitch
EndFunc   ;==>testfunc
Func testfunc2()
Switch GUICtrlRead($Test2)
  Case 1
   Beep(180, 100)
   GUICtrlSetState($Test, 4)
  Case 4
   GUICtrlSetState($Test, 1)
   Beep(200, 100)
EndSwitch
EndFunc   ;==>testfunc
Func redundentness()
Select
  Case GUICtrlRead($Test) = 1 And GUICtrlRead($Test2) = 1
   Beep(520,100)
  Case GUICtrlRead($Test) = 1 And GUICtrlRead($Test2) = 4
   Beep(670,100)
  Case GUICtrlRead($Test) = 4 And GUICtrlRead($Test2) = 1
   Beep(850,100)
  Case GUICtrlRead($Test) = 4 And GUICtrlRead($Test2) = 4
   Beep(1000,100)
EndSelect
EndFunc
Func _Exit()
Exit
EndFunc   ;==>_Exit

you've been here since `2011, why don't you know this yet?

Barley logging on?

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...