Tiboi Posted May 25, 2010 Share Posted May 25, 2010 hi guys i am trying to have group2 be hidden by default then for me to unhide it when the checkbox is checked. can someone help me with where i'm going wrong please? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 413, 298, 302, 218) $Group1 = GUICtrlCreateGroup("Group1", 24, 16, 249, 153) $Group2 = GUICtrlCreateGroup("Group2", 72, 64, 169, 89) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateGroup("", -99, -99, 1, 1) $Checkbox1 = GUICtrlCreateCheckbox("UnHide group 2", 296, 80, 97, 17) GUICtrlSetState(-1, $GUI_UNCHECKED) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 UNHIDE() EndSwitch WEnd Func UNHIDE() GUISetState($GUI_SHOW, $Group2) EndFunc ;==>UNHIDE Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 I have modified your code somewhat, see the difference? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 413, 298, 302, 218) $Group1 = GUICtrlCreateGroup("Group1", 24, 16, 249, 153) $Group2 = GUICtrlCreateGroup("Group2", 72, 64, 169, 89) ;GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateGroup("", -99, -99, 1, 1) $Checkbox1 = GUICtrlCreateCheckbox("UnHide group 2", 296, 80, 97, 17) GUICtrlSetState(-1, $GUI_UNCHECKED) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 UNHIDE() EndSwitch WEnd Func UNHIDE() ;GUISetState($GUI_SHOW, $Group2) GUICtrlSetState($Group2, $GUI_SHOW) EndFunc ;==>UNHIDE - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 (edited) I have modified your code somewhat, see the difference? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 413, 298, 302, 218) $Group1 = GUICtrlCreateGroup("Group1", 24, 16, 249, 153) $Group2 = GUICtrlCreateGroup("Group2", 72, 64, 169, 89) ;GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateGroup("", -99, -99, 1, 1) $Checkbox1 = GUICtrlCreateCheckbox("UnHide group 2", 296, 80, 97, 17) GUICtrlSetState(-1, $GUI_UNCHECKED) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 UNHIDE() EndSwitch WEnd Func UNHIDE() ;GUISetState($GUI_SHOW, $Group2) GUICtrlSetState($Group2, $GUI_SHOW) EndFunc ;==>UNHIDE yes it works thanks. so how do i hide it again if i uncheck the checkbox? like toggle. (please don't be mad for me asking) this is my 4th day learning Autoit edit: never mind i got it to do what i wanted. here is the solved code: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 413, 298, 302, 218) $Group1 = GUICtrlCreateGroup("Group1", 24, 16, 249, 153) $Group2 = GUICtrlCreateGroup("Group2", 72, 64, 169, 89) ;GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateGroup("", -99, -99, 1, 1) $Checkbox1 = GUICtrlCreateCheckbox("UnHide group 2", 296, 80, 97, 17) GUICtrlSetState(-1, $GUI_UNCHECKED) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 UNHIDE() EndSwitch WEnd Func UNHIDE() If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ;GUISetState($GUI_SHOW, $Group2) GUICtrlSetState($Group2, $GUI_SHOW) Else GUICtrlSetState($Group2, $GUI_HIDE) EndIf ;==>UNHIDE EndFunc ;==>UNHIDE Edited May 25, 2010 by Tiboi Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 Change the function UNHIDE() to this.Func UNHIDE() If GUICtrlGetState($Group2) = 96 Then GUICtrlSetState($Group2, $GUI_SHOW) Else GUICtrlSetState($Group2, $GUI_HIDE) EndIf EndFunc ;==>UNHIDE - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 Two different ways to do it, there's more I'm sure, so a new problem: which to use? - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 (edited) Two different ways to do it, there's more I'm sure, so a new problem: which to use? lol thanks for the help man i appreciate it. oh and where can i find the a list of controlID(s) Edited May 25, 2010 by Tiboi Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 You bet. Good luck. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 (edited) somdcomputerguy i have 2 questions: 1. where can i find the a list of controlIDs, cause i'd like to know how you got 96 in If GUICtrlGetState($Group2) = 96 Then 2. how do i get controls in group2 to hide as well. eg. if i add a textbox to group2 Edited May 25, 2010 by Tiboi Link to comment Share on other sites More sharing options...
somdcomputerguy Posted May 25, 2010 Share Posted May 25, 2010 Here's a new UNHIDE() Func UNHIDE() If GUICtrlGetState($Group2) = 96 Then GUICtrlSetState($Group2, $GUI_SHOW) ConsoleWrite(GUICtrlGetState($Group2) & @LF) Else GUICtrlSetState($Group2, $GUI_HIDE) ConsoleWrite(GUICtrlGetState($Group2) & @LF) EndIf EndFunc ;==>UNHIDE AFAIK, any controls in a hidden group will be hidden as well. If not, I suppose they could be hidden/shown individually.. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
Tiboi Posted May 25, 2010 Author Share Posted May 25, 2010 here is the code, it does not hide tne control inside the group expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\Desktop\Form2.kxf $Form2 = GUICreate("Form2", 414, 299, 302, 218) $Group1 = GUICtrlCreateGroup("Group1", 24, 16, 249, 153) $Group2 = GUICtrlCreateGroup("Group2", 56, 64, 169, 89) $Input2 = GUICtrlCreateInput("Input2", 72, 104, 121, 21) ;GUICtrlCreateGroup("", -99, -99, 1, 1) $Input1 = GUICtrlCreateInput("Input1", 40, 32, 121, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Checkbox1 = GUICtrlCreateCheckbox("UnHide group 2", 296, 80, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 UNHIDE() EndSwitch WEnd ;Func UNHIDE() <-- my code ; If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ; GUICtrlSetState($Group2, $GUI_SHOW) ; Else ; GUICtrlSetState($Group2, $GUI_HIDE) ; EndIf ;EndFunc ;==>UNHIDE ;Func UNHIDE() <--somdcomputerguy code 1 ; If GUICtrlGetState($Group2) = 96 Then ; GUICtrlSetState($Group2, $GUI_SHOW) ; Else ; GUICtrlSetState($Group2, $GUI_HIDE) ; EndIf ;EndFunc ;==>UNHIDE Func UNHIDE() ;<--somdcomputerguy code 2 If GUICtrlGetState($Group2) = 96 Then GUICtrlSetState($Group2, $GUI_SHOW) ConsoleWrite(GUICtrlGetState($Group2) & @LF) Else GUICtrlSetState($Group2, $GUI_HIDE) ConsoleWrite(GUICtrlGetState($Group2) & @LF) EndIf EndFunc ;==>UNHIDE Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2010 Moderators Share Posted May 25, 2010 Tiboi,You have to hide/show each control individually. If you create the controls in IMMEDIATE succession, you can do it like this: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\Desktop\Form2.kxf $Form2 = GUICreate("Form2", 414, 299, 302, 218) $Group1 = GUICtrlCreateGroup("Group1", 24, 16, 249, 153) $Input1 = GUICtrlCreateInput("Input1", 40, 32, 121, 21) $Group2 = GUICtrlCreateGroup("Group2", 56, 64, 169, 89) $Input2 = GUICtrlCreateInput("Input2", 72, 104, 121, 21) $GroupEnd = GUICtrlCreateGroup("", -99, -99, 1, 1) ; Hide Group2 to start Group_Display($Group2, $GroupEnd, $GUI_HIDE) $Checkbox1 = GUICtrlCreateCheckbox("UnHide group 2", 296, 80, 97, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Checkbox1 If GUICtrlRead($Checkbox1) = 1 Then Group_Display($Group2, $GroupEnd, $GUI_SHOW) Else Group_Display($Group2, $GroupEnd, $GUI_HIDE) EndIf EndSwitch WEnd Func Group_Display($iStart, $iEnd, $iState) For $i = $iStart To $iEnd GUICtrlSetState($i, $iState) Next EndFuncI hope it is clear what is going on - please ask if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now