Sign in to follow this  
Followers 0
LinuxRabbit

Need help with updating combo boxes

3 posts in this topic

I have been trying to solve this problem for a couple of hours. Been searching the forms and the help file, but alas nothing seems to work. I am new to autoit so please be gentle.

I have 2 combo boxes that I use in an rdp program that I wrote to help with all the servers I have to remote to daily.

Global $hsrvs = IniReadSection($ini, "hsrvs")
Global $lsrvs = IniReadSection($ini, "lsrvs")


#Region ### START Koda GUI section ### Form=C:\scripts\test.kxf
$gui = GUICreate("", 264, 24, 780, 0, BitOR($WS_BORDER,$WS_Popup), BitOR($WS_EX_TOPMOST,$WS_EX_WINDOWEDGE))
GUICtrlCreateLabel("", 0, 0, 10, 23, $WS_GROUP, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x0000FF)
$connect = GUICtrlCreateButton("connect", 191, 0, 26, 23, $BS_BITMAP)
GUICtrlSetOnEvent(-1, "connectclick")
GUICtrlSetImage(-1, @ScriptDir & "\connect.bmp", -1)
GUICtrlSetTip(-1, "Connect to the selected server")
$exit = GUICtrlCreateButton("exit", 220, 0, 20, 23, BitOR($BS_BITMAP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "exitclick")
GUICtrlSetImage(-1, @ScriptDir & "\exit.bmp", -1)
GUICtrlSetTip(-1, "Exit Usapsys RDP Dock")
$edit = GUICtrlCreateButton("edit", 242, 0, 20, 23, BitOR($BS_BITMAP,$WS_CLIPSIBLINGS))
GUICtrlSetOnEvent(-1, "editclick")
GUICtrlSetImage(-1, @ScriptDir & "\edit.bmp", -1)
GUICtrlSetTip(-1, "Edit the variables in the ini file")
$dboxh = GUICtrlCreateCombo("", 10, 0, 90, 25)
For $i = 1 To $hsrvs[0][0]
    GUICtrlSetData($dboxh, $hsrvs[$i][1], "")
Next
$dBoxl = GUICtrlCreateCombo("", 100, 0, 90, 25)
For $i = 1 To $lsrvs[0][0]
    GUICtrlSetData($dBoxl, $lsrvs[$i][1], "")
Next
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

This is my gui with the combo boxes. I use an ini file to keep everything orderly and so that other people at my office could use the program. My only problem is that when you go to edit the ini file my combo boxes are not being updated with the new information in the array.

Func editclick()
    ShellExecuteWait("server.ini", "", @ScriptDir, "edit")
    _GUICtrlComboBox_ResetContent($comboh)
    _GUICtrlComboBox_ResetContent($combol)
    _GUICtrlComboBox_BeginUpdate($comboh)
    _GUICtrlComboBox_BeginUpdate($combol)
    For $i = 1 To $hsrvs[0][0]
        GUICtrlSetData($dboxh, $hsrvs[$i][1], "")
    Next
    For $i = 1 To $lsrvs[0][0]
        GUICtrlSetData($dboxh, $lsrvs[$i][1], "")   
    Next
    _GUICtrlComboBox_EndUpdate($comboh)
    _GUICtrlComboBox_EndUpdate($combol)
    _GUICtrlComboBox_SetEditText($dboxh, "")
    _GUICtrlComboBox_SetEditText($dBoxl, "")
EndFunc

This is my function for editing the ini file. Could someone please help.

Share this post


Link to post
Share on other sites



LinuxRabbit,

You have to reread the ini file sections after you have modified the file - otherwise the arrays you created to hold the contents will not change. So add a couple of lines to do that in your editclick function:

Func editclick()
    ShellExecuteWait("server.ini", "", @ScriptDir, "edit")
    _GUICtrlComboBox_ResetContent($dboxh)
    _GUICtrlComboBox_ResetContent($dBoxl)
    _GUICtrlComboBox_BeginUpdate($dboxh)
    _GUICtrlComboBox_BeginUpdate($dBoxl)

    $hsrvs = IniReadSection($ini, "hsrvs") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $lsrvs = IniReadSection($ini, "lsrvs") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<

    For $i = 1 To $hsrvs[0][0]
        GUICtrlSetData($dboxh, $hsrvs[$i][1], "")
    Next
    For $i = 1 To $lsrvs[0][0]
        GUICtrlSetData($dboxl, $lsrvs[$i][1], "")
    Next
    _GUICtrlComboBox_EndUpdate($dboxh)
    _GUICtrlComboBox_EndUpdate($dBoxl)
    _GUICtrlComboBox_SetEditText($dboxh, "")
    _GUICtrlComboBox_SetEditText($dBoxl, "")
EndFunc

I have also amended the names of the combos so that they match those in the main script - you had a mixture of $combo, $combol, $dboxh, $dBoxl which was not helping either. >_<

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Melba you are awesome! Looking back at the code I see what I did wrong. Thank you for pointing that out.

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