Jump to content

Get data from multiple combobox in different tabs

Recommended Posts


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.

Func _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 

    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

        ; 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)
        ;Do nothing

    ; Run the GUI until the dialog is closed
    While $msg <> $Ok
        $msg = GUIGetMsg()
        If $msg = $GUI_EVENT_CLOSE Then 
        ElseIf $msg = $Ok Then 
EndFunc   ;
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...