rowish Posted July 16, 2013 Share Posted July 16, 2013 (edited) I am kind of lost. I wanted to create this GUI with two list-boxes and an input. Depending of what item the user selects in the first list I would like that a certain set of data would be displayed on the second list. Also the input should concatenate the selected items. My code looks like this at this moment: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $Hostname, $CountryCode, $StoreID, $StoreIDData $MainForm = GUICreate("Hostname", 349, 184) $HostnameInput = GUICtrlCreateInput("", 40, 24, 125, 21) $CountryCodeList = GUICtrlCreateList("", 40, 56, 50, 87) ; 1st Combo GUICtrlSetData(-1, "BGR|ESP|FFM|GBR|ITA|POL|RUS", "FFM") ; Add alternatives and set default $StoreIDList = GUICtrlCreateList("", 104, 56, 60, 87) ; 2nd Combo ; GUICtrlSetData(-1, $StoreIDData) ; Add alternatives and set default GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func StoreData () $CountryCode = GUICtrlRead($CountryCodeList) Select Case $CountryCode = "BGR" $StoreIDData = "10|11|15|16|18|21" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case $CountryCode = "ESP" $StoreIDData = "1|2|3|5|9|12|14|18|22|23" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case $CountryCode = "FFM" $StoreIDData = "0" GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case $CountryCode = "GBR" $StoreIDData = "1|2|3|4|5|6|7|8|9|10|11|12" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case $CountryCode = "ITA" $StoreIDData = "10|11|12|13|14|15|16|17|18" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case $CountryCode = "POL" $StoreIDData = "1|2|5|7|9|10|11|12|14|15|18" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case $CountryCode = "RUS" $StoreIDData = "10|11|12|15|16|19|20|21|22|29|32" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) EndSelect EndFunc While 1 $Msg = GUIGetMsg() ;StoreData($CountryCode) Select Case $Msg = $GUI_EVENT_CLOSE Exit EndSelect Storedata() WEnd Apparently it doesn't work as I wanted since I don't think I am doing the loop the right way. Could anybody help me, please? Thank you. Edited July 16, 2013 by rowish Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 16, 2013 Moderators Share Posted July 16, 2013 rowish,What exactly do you want to appear in the input? The items selected in the CountryCode list or those in the StoreID list? 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...
FireFox Posted July 16, 2013 Share Posted July 16, 2013 Hi, Try this, it can be improved. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListBox.au3> #include <Array.au3> Global $sLastCountryCodeList = "" Global $Hostname, $CountryCode, $StoreID, $StoreIDData $MainForm = GUICreate("Hostname", 349, 184) $HostnameInput = GUICtrlCreateInput("", 40, 24, 125, 21) $CountryCodeList = GUICtrlCreateList("", 40, 56, 50, 87) ; 1st Combo GUICtrlSetData(-1, "BGR|ESP|FFM|GBR|ITA|POL|RUS", "FFM") ; Add alternatives and set default $StoreIDList = GUICtrlCreateList("", 104, 56, 60, 87, $LBS_EXTENDEDSEL) ; 2nd Combo ; GUICtrlSetData(-1, $StoreIDData) ; Add alternatives and set default GUISetState(@SW_SHOW, $MainForm) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func StoreData() $sCountryCodeList = GUICtrlRead($CountryCodeList) If $sCountryCodeList = $sLastCountryCodeList Then Return 0 GUICtrlSetData($StoreIDList, "") Switch $sCountryCodeList Case "BGR" $StoreIDData = "10|11|15|16|18|21" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "ESP" $StoreIDData = "1|2|3|5|9|12|14|18|22|23" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "FFM" $StoreIDData = "0" GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "GBR" $StoreIDData = "1|2|3|4|5|6|7|8|9|10|11|12" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "ITA" $StoreIDData = "10|11|12|13|14|15|16|17|18" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "POL" $StoreIDData = "1|2|5|7|9|10|11|12|14|15|18" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "RUS" $StoreIDData = "10|11|12|15|16|19|20|21|22|29|32" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) EndSwitch $sLastCountryCodeList = $sCountryCodeList EndFunc ;==>StoreData Func WM_COMMAND($hWnd, $iMsg, $iParam, $lParam) Local $iIDFrom = 0, $iCode = 0 $iIDFrom = BitAND($iParam, 0xFFFF) ; Low Word $iCode = BitShift($iParam, 16) ; Hi Word Switch $iIDFrom Case $StoreIDList Switch $iCode Case $LBN_SELCHANGE Local $aData = _GUICtrlListBox_GetSelItemsText($StoreIDList) GUICtrlSetData($HostnameInput, _ArrayToString($aData, ", ", 1)) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch StoreData() Sleep(10) WEnd rowish 1 Link to comment Share on other sites More sharing options...
rowish Posted July 17, 2013 Author Share Posted July 17, 2013 rowish, What exactly do you want to appear in the input? The items selected in the CountryCode list or those in the StoreID list? M23 Hi Melba, I wanted to concatenate the selected items in both lists and use the string further. However the main issue was updating the second list after changing selection in the first one. FireFox shared the solution below. Hi, Try this, it can be improved. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIListBox.au3> #include <Array.au3> Global $sLastCountryCodeList = "" Global $Hostname, $CountryCode, $StoreID, $StoreIDData $MainForm = GUICreate("Hostname", 349, 184) $HostnameInput = GUICtrlCreateInput("", 40, 24, 125, 21) $CountryCodeList = GUICtrlCreateList("", 40, 56, 50, 87) ; 1st Combo GUICtrlSetData(-1, "BGR|ESP|FFM|GBR|ITA|POL|RUS", "FFM") ; Add alternatives and set default $StoreIDList = GUICtrlCreateList("", 104, 56, 60, 87, $LBS_EXTENDEDSEL) ; 2nd Combo ; GUICtrlSetData(-1, $StoreIDData) ; Add alternatives and set default GUISetState(@SW_SHOW, $MainForm) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func StoreData() $sCountryCodeList = GUICtrlRead($CountryCodeList) If $sCountryCodeList = $sLastCountryCodeList Then Return 0 GUICtrlSetData($StoreIDList, "") Switch $sCountryCodeList Case "BGR" $StoreIDData = "10|11|15|16|18|21" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "ESP" $StoreIDData = "1|2|3|5|9|12|14|18|22|23" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "FFM" $StoreIDData = "0" GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "GBR" $StoreIDData = "1|2|3|4|5|6|7|8|9|10|11|12" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "ITA" $StoreIDData = "10|11|12|13|14|15|16|17|18" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "POL" $StoreIDData = "1|2|5|7|9|10|11|12|14|15|18" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) Case "RUS" $StoreIDData = "10|11|12|15|16|19|20|21|22|29|32" GUICtrlSetData($StoreIDList, $StoreIDData) GUICtrlSetData($HostnameInput, $CountryCode & GUICtrlRead($StoreIDList)) EndSwitch $sLastCountryCodeList = $sCountryCodeList EndFunc ;==>StoreData Func WM_COMMAND($hWnd, $iMsg, $iParam, $lParam) Local $iIDFrom = 0, $iCode = 0 $iIDFrom = BitAND($iParam, 0xFFFF) ; Low Word $iCode = BitShift($iParam, 16) ; Hi Word Switch $iIDFrom Case $StoreIDList Switch $iCode Case $LBN_SELCHANGE Local $aData = _GUICtrlListBox_GetSelItemsText($StoreIDList) GUICtrlSetData($HostnameInput, _ArrayToString($aData, ", ", 1)) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch StoreData() Sleep(10) WEnd That's what I've been looking to in the first place. Thank you so much both of you. Link to comment Share on other sites More sharing options...
rowish Posted August 30, 2013 Author Share Posted August 30, 2013 I'm returning after a while, because after numerous attempts I couldn't make it work the way I wanted. I have to admit that the code in WM_COMMAND function is too advanced for my knowledge. However, the $LBS_EXTENDEDSEL parameter of GUICtrlCreateList seems to limit the number of items displayed in the second listbox - there is no scrolling feature. If I eliminate it, the items are not displayed in the order they are written in the code. Also, I couldn't figure out how to add CountryCode selected item alongside StoreID in the input. Link to comment Share on other sites More sharing options...
FireFox Posted August 30, 2013 Share Posted August 30, 2013 Use a listview with a single column if the simple list limited. Br, FireFox. 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