cheeroke Posted September 12, 2017 Share Posted September 12, 2017 Hi, I am trying to get my list displayed in order I press button not in alphabeticall order. I modified example from here Code below. What i want to achieve is to according to pressed button message been displayed in that order. Currently no matter what button in what order I press it is always showing first button NO1 and than button NO2. PLease help. expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() Local $sMESSAGE = "The following buttons have been clicked" GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idAdd = GUICtrlCreateButton("Add1", 64, 32, 75, 25) Local $idAdd2 = GUICtrlCreateButton("Add2", 64, 52, 75, 25) Local $idClear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $sMESSAGE) Local $idClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idAdd GUICtrlSetData($idMylist, " button No1|") Case $idAdd2 GUICtrlSetData($idMylist, " button No2|") Case $idClear GUICtrlSetData($idMylist, "") Case $idClose MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2) Exit EndSwitch WEnd EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 12, 2017 Moderators Share Posted September 12, 2017 cheeroke, As explained in the Help file, GUICtrlCreateList has a number of default styles - one of which is $LBS_SORT. So you need to set the styles excluding that one: Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97, BitOr($WS_BORDER, $WS_VSCROLL)) Reading the Setting Styles tutorial in the Wiki will explain in more detail. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AndroidZero Posted September 13, 2017 Share Posted September 13, 2017 (edited) @Melba23 Good advice with the Setting Styles. I would like to add my solution for his "problem". expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> Example() Func Example() Local $sMESSAGE = "The following buttons have been clicked" GUICreate("My GUI list") ; will create a dialog box that when displayed is centered Local $idAdd = GUICtrlCreateButton("Add1", 64, 32, 75, 25) Local $idAdd2 = GUICtrlCreateButton("Add2", 64, 52, 75, 25) Local $idClear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $idMylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200) ; to limit horizontal scrolling GUICtrlSetData(-1, $sMESSAGE) Local $idClose = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idAdd _GUICtrlListBox_InsertString($idMylist,"Test1",_GUICtrlListBox_GetCount($idMylist)) Case $idAdd2 _GUICtrlListBox_InsertString($idMylist,"Test2",_GUICtrlListBox_GetCount($idMylist)) Case $idClear GUICtrlSetData($idMylist, "") Case $idClose MsgBox($MB_SYSTEMMODAL, "", "the closing button has been clicked", 2) Exit EndSwitch WEnd EndFunc ;==>Example With <GuiListBox.au3> you got more possibilities and variations. Read the wiki files and start with _GUICtrlListBox_GetCount so you will quickly understand how easy you can setup your listbox with those commands. Enjoy =) Edited September 13, 2017 by AndroidZero Link to comment Share on other sites More sharing options...
cheeroke Posted September 14, 2017 Author Share Posted September 14, 2017 (edited) Thanks for your guidance and help. Edited September 14, 2017 by cheeroke 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