Paedric Posted June 4, 2011 Share Posted June 4, 2011 Hello. I had a single combobox, but it was getting quite long, so I decided to separate them in 4 different combobox, in different tabs. However, I can't manage to write to an ini file the last item that was selected. My goal is that when the user select an item from one of the four combobox, it gets written to the ini file. Here is the part of the code that is supposed to do that. Thanks in advance. expandcollapse popupFunc _FactionGUI() Local $tab, $tab0, $tab0combo Local $tab1, $tab1combo Local $tab2, $tab2combo, $msg Local $tab3, $tab3combo Local $Ok $FactionSelected = IniRead($iniFile, $defaultIniSection, $FactionIniKey, $defaultFaction) ; read the former value from the ini file GUICreate("Select your faction", 800, 600) ; create a dialog box GUISetBkColor(0x00FFFFFF) GUISetFont(9, 300) $tab = GUICtrlCreateTab(10, 10, 500, 300) $tab0 = GUICtrlCreateTabItem("0 Turn Campaigns") $tab0combo = GUICtrlCreateCombo("", 20, 50, 200, 120) $FactionSelectCombo = GUICtrlSetData(-1, "Select a faction|-----------------|Arverni|Belgae|Boii|Carthage|Cimbri|Dacia|Gallaeci|Greek City-States|Macedon|Parthia|Pergamon|Pontus|Ptolemaic Empire|Rome|Sarmatia|Scythia|Seleucid|Sparta", $FactionSelected) $tab1 = GUICtrlCreateTabItem("1 Turn Campaigns") $tab1combo = GUICtrlCreateCombo("", 20, 50, 200, 120) $FactionSelectCombo = GUICtrlSetData(-1, "Select a faction|-----------------|One-turn Campaigns|Rome One Turn", $FactionSelected) $tab2 = GUICtrlCreateTabItem("Swap Factions") $tab2combo = GUICtrlCreateCombo("", 20, 50, 200, 120) $FactionSelectCombo = GUICtrlSetData(-1, "Select a faction|-----------------|Bosphorus|Syracuse", $FactionSelected) $tab3 = GUICtrlCreateTabItem("Battles and Multiplayer") $tab3combo = GUICtrlCreateCombo("", 20, 50, 200, 120) $FactionSelectCombo = GUICtrlSetData(-1, "Select a faction|-----------------|Custom & Historical Battles|Multiplayer", $FactionSelected) GUICtrlCreateTabItem("") ; end tabitem definition $Ok = GUICtrlCreateButton("Ok", 250, 400, 100, 50) ;button to go back to the main GUI GUISetState() ; Write the combobox value to the ini file If IniWrite(@ScriptDir & "\" & $iniFile, $defaultIniSection, $FactionIniKey, $FactionSelectCombo) == 0 Then MsgBox(BitOr(4096, 16), "Could not write to " & $iniFile, 12) Else ;Do nothing EndIf ; Run the GUI until the dialog is closed While $msg <> $Ok $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop ElseIf $msg = $Ok Then GUIDelete() EndIf WEnd EndFunc ; Link to comment Share on other sites More sharing options...
ahmet Posted June 4, 2011 Share Posted June 4, 2011 When selection of ComboBox has been changed use GUICtrlRead() to get the value selected. Link to comment Share on other sites More sharing options...
Paedric Posted June 4, 2011 Author Share Posted June 4, 2011 Works like a charm, thanks a lot. 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