maniootek Posted September 30, 2014 Share Posted September 30, 2014 Hi. Any chance that function GUICtrlCreateListViewItem() create new entry to ListView but any new item will go on the top of the list? Link to comment Share on other sites More sharing options...
Radiance Posted September 30, 2014 Share Posted September 30, 2014 (edited) Hey, there's a style in ListviewConstants.au3 called $LVS_SORTDESCENDING (0x0020). This should be exactly what you need. Edited September 30, 2014 by Radiance Link to comment Share on other sites More sharing options...
maniootek Posted September 30, 2014 Author Share Posted September 30, 2014 any chance to change it in script without modify any au3 file? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2014 Moderators Share Posted September 30, 2014 Radiance,That style just sorts the ListView items, nothing to do with insertion order. maniootek,If you use my GUIListViewEx UDF - look in my sig for the link you can do it pretty easily: expandcollapse popup#include <GUIConstantsEx.au3> #include "GUIListViewEx.au3" $iCount = 4 $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 1|Col 2", 10, 10, 250, 200) For $i = 0 To $iCount GUICtrlCreateListViewItem("0-" & $i & "|1-" & $i, $cLV) Next $cInsert = GUICtrlCreateButton("Insert", 10, 450, 80, 30) GUISetState() ; Read ListView content $aList = _GUIListViewEx_ReadToArray($cLV) ; Initialise ListView $iLV_Index = _GUIListViewEx_Init($cLV, $aList) ; Register ListView messages _GUIListViewEx_MsgRegister() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cInsert ; Click on top item _GUICtrlListView_ClickItem($cLV, 0) ; Just to distinguish the new items $iCount += 1 ; Indert below selected item _GUIListViewEx_Insert("0-" & $iCount & "|1-" & $iCount) ; And move up one place _GUIListViewEx_Up() ; Cancel the automatic selection of the new item _GUICtrlListView_SetItemSelected($cLV, 0, False) EndSwitch WEndIt could get a bit flicker if you have a lot of rows, but that is a price you will have to pay. 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...
Radiance Posted September 30, 2014 Share Posted September 30, 2014 From what I know you can't manipulate GUI controls from outside a running script. Link to comment Share on other sites More sharing options...
Radiance Posted September 30, 2014 Share Posted September 30, 2014 Radiance, That style just sorts the ListView items, nothing to do with insertion order. When I use the style every new item goes straight to the top of the list. $GUI = GUICreate("Test", 250, 200) $List = GUICtrlCreateListView(" ",0 ,0 ,250, 200, 0x0020) GUISetState() Sleep(1000) $Red = GUICtrlCreateListViewItem("Text", $List) GUICtrlSetbkColor(-1, 0xFFBEBE) Sleep(1000) $Green = GUICtrlCreateListViewItem("Text", $List) GUICtrlSetbkColor(-1, 0xBEFFBE) Sleep(1000) $Yellow = GUICtrlCreateListViewItem("Text", $List) GUICtrlSetbkColor(-1, 0xF7F7B0) Sleep(2000) Care to explain? Link to comment Share on other sites More sharing options...
maniootek Posted September 30, 2014 Author Share Posted September 30, 2014 When I use the style every new item goes straight to the top of the list. $GUI = GUICreate("Test", 250, 200) $List = GUICtrlCreateListView(" ",0 ,0 ,250, 200, 0x0020) GUISetState() Sleep(1000) $Red = GUICtrlCreateListViewItem("Text", $List) GUICtrlSetbkColor(-1, 0xFFBEBE) Sleep(1000) $Green = GUICtrlCreateListViewItem("Text", $List) GUICtrlSetbkColor(-1, 0xBEFFBE) Sleep(1000) $Yellow = GUICtrlCreateListViewItem("Text", $List) GUICtrlSetbkColor(-1, 0xF7F7B0) Sleep(2000) Care to explain? works! thanks! I just also noticed that this option is described under this manual: https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateListView.htm in example you can see line: Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) ;,$LVS_SORTDESCENDING) so you can just unquote that option $LVS_SORTDESCENDING to get this: Local $idListview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150, $LVS_SORTDESCENDING) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2014 Moderators Share Posted September 30, 2014 Radiance, Care to explain?Delighted. You are inserting the same text each time so there is no "alphabetical order" to sort. AutoIt then looks for the item parameter value - which for native-created items is the ControlID. As these increase in value each time you create an item, the latest (and highest value) item goes to the top. But if you have real differences in the text you add, the AutoIt sorts on that - as you can see here:#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> $GUI = GUICreate("Test", 250, 200) $List = GUICtrlCreateListView(" ",0 ,0 ,250, 200, $LVS_SORTDESCENDING) GUISetState() Sleep(1000) GUICtrlCreateListViewItem("Text Z", $List) Sleep(1000) GUICtrlCreateListViewItem("Text A", $List) Sleep(1000) GUICtrlCreateListViewItem("Text Y", $List) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndAll clear? 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...
Moderators Melba23 Posted September 30, 2014 Moderators Share Posted September 30, 2014 maniootek,I am afraid the answer is not the one you have marked - please read my post immediately above. 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...
maniootek Posted September 30, 2014 Author Share Posted September 30, 2014 I have noticed that ListView is sorted correctly now (SORTDESCENDING) but index of items are not changed. Example: I have three items in the ListView and the item on the top has index "1" when the other on the middle has "2" and bottom "3" but item with index "1" is displayed on the bottom which is not correct for me Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 30, 2014 Moderators Share Posted September 30, 2014 maniootek,Please post the code you use - merely stating (not very clearly) the end result is not a lot of help. Basically, Radiance's suggestion is NOT the answer to inserting at the top unless you keep adding items that are always alphabetically higher valued than everything already in place. 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...
Radiance Posted October 1, 2014 Share Posted October 1, 2014 All clear? Yes, thanks! I'm using this and basically never had a case (yet) where this would have stood out. Apologies for the wrong answer, I guess I have to rewrite some scripts now. 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