Sign in to follow this  
Followers 0
Paedric

Get data from multiple combobox in different tabs

3 posts in this topic

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.

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 

    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   ;

Share this post


Link to post
Share on other sites



When selection of ComboBox has been changed use GUICtrlRead() to get the value selected.

Share this post


Link to post
Share on other sites

Works like a charm, thanks a lot.

Share this post


Link to post
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
Sign in to follow this  
Followers 0