fenix114 Posted March 14, 2014 Share Posted March 14, 2014 I got this code created with help of melba a few days ago, if you run this code and press "addname" a new name will appear in "list1" my question is if a new string can be added after the last name instead of adding a new name before the first name (in this case creating a new name after "example9" instead of creating a new name before "example1") #include <GUIConstantsEx.au3> #include <GUIListBox.au3> Global $iIndex = 0 $Form1 = GUICreate("Form1", 487, 437, 368, 124) $List1 = GUICtrlCreateList("", 136, 24, 345, 396) $Button1 = GUICtrlCreateButton("start function", 8, 24, 113, 41) $addname = GUICtrlCreateInput("(add new name)", 16, 112, 113, 21) $Button2 = GUICtrlCreateButton("add new name", 16, 144, 113, 25) GUISetState(@SW_SHOW) GUICtrlSetData($List1, "example1|example2|example3|example4|example5|example6|example7|example8|example9") _GUICtrlListBox_SetCurSel($List1, $iIndex) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button2 _GUICtrlListBox_AddString($List1, GUICtrlRead($addname)) Case $Button1 ; Function MsgBox("", "Function", "Running on: " & GUICtrlRead($List1)) ; Move on $iIndex += 1 If $iIndex = _GUICtrlListBox_GetCount($List1) Then $iIndex = 0 _GUICtrlListBox_SetCurSel($List1, $iIndex) EndSwitch WEnd Link to comment Share on other sites More sharing options...
FireFox Posted March 14, 2014 Share Posted March 14, 2014 (edited) Hi, From the MSDN : If the list box does not have the LBS_SORT style, the string is added to the end of the list. Otherwise, the string is inserted into the list and the list is sorted. As the default style for the list is : $LBS_SORT, $WS_BORDER, $WS_VSCROLL, you need to remove the $LBS_SORT style. #include <WindowsConstants.au3> ... $List1 = GUICtrlCreateList("", 136, 24, 345, 396, BitOR($WS_BORDER, $WS_VSCROLL)) ... _ Br, FireFox. Edited March 14, 2014 by FireFox Link to comment Share on other sites More sharing options...
fenix114 Posted March 14, 2014 Author Share Posted March 14, 2014 thank you very much Link to comment Share on other sites More sharing options...
fenix114 Posted March 14, 2014 Author Share Posted March 14, 2014 I also want the list to select the next automaticly ( I know how to do that ) but I want it to stop when it selects the last name, something like: stop function(function= select next one) when ""example9" is selected in list1 but i dont know how to practice this. Link to comment Share on other sites More sharing options...
FireFox Posted March 14, 2014 Share Posted March 14, 2014 (edited) Maybe the GUICtrlRead function on the list. Or : If _GUICtrlListBox_GetCount($List1) -1 == _GUICtrlListBox_GetCurSel($List1) Then ... Edited March 14, 2014 by 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