gcue Posted October 1, 2009 Share Posted October 1, 2009 depending on the radio button chosen, id like to change the controls of the same window.. trying to do it through the while loop, the controls keep flickering better way to do this? thanks GUICreate($version, 240, 100) $check1 = GUICtrlCreateRadio("opt1", 10, 20) $check2 = GUICtrlCreateRadio("opt2", 10, 40) $check3 = GUICtrlCreateRadio("opt3", 10, 60) GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton") GUISetState(@SW_SHOW) While 1 ;Sleep(1) If BitAND(GUICtrlRead($check1), $GUI_CHECKED) = $GUI_CHECKED Then option1() EndIf WEnd Func option1() GUICtrlCreateLabel("option1", 120, 10) GUICtrlCreateButton("opt1", 120, 40) EndFunc ;==>option1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 1, 2009 Moderators Share Posted October 1, 2009 gcue,Use a flag to show if the controls are already created, that way you do not get the flashing:#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; <<<<<<<<<<<<<<<<<<<< Added GUICreate("version", 240, 100) ; <<<<<<<<<<<<<<<< Altered $check1 = GUICtrlCreateRadio("opt1", 10, 20) $check2 = GUICtrlCreateRadio("opt2", 10, 40) $check3 = GUICtrlCreateRadio("opt3", 10, 60) GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton") GUISetState(@SW_SHOW) $fOpt1Flag = False While 1 ;Sleep(1) If BitAND(GUICtrlRead($check1), $GUI_CHECKED) = $GUI_CHECKED Then If $fOpt1Flag = False Then option1() ; <<<<<<< Solution EndIf WEnd Func option1() $fOpt1Flag = True ; <<<<<<< Solution GUICtrlCreateLabel("option1", 120, 10) GUICtrlCreateButton("opt1", 120, 40) EndFunc ;==>option1 Func Xbutton() ; <<<<<<<<<<<<<<<<<<<<<<<< Whole function added Exit ; <<<<<<<<<<<<<<<<<<<<<<<< Whole function added EndFunc ; <<<<<<<<<<<<<<<<<<<<<<<< Whole function addedM23Hint to any readers: If you post code which can be run directly without having to add half a dozen lines it really increases your chances of getting a quick response. 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...
gcue Posted October 1, 2009 Author Share Posted October 1, 2009 works great when you switch the first time.. but when you switch back to it, it doesnt work expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) ; <<<<<<<<<<<<<<<<<<<< Added GUICreate("version", 240, 100) ; <<<<<<<<<<<<<<<< Altered $check1 = GUICtrlCreateRadio("1", 10, 20, 20) $check2 = GUICtrlCreateRadio("2", 10, 40, 20) $check3 = GUICtrlCreateRadio("3", 10, 60, 20) GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton") GUISetState(@SW_SHOW) $fOpt1Flag = False $fOpt2Flag = False $fOpt3Flag = False While 1 ;Sleep(1) If BitAND(GUICtrlRead($check1), $GUI_CHECKED) = $GUI_CHECKED Then If $fOpt1Flag = False Then option1() ; <<<<<<< Solution EndIf If BitAND(GUICtrlRead($check2), $GUI_CHECKED) = $GUI_CHECKED Then If $fOpt2Flag = False Then option2() ; <<<<<<< Solution EndIf If BitAND(GUICtrlRead($check3), $GUI_CHECKED) = $GUI_CHECKED Then If $fOpt3Flag = False Then option3() ; <<<<<<< Solution EndIf WEnd Func option1() $fOpt1Flag = True ; <<<<<<< Solution GUICtrlCreateLabel("option1", 120, 10) GUICtrlCreateButton("opt1", 120, 40) ;$fOpt1Flag = False EndFunc ;==>option1 Func option2() $fOpt2Flag = True ; <<<<<<< Solution GUICtrlCreateLabel("option2", 120, 10) GUICtrlCreateButton("opt2", 120, 40) ;$fOpt2Flag = False EndFunc ;==>option1 Func option3() $fOpt3Flag = True ; <<<<<<< Solution GUICtrlCreateLabel("option3", 120, 10) GUICtrlCreateButton("opt3", 120, 40) ;$fOpt3Flag = False EndFunc ;==>option1 Func Xbutton() ; <<<<<<<<<<<<<<<<<<<<<<<< Whole function added Exit ; <<<<<<<<<<<<<<<<<<<<<<<< Whole function added EndFunc ; <<<<<<<<<<<<<<<<<<<<<<<< Whole function added Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 1, 2009 Moderators Share Posted October 1, 2009 gcue, I have given you a generic solution. So why do you not have a go at coding something yourself and come back if you have problems, rather than expecting me to give you a ready-coded snippet? M23 Hint: You know that the flag idea works - what you have to do is delete the controls and reset the flag if the radio is not checked. 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...
gcue Posted October 1, 2009 Author Share Posted October 1, 2009 (edited) i did try. instead of just one option i added two more, i set the flags to false..and i also tried setting them back to true.. which brings back the flicker =) still trying.. thanks for your original post =) Edited October 1, 2009 by gcue Link to comment Share on other sites More sharing options...
PsaltyDS Posted October 1, 2009 Share Posted October 1, 2009 still trying.. We agree that you are still trying... I know you've been given examples like this before. And you've been around here too long to still be asking the same questions. It's time to study the examples and actually learn how they work: expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $iCheckboxes = 0 Do $iCheckboxes = Number(InputBox("Test", "Enter number of checkboxes\buttons: ")) Until $iCheckboxes <> 0 Global $hGUI, $avCheckboxes[$iCheckboxes], $avButtons[$iCheckboxes] $hGUI = GUICreate("version", 300, 20 + (50 * $iCheckboxes)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") For $n = 0 To UBound($avCheckboxes) - 1 $avCheckboxes[$n] = GUICtrlCreateCheckbox("Checkbox: " & $n + 1, 20, 20 + ($n * 50), 120, 20) GUICtrlSetOnEvent(-1, "_CheckBoxHit") $avButtons[$n] = GUICtrlCreateButton("Button: " & $n + 1, 175, 20 + ($n * 50), 100, 30) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlSetOnEvent(-1, "_ButtonHit") Next GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func _CheckBoxHit() ; Set conditions For $n = 0 To UBound($avCheckboxes) - 1 If ControlCommand($hGUI, "", $avCheckboxes[$n], "IsChecked") Then GUICtrlSetState($avButtons[$n], $GUI_SHOW) GUICtrlSetState($avButtons[$n], $GUI_ENABLE) Else GUICtrlSetState($avButtons[$n], $GUI_DISABLE) GUICtrlSetState($avButtons[$n], $GUI_HIDE) EndIf Next EndFunc ;==>_CheckBoxHit Func _ButtonHit() ConsoleWrite("Debug: _ButtonHit(): @GUI_CtrlId = " & @GUI_CtrlId & @LF) Local $sText = GUICtrlRead(@GUI_CtrlId) MsgBox(64, "Button Hit", "You clicked: " & $sText) EndFunc ;==>_ButtonHit Func _Quit() Exit EndFunc ;==>_Quit Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
gcue Posted October 1, 2009 Author Share Posted October 1, 2009 (edited) for the record, i dont remmeber asking for this before. also, im not a programmer by any means i have gotten better at this and am still working at improving. after my sign on date, i didnt use autoit (or any other type of programming) for a few years and then started using it maybe just short of 2 years ago again im sorry if i frustrate you.. this might come easy to some of you but not all of us. anyway, thanks for your help PSalty/Melba =) Edited October 1, 2009 by gcue Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 1, 2009 Moderators Share Posted October 1, 2009 gcue, One way of doing it: expandcollapse popup#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) GUICreate("version", 240, 100) $check1 = GUICtrlCreateRadio("opt1", 10, 20) $check2 = GUICtrlCreateRadio("opt2", 10, 40) $check3 = GUICtrlCreateRadio("opt3", 10, 60) GUISetOnEvent($GUI_EVENT_CLOSE, "Xbutton") GUISetState(@SW_SHOW) Global $fOpt1Flag = False Global $hLabel1 = 0 Global $hButton1 = 0 Global $fOpt2Flag = False Global $hLabel2 = 0 Global $hButton2 = 0 Global $fOpt3Flag = False Global $hLabel3 = 0 Global $hButton3 = 0 While 1 For $i = $check1 To $check3 If BitAND(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then ConsoleWrite($i - $check1 + 1 & @CRLF) option($i - $check1 + 1) ExitLoop EndIf Next WEnd Func option($i) Switch $i Case 1 If $fOpt1Flag = False Then GUICtrlDelete($hLabel2) GUICtrlDelete($hButton2) $fOpt2Flag = False GUICtrlDelete($hLabel3) GUICtrlDelete($hButton3) $fOpt3Flag = False $hLabel1 = GUICtrlCreateLabel("option1", 120, 10) $hButton1 = GUICtrlCreateButton("opt1", 120, 40) $fOpt1Flag = True EndIf Case 2 If $fOpt2Flag = False Then GUICtrlDelete($hLabel1) GUICtrlDelete($hButton1) $fOpt1Flag = False GUICtrlDelete($hLabel3) GUICtrlDelete($hButton3) $fOpt3Flag = False $hLabel2 = GUICtrlCreateLabel("option2", 120, 10) $hButton2 = GUICtrlCreateButton("opt2", 120, 40) $fOpt2Flag = True EndIf Case 3 If $fOpt3Flag = False Then GUICtrlDelete($hLabel1) GUICtrlDelete($hButton1) $fOpt1Flag = False GUICtrlDelete($hLabel2) GUICtrlDelete($hButton2) $fOpt2Flag = False $hLabel3 = GUICtrlCreateLabel("option3", 120, 10) $hButton3 = GUICtrlCreateButton("opt3", 120, 40) $fOpt3Flag = True EndIf EndSwitch EndFunc ;==>option1 Func Xbutton() Exit EndFunc 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...
gcue Posted October 1, 2009 Author Share Posted October 1, 2009 thanks again melba =) 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