Goodkeeper Posted August 30, 2012 Share Posted August 30, 2012 Hi, What is the correct or best way to control elements with combobox? I'm checking the state of combobox with 'while 1' and then hiding/showing the elements manually, but I know this can't be the correct way to do it as it's clumsy and breaks easily... so what is? How do you guys change the elements with combobox? Please, answer in detail, as I'm very new to autoit. Thanks Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2012 Moderators Share Posted August 30, 2012 Goodkeeper,Can you explain a little more clearly what you are trying do? What exactly triggers the "hiding/showing" of the elements? You can reset the contents of a combo with GUICtrlSetData - you just have to start the string with the separator character (default is "|"). 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...
Goodkeeper Posted August 30, 2012 Author Share Posted August 30, 2012 First of all I'm not sure if I should be hiding/showing guielements, but as I don't know other way...Idea: I have two elements: combobox & inputboxI've 3 different options in combobox: text1|text2|text3 and by selecting one of these options, the content of inputbox should change. For an eg "This is an inputbox for combo option text1" "this is for text2" and so on.. and all this should be done so that I can later in my script get the data of inputbox under combobox option "x". Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2012 Moderators Share Posted August 30, 2012 Goodkeeper, Is this heading in the right direction? #include <GUIConstantsEx.au3> #include <Array.au3> Local $aList[3][2] = [["text1", "This is an inputbox for combo option text1"], _ ["text2", "This is an inputbox for combo option text2"], _ ["text3", "This is an inputbox for combo option text3"]] $sCombo_List = "" For $i = 0 To UBound($aList) - 1 $sCombo_List &= "|" & $aList[$i][0] Next $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 250, 20) GUICtrlSetData(-1, $sCombo_List) $cInput = GUICtrlCreateInput("", 10, 100, 250, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo $sSel = GUICtrlRead($cCombo) $iIndex = _ArraySearch($aList, $sSel) If $iIndex <> -1 Then GUICtrlSetData($cInput, $aList[$iIndex][1]) EndIf EndSwitch WEnd If so, then do I understand that you want to replace the combo elements in some way by entering data into the input? 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...
Goodkeeper Posted August 30, 2012 Author Share Posted August 30, 2012 Yes, your example is very near to what I mean to achieve. The only thing missing is that it doesn't save new inputbox values.For an eg. when I select "text2" and change the input value from "This is an inputbox for combo option text2" to "hello world" it doesn't save the new value (when I come back to text2, its back to the original text)... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2012 Moderators Share Posted August 30, 2012 Goodkeeper,How do you want to trigger the change? A button? Pressing {ENTER} when the new text is finished? 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...
Goodkeeper Posted August 30, 2012 Author Share Posted August 30, 2012 Actually I would prefer if I shouldn't have to press anything. When I type "hello world", change to text1 and back to 2 it would still be there. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2012 Moderators Share Posted August 30, 2012 Goodkeeper, That exercised the little grey cells! expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <Array.au3> Local $aList[3] = ["This is an inputbox for combo option text1", _ "This is an inputbox for combo option text2", _ "This is an inputbox for combo option text3"] $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 250, 20) _Fill_Combo("") $cInput = GUICtrlCreateInput("", 10, 100, 250, 20) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo $sSel = GUICtrlRead($cCombo) $iIndex = _ArraySearch($aList, $sSel) If $iIndex <> -1 Then GUICtrlSetData($cInput, $aList[$iIndex]) EndIf EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $iCode Case $EN_CHANGE Switch $iIDFrom Case $cInput $sSel = GUICtrlRead($cCombo) $iIndex = _ArraySearch($aList, $sSel) If $iIndex <> -1 Then $aList[$iIndex] = GUICtrlRead($cInput) EndIf _Fill_Combo(GUICtrlRead($cInput)) EndSwitch EndSwitch EndFunc ;==>WM_COMMAND Func _Fill_Combo($sNew_Item) Local $sCombo_List = "" For $i = 0 To UBound($aList) - 1 $sCombo_List &= "|" & $aList[$i] Next GUICtrlSetData($cCombo, $sCombo_List, $sNew_Item) EndFunc ;==>_Fill_Combo How is that? Please ask if you have any questions. 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...
Goodkeeper Posted August 30, 2012 Author Share Posted August 30, 2012 haha, didn't except this to be so complicated Your code is again a bit closer to what I'm searching for, but now the actual combobox's option texts are changing too! There should be text1, text2, text3 -options and only the input box should change value Think this as a tab: You have different tabs with different content. Changing element values inside tabs does not affect to other tabs' elements and so on. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2012 Moderators Share Posted August 30, 2012 Goodkeeper, I think I have it this time - back to a 2D array: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <Array.au3> Local $aList[3][2] = [["text1", "This is an inputbox for combo option text1"], _ ["text2", "This is an inputbox for combo option text2"], _ ["text3", "This is an inputbox for combo option text3"]] $hGUI = GUICreate("Test", 500, 500) $cCombo = GUICtrlCreateCombo("", 10, 10, 250, 20) Local $sCombo_List = "" For $i = 0 To UBound($aList) - 1 $sCombo_List &= "|" & $aList[$i][0] Next GUICtrlSetData($cCombo, $sCombo_List) $cInput = GUICtrlCreateInput("", 10, 100, 250, 20) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cCombo $sSel = GUICtrlRead($cCombo) $iIndex = _ArraySearch($aList, $sSel) If $iIndex <> -1 Then GUICtrlSetData($cInput, $aList[$iIndex][1]) EndIf EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $iCode Case $EN_CHANGE Switch $iIDFrom Case $cInput $sSel = GUICtrlRead($cCombo) $iIndex = _ArraySearch($aList, $sSel) If $iIndex <> -1 Then $aList[$iIndex][1] = GUICtrlRead($cInput) EndIf EndSwitch EndSwitch EndFunc ;==>WM_COMMAND How is that? 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...
Goodkeeper Posted August 30, 2012 Author Share Posted August 30, 2012 Yup, you nailed it. That's exactly what I was looking for. Thanks for your help, big time. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 30, 2012 Moderators Share Posted August 30, 2012 Goodkeeper, Glad we got there in the end. But you might want to brush up your explaining skills a bit - I was in the dark as to what you were actually after for most of this thread! 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