bobbintb Posted November 1, 2011 Share Posted November 1, 2011 so im having a little programmers block and thought id ask for help. i have an updown button called $updown that ranges from 1 to 15 with 1 as the default. i want the code create a number of input boxes with browse buttons based on the number in the updown. so if 7 in the number in updown, there should be 7 inputs with 7 browse buttons. i also need it to correct itself. so for instance i go to 8 and then down one to 7, it needs to delete the last one. right now i just have the gui call this function when $updown is clicked. heres what i have so far: Func browseforvidarray() $i=1 Do ;~ MsgBox(0, "", $i) $videoinput[$i-1] = GUICtrlCreateInput("", 16, 136+25*$i, 417, 21) $videolook[$i-1] = GUICtrlCreateButton("Browse", 444, 132+25*$i, 65, 25) $i=$i+1 redim $videoinput[$i+1] redim $videolook[$i+1] until $i>=GUICtrlRead($input)+1 EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 1, 2011 Moderators Share Posted November 1, 2011 bobbintb, Perhaps something along these lines might do the trick: expandcollapse popup#include <GUIConstantsEx.au3> #include <UpdownConstants.au3> #include <EditConstants.au3> Global $aInputs[15] $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput(1, 10, 10, 40, 20, $ES_READONLY) $hUpDown = GUICtrlCreateUpdown(-1, $UDS_WRAP) GUICtrlSetLimit(-1, 15, 1) For $i = 0 To 14 $aInputs[$i] = GUICtrlCreateInput("", 10, 50 + ($i * 30), 200, 20) If $i Then GUICtrlSetState(-1, $GUI_HIDE) EndIf Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hUpDown $iCount = GUICtrlRead($hInput) For $i = 0 To $iCount - 1 GUICtrlSetState($aInputs[$i], $GUI_SHOW) Next For $i = $iCount To UBound($aInputs) - 1 GUICtrlSetState($aInputs[$i], $GUI_HIDE) Next EndSwitch WEnd As you can see, all the controls are created initially and then shown/hidden as required. Sneaky but useful. 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...
bobbintb Posted November 1, 2011 Author Share Posted November 1, 2011 bobbintb, Perhaps something along these lines might do the trick: expandcollapse popup#include <GUIConstantsEx.au3> #include <UpdownConstants.au3> #include <EditConstants.au3> Global $aInputs[15] $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput(1, 10, 10, 40, 20, $ES_READONLY) $hUpDown = GUICtrlCreateUpdown(-1, $UDS_WRAP) GUICtrlSetLimit(-1, 15, 1) For $i = 0 To 14 $aInputs[$i] = GUICtrlCreateInput("", 10, 50 + ($i * 30), 200, 20) If $i Then GUICtrlSetState(-1, $GUI_HIDE) EndIf Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hUpDown $iCount = GUICtrlRead($hInput) For $i = 0 To $iCount - 1 GUICtrlSetState($aInputs[$i], $GUI_SHOW) Next For $i = $iCount To UBound($aInputs) - 1 GUICtrlSetState($aInputs[$i], $GUI_HIDE) Next EndSwitch WEnd As you can see, all the controls are created initially and then shown/hidden as required. Sneaky but useful. M23 ah! very sneaky. i like. hadnt even thought of that. thanks, i'll give it a shot. Link to comment Share on other sites More sharing options...
bobbintb Posted November 1, 2011 Author Share Posted November 1, 2011 (edited) that worked great but now i have a problem. i added some lines to do the same thing but with a button as well. here is the code: #include <GUIConstantsEx.au3> #include <UpdownConstants.au3> #include <EditConstants.au3> Global $aInputs[15] Global $bInputs[15] $hGUI = GUICreate("Test", 500, 500) $hInput = GUICtrlCreateInput(1, 10, 10, 40, 20, $ES_READONLY) $hUpDown = GUICtrlCreateUpdown(-1, $UDS_WRAP) $bInput = GUICtrlCreateButton("Browse", 230, 50, 65, 20) GUICtrlSetLimit($hUpDown, 15, 1) For $i = 0 To 14 $aInputs[$i] = GUICtrlCreateInput("", 10, 50 + ($i * 30), 200, 20) $bInputs[$i] = GUICtrlCreateButton("Browse", 230, 50 + ($i * 30), 65, 20) If $i Then GUICtrlSetState(-1, $GUI_HIDE) EndIf Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hUpDown $iCount = GUICtrlRead($hInput) For $i = 0 To $iCount - 1 GUICtrlSetState($aInputs[$i], $GUI_SHOW) GUICtrlSetState($bInputs[$i], $GUI_SHOW) Next For $i = $iCount To UBound($aInputs) - 1 GUICtrlSetState($aInputs[$i], $GUI_HIDE) Next For $i = $iCount To UBound($bInputs) - 1 GUICtrlSetState($bInputs[$i], $GUI_HIDE) Next EndSwitch WEnd problem is when i run it i get the full 15 inputs at first unless i remark out the this line: $bInputs[$i] = GUICtrlCreateButton("Browse", 230, 50 + ($i * 30), 65, 20) i dont understand why adding it would affect the other. Edited November 1, 2011 by bobbintb Link to comment Share on other sites More sharing options...
wraithdu Posted November 2, 2011 Share Posted November 2, 2011 GUICtrlSetState(-1, $GUI_HIDE) hides the last created control, in your case the button, in each iteration of the loop. So your input controls are never hidden since they are created before the buttons. Link to comment Share on other sites More sharing options...
bobbintb Posted November 2, 2011 Author Share Posted November 2, 2011 got it! thanks so much. 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