marcoauto Posted November 2, 2011 Posted November 2, 2011 Hi, I need to create some combo in a gui, but the number of them are choose by the user. I have do this (and this work): For $c = 1 To $NumberofColumns for $r = 1 to $NumberofRows $EditControl[$c][$r] = GUICtrlCreateCombo($Control[$c][$r], $spazio_colonne+($larghezza_bottone+$spazio_colonne)*($c-1), $r *$spazio_righe + 10, $larghezza_bottone, $altezza_bottone, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, $elenco) Next GUISetState() but when I read the value of the combo, this value is always 0 For $c = 1 To $NumberofColumns for $r = 1 to $NumberofRows ConsoleWrite(GUICtrlRead($EditControl[$c][$r])) Next Next If I create the combos with variabiles without array (es. $EditControl_1, $EditControl_2, ....) all works, but I can't create them dinamicaly Is there a solution? Grazie marco
Zedna Posted November 2, 2011 Posted November 2, 2011 Try this: For $c = 1 To $NumberofColumns for $r = 1 to $NumberofRows ConsoleWrite($EditControl[$c][$r] & @CRLF) ; ConsoleWrite(GUICtrlRead($EditControl[$c][$r]) & @CRLF) Next Next Also check if content of your array is not changed somewhere in your program. Small reproducing script will be good to get more help. Resources UDF ResourcesEx UDF AutoIt Forum Search
Moderators Melba23 Posted November 2, 2011 Moderators Posted November 2, 2011 marcoauto,Have you checked to make sure that you have sensible values in your $EditControl array? I have no problems at all with this exampel script based on your snippets:#include <GUIConstantsEx.au3> #include <Array.au3> Global $aCombos[4][4] $hGUI = GUICreate("Test", 500, 500) For $i = 1 To 3 For $j = 1 To 3 $aCombos[$i][$j] = GUICtrlCreateCombo("", 10 + ($i * 100), 10 + ($j * 50), 80, 20) GUICtrlSetData(-1, "1|2|3|4|5", "1") Next Next $hButton = GUICtrlCreateButton("Read", 10, 400, 80, 30) GUISetState() _ArrayDisplay($aCombos, "Combo ControlIDs") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hButton For $i = 1 To 3 For $j = 1 To 3 ConsoleWrite(GUICtrlRead($aCombos[$i][$j]) & @CRLF) Next ConsoleWrite(@CRLF) Next EndSwitch WEndM23 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
marcoauto Posted November 2, 2011 Author Posted November 2, 2011 Try this: For $c = 1 To $NumberofColumns for $r = 1 to $NumberofRows ConsoleWrite($EditControl[$c][$r] & @CRLF) ; ConsoleWrite(GUICtrlRead($EditControl[$c][$r]) & @CRLF) Next Next Also check if content of your array is not changed somewhere in your program. Small reproducing script will be good to get more help. I think I'm wrong somewhere in my scripts :-( If I do ConsoleWrite($EditControl[$c][$r] & @CRLF) the result is 46 47 48 49 50 51 52 53 54
Moderators Melba23 Posted November 2, 2011 Moderators Posted November 2, 2011 marcoauto, No, those values look as though they are perfectly sensible ControlIDs for your combos. However, I suggest that you add a similar line to check what ControlIDs are returned when you create the combos on order to check that they are the same. And please post the whole script - we can then see if you have anything else in there which might cause a problem. 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
marcoauto Posted November 2, 2011 Author Posted November 2, 2011 (edited) marcoauto, No, those values look as though they are perfectly sensible ControlIDs for your combos. However, I suggest that you add a similar line to check what ControlIDs are returned when you create the combos on order to check that they are the same. And please post the whole script - we can then see if you have anything else in there which might cause a problem. M23 Ok. This is my whole script. Is not finished. The program read a file and parse it to find the values to use in the combos. Also read a .ini file where are stored the default values and when the program will finished, I'll store the new values. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <Array.au3> #Include <String.au3> #include <EditConstants.au3> Global $hChild, $fChild = False $altezza_bottone = 26 $distanza_sinistra = 10 $larghezza_bottone = 150 $spazio_colonne = 30 $spazio_righe = 36 Global $Control[20][20] Global $ButtonControl[20][20] Global $EditControl[20][20] Global $NumberofColumns = 7 Global $NumberofRows = 6 Global $chars Global $elenco = "" Global $ProgramSettingsFile = @ScriptDir & "\ABC_settings.ini" $Control[1][1] = IniRead($ProgramSettingsFile, "PLAYOUT1", "nome", "Not_Found") $Control[1][2] = IniRead($ProgramSettingsFile, "PLAYOUT1", "IP", "Not_Found") $Control[1][3] = IniRead($ProgramSettingsFile, "PLAYOUT1", "evento1", "Not_Found") $Control[1][4] = IniRead($ProgramSettingsFile, "PLAYOUT1", "evento2", "Not_Found") $Control[1][5] = IniRead($ProgramSettingsFile, "PLAYOUT1", "evento3", "Not_Found") $Control[1][6] = IniRead($ProgramSettingsFile, "PLAYOUT1", "evento4", "Not_Found") $Control[1][7] = IniRead($ProgramSettingsFile, "PLAYOUT1", "evento5", "Not_Found") $Control[1][8] = IniRead($ProgramSettingsFile, "PLAYOUT1", "evento6", "Not_Found") ;~ ConsoleWrite ($P1n & $P1Ip & $P1e1 & $P1e2 & $P1e3 & $P1e4 & $P1e5 & $P1e6) $hGUI = GUICreate("Test", 1290, 300) $hButton = GUICtrlCreateButton("Setup", 10, 10, 80, 30) GUISetState() $file = FileOpen("file.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $chars = FileRead($file) FileClose($file) $array = StringRegExp($chars, '(?)0000000(.*?)(?)001100', 4) for $i = 0 to UBound($array) - 1 $match = $array[$i] $elenco &= ($match[1]) & "|" Next For $c = 1 To $NumberofColumns for $r = 1 to $NumberofRows $ButtonControl[$c][$r] = GUICtrlCreateButton($Control[$c][$r],$spazio_colonne+($larghezza_bottone+$spazio_colonne)*($c-1), $r *$spazio_righe + 10, $larghezza_bottone, $altezza_bottone) GUICtrlSetOnEvent(-1, 'btnsfunc') Next Next GUISetState() Func quit() Exit EndFunc While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE If $fChild Then GUISetState(@SW_ENABLE, $hGUI) GUIDelete($hChild) $fChild = False For $c = 1 To $NumberofColumns for $r = 1 to $NumberofRows ConsoleWrite($EditControl[$c][$r] & @CRLF) ;~ ConsoleWrite(GUICtrlRead($EditControl[$c][$r]) & @CRLF) Next Next Else Exit EndIf Case $hButton GUISetState(@SW_DISABLE, $hGUI) $fChild = True $hChild =GUICreate('Setup',1290,300, -1, -1, -1, -1, $hGUI) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') For $c = 1 To 7 ; numero colonne (playout) for $r = 1 to 6 ; numero righe (eventi: crawl ecc ecc) If $r <= 2 Then $EditControl[$c][$r] = GUICtrlCreateEdit("", $spazio_colonne+($larghezza_bottone+$spazio_colonne)*($c-1), $r *$spazio_righe + 10, $larghezza_bottone, $altezza_bottone, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN)) GUICtrlSetFont(-1, 10) GUICtrlSetLimit(-1, 15) Else $EditControl[$c][$r] = GUICtrlCreateCombo($Control[$c][$r], $spazio_colonne+($larghezza_bottone+$spazio_colonne)*($c-1), $r *$spazio_righe + 10, $larghezza_bottone, $altezza_bottone, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, $elenco) EndIf Next Next GUISetState() EndSwitch WEnd Func btnsfunc() MsgBox(0, '', GUICtrlRead(@GUI_CtrlId)) EndFunc and the file ABC_settings.ini is: [PLAYOUT1] nome = NameCh IP = 192.168.1.111 evento1=test1file evento2=test2file evento3=test3file evento4=test4file evento5=test5file evento6=test6file Thanks marco Edited November 2, 2011 by marcoauto
Moderators Melba23 Posted November 2, 2011 Moderators Posted November 2, 2011 marcoauto, I hope there is more than that to your script - try again! 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
marcoauto Posted November 2, 2011 Author Posted November 2, 2011 marcoauto, I hope there is more than that to your script - try again! M23 :-)To parse the file I use a symbol that the forum can't write I have uploaded the whole script above
Moderators Melba23 Posted November 2, 2011 Moderators Posted November 2, 2011 marcoauto, Look at this section of your script: GUIDelete($hChild) $fChild = False For $c = 1 To $NumberofColumns For $r = 1 To $NumberofRows ConsoleWrite($EditControl[$c][$r] & @CRLF) ;~ ConsoleWrite(GUICtrlRead($EditControl[$c][$r]) & @CRLF) Next Next Now ask yourself in which GUI the Edit controls you are trying to read were created. Then ask yourself where that GUI is now - and you will underatand why you find it difficult to read them. Got it? 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
marcoauto Posted November 2, 2011 Author Posted November 2, 2011 marcoauto, Look at this section of your script: GUIDelete($hChild) $fChild = False For $c = 1 To $NumberofColumns For $r = 1 To $NumberofRows ConsoleWrite($EditControl[$c][$r] & @CRLF) ;~ ConsoleWrite(GUICtrlRead($EditControl[$c][$r]) & @CRLF) Next Next Now ask yourself in which GUI the Edit controls you are trying to read were created. Then ask yourself where that GUI is now - and you will underatand why you find it difficult to read them. Got it? M23 ok, now it works thankyou very much marco
Moderators Melba23 Posted November 3, 2011 Moderators Posted November 3, 2011 A NOTE TO ALL OUR READERS Here is a classic case where the problem had nothing to do with the code snippets in the first post. So please do NOT just post small snippets of the code that you think is going wrong expecting us to determine the cause of your problems - post the complete script. If this is extremely long then YOU need to simplify it so that the problem remains and it does not take us too long to find. Remember too that you wrote the code and know what it is supposed to do - we do not. We are happy to look for problems but please try to comment any complex sections of the code (in English) so we can see what is supposed to be happening. And please think about using Tidy to get the code into a readable format - how some of you manage to read your scripts at all given the chaotic layout of the code beats me! So, if you post mere snippets of code, or a complex uncommented 3000 line script, you are unlikely to get a great deal of help. Please make it easy for us to help you. M23 P.S. marcoauto - this is not directed at you more more than anyone else - you just acted as the catalyst! 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
Zedna Posted November 3, 2011 Posted November 3, 2011 (edited) In other words - short version: To increase chance for getting help provide small reproducing script. Edited November 3, 2011 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
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