Omega19 Posted January 21, 2016 Posted January 21, 2016 M23, okay, thank you very much. I'll think about this _GUIListViewEx_Drag() solution, but as you suspected, I guess I'll use the Stop/Restart Button. Tanks a lot! Omega19
Omega19 Posted January 22, 2016 Posted January 22, 2016 I know this UDF is based on user interaction with the ListViews. This is quite good for what I need, but through I more often add or delete items automaticly (without user action), I made two new functions. These are just slimmed versions of what Melba23 did, but now they fit my needs. If anyone has a use for this, feel free expandcollapse popup; #FUNCTION# ========================================================================================================= ; Name...........: _GUIListViewEx_DeleteSpecified ; Description ...: Deletes specified item in the specified ListView ; Syntax.........: _GUIListViewEx_DeleteSpecified() ; Parameters ....: $iLVEx - index of the ListViewEx element as returned by _GUIListViewEx_Init ; $iRow - the index (zero based) of the rows you want to delete, default: 0 (first row) ; Requirement(s).: v3.3 + ; Return values .: Success: Array of specified ListView ; Failure: If $iLVEx is bad then returns "" and sets @error to 1 ; Author ........: Melba23 ; Modified ......: Omega19 ; Remarks .......: - ; Example........: No ;===================================================================================================================== Func _GUIListViewEx_DeleteSpecified($iLVEx, $iRow = 0) ; If $iLVEx is wrong then return If $iLVEx = 0 Or $iLVEx >= UBound($aGLVEx_Data) Then Return SetError(1, 0, "") ; Load ListView details $hGLVEx_SrcHandle = $aGLVEx_Data[$iLVEx][0] $cGLVEx_SrcID = $aGLVEx_Data[$iLVEx][1] Local $fCheckBox = $aGLVEx_Data[$iLVEx][6] ; Copy array for manipulation $aGLVEx_SrcArray = $aGLVEx_Data[$iLVEx][2] ; Create Local array for checkboxes (if no checkboxes makes no difference) Local $aCheck_Array[UBound($aGLVEx_SrcArray)] For $i = 1 To UBound($aCheck_Array) - 1 $aCheck_Array[$i] = _GUICtrlListView_GetItemChecked($hGLVEx_SrcHandle, $i - 1) Next ; Delete element from array _GUIListViewEx_Array_Delete($aGLVEx_SrcArray, $iRow + 1) _GUIListViewEx_Array_Delete($aCheck_Array, $iRow + 1) ; Rewrite ListView _GUIListViewEx_ReWriteLV($hGLVEx_SrcHandle, $aGLVEx_SrcArray, $aCheck_Array, $iLVEx, $fCheckBox) ; Store amended array $aGLVEx_Data[$iLVEx][2] = $aGLVEx_SrcArray ; Delete copied array $aGLVEx_SrcArray = 0 ; Return amended array Return _GUIListViewEx_ReturnArray($iLVEx) EndFunc ;==>_GUIListViewEx_DeleteSpecified ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIListViewEx_InsertSpecified ; Description ...: Inserts data just below selected item in specified ListView - if no selection, data added at end ; Syntax.........: _GUIListViewEx_InsertSpecified($iLVEx, $vData[, $fMultiRow = False[, $bInsertAtEnd = True[, $fRetainWidth = False]]]) ; Parameters ....: $iLVEx - index of the ListViewEx element as returned by _GUIListViewEx_Init ; $vData - Data to insert, can be in array or delimited string format ; $fMultiRow - If $vData is a 1D array: ; - False (default) - elements added as subitems to a single row ; - True - elements added as rows containing a single item ; Ignored if $vData is a single item or a 2D array ; $bInsertAtEnd - True (default) - elements will be added at the end ; False = does not force the elements to be added at the end ; $fRetainWidth - True = native ListView column width is retained on insert ; False = native ListView columns expand to fit data (default) ; Requirement(s).: v3.3 + ; Return values .: Success: Array of current ListView with count in [0] element ; Failure: If $iLVEx is bad then returns "" and sets @error to 1 ; Author ........: Melba23 ; Modified ......: Omega19 ; Remarks .......: - New data is inserted after the selected item. If no item is selected or $bInsertAtEnd is set True then the data is added at ; the end of the ListView. If multiple items are selected, the data is inserted after the first ; - $vData can be passed in string or array format - it is automatically transformed if required ; - $vData as single item - item added to all columns ; - $vData as 1D array - see $fMultiRow above ; - $vData as 2D array - added as rows/columns ; - Native ListViews automatically expand subitem columns to fit inserted data. Setting the ; $fRetainWidth parameter resets the original width after insertion ; Example........: No ;===================================================================================================================== Func _GUIListViewEx_InsertSpecified($iLVEx, $vData, $fMultiRow = False, $bInsertAtEnd = True, $fRetainWidth = False) Local $vInsert ; If $iLVEx false then return If $iLVEx = 0 Or $iLVEx >= UBound($aGLVEx_Data) Then Return SetError(1, 0, "") ; Load specified ListView details $hGLVEx_SrcHandle = $aGLVEx_Data[$iLVEx][0] $cGLVEx_SrcID = $aGLVEx_Data[$iLVEx][1] Local $fCheckBox = $aGLVEx_Data[$iLVEx][6] ; Copy array for manipulation $aGLVEx_SrcArray = $aGLVEx_Data[$iLVEx][2] ; Create Local array for checkboxes (if no checkboxes makes no difference) Local $aCheck_Array[UBound($aGLVEx_SrcArray)] For $i = 1 To UBound($aCheck_Array) - 1 $aCheck_Array[$i] = _GUICtrlListView_GetItemChecked($hGLVEx_SrcHandle, $i - 1) Next ; Get selected item in ListView Local $iIndex = _GUICtrlListView_GetSelectedIndices($hGLVEx_SrcHandle) If $bInsertAtEnd Then $iIndex = "" Local $iInsert_Index = $iIndex ; If no selection If $iIndex = "" Then $iInsert_Index = -1 ; Check for multiple selections If StringInStr($iIndex, "|") Then Local $aIndex = StringSplit($iIndex, "|") ; Use first selection $iIndex = $aIndex[1] ; Cancel all other selections For $i = 2 To $aIndex[0] _GUICtrlListView_SetItemSelected($hGLVEx_SrcHandle, $aIndex[$i], False) Next EndIf Local $aCol_Width, $iColCount ; If width retain required and native ListView If $fRetainWidth And $cGLVEx_SrcID Then $iColCount = _GUICtrlListView_GetColumnCount($hGLVEx_SrcHandle) ; Store column widths Local $aCol_Width[$iColCount] For $i = 1 To $iColCount - 1 $aCol_Width[$i] = _GUICtrlListView_GetColumnWidth($hGLVEx_SrcHandle, $i) Next EndIf ; If empty array insert at 0 If $aGLVEx_SrcArray[0][0] = 0 Then $iInsert_Index = 0 ; Get data into array format for insert If IsArray($vData) Then $vInsert = $vData Else Local $aData = StringSplit($vData, $sGLVEx_SepChar) Switch $aData[0] Case 1 $vInsert = $aData[1] Case Else Local $vInsert[$aData[0]] For $i = 0 To $aData[0] - 1 $vInsert[$i] = $aData[$i + 1] Next EndSwitch EndIf ; Insert data into arrays If $iIndex = "" Then _GUIListViewEx_Array_Add($aGLVEx_SrcArray, $vInsert, $fMultiRow) _GUIListViewEx_Array_Add($aCheck_Array, $vInsert, $fMultiRow) Else _GUIListViewEx_Array_Insert($aGLVEx_SrcArray, $iInsert_Index + 2, $vInsert, $fMultiRow) _GUIListViewEx_Array_Insert($aCheck_Array, $iInsert_Index + 2, $vInsert, $fMultiRow) EndIf ; Rewrite ListView _GUIListViewEx_ReWriteLV($hGLVEx_SrcHandle, $aGLVEx_SrcArray, $aCheck_Array, $iLVEx, $fCheckBox) ; Set highlight #cs If $iIndex = "" Then _GUIListViewEx_Highlight($hGLVEx_SrcHandle, $cGLVEx_SrcID, _GUICtrlListView_GetItemCount($hGLVEx_SrcHandle) - 1) Else _GUIListViewEx_Highlight($hGLVEx_SrcHandle, $cGLVEx_SrcID, $iInsert_Index + 1) EndIf #ce ; Restore column widths if required If $fRetainWidth And $cGLVEx_SrcID Then For $i = 1 To $iColCount - 1 $aCol_Width[$i] = _GUICtrlListView_SetColumnWidth($hGLVEx_SrcHandle, $i, $aCol_Width[$i]) Next EndIf ; Store amended array $aGLVEx_Data[$iLVEx][2] = $aGLVEx_SrcArray ; Delete copied array $aGLVEx_SrcArray = 0 ; Return amended array Return _GUIListViewEx_ReturnArray($iLVEx) EndFunc ;==>_GUIListViewEx_InsertSpecified For anyone wondering if you can now simultaniously drag/drop and change the ListView in the background using the new funktions (because you don't need to set any ListView active): No. Everything you can do with this functions you could have done with the ones Melba23 made. These just give simpler access, if you want to insert/delete without user actions. Best regards, Omega19 argumentum 1
Moderators Melba23 Posted January 26, 2016 Author Moderators Posted January 26, 2016 (edited) Omega19, I have added a couple of functions to this Beta version of the UDF - _GUIListViewEx_InsertSpec & _GUIListViewEx_DeleteSpec - which do what you require. Please can you test and see if they meet your requirements: <snip> You will notice quite a few other new functions in there as well - you are not the only one asking for added functionalities! M23 Edited February 1, 2016 by Melba23 Beta code removed 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
Omega19 Posted February 1, 2016 Posted February 1, 2016 M23, I've downloaded and tested the Beta version functions _InsertSpec & _DeleteSpec, and this is what I got: _GUIListViewEx_InsertSpec($iLVEx,-1,$sValue) is what I needed. It just adds the value to the specified LVEx. I don't actually care where the data is added (top, bottom, under highlited, over highlited...). It leaves one of the items inside of the LV highlighted (=selected), which isn't needed but also isn't disturbing. _GUIListViewEx_DeleteSpec($iLVEx,$sRange) is not exactly what I thought it was. What I wanted is something where I can just delete the first item. Maybe I used $sRange wrong (I tried -1,0 and 1) but somehow the deleted item is affected on the highlighted (or selected) item. -1 deletes the selected item(s), as written in the description. 0 deletes also the selected Item. 1 deletes the Item right under the selected one, if there is only one Item (which is selected), it does nothing. My background processes shouldn't care about selected items. They just sometimes add items and sometimes remove the first item of a LV. Omega19
Moderators Melba23 Posted February 1, 2016 Author Moderators Posted February 1, 2016 (edited) Omega19, Quote My background processes shouldn't care about selected items. They just sometimes add items and sometimes remove the first item of a LV You might only be interested in that, but I want the UDF to be rather more flexible. I found the problem in _GUIListViewEx_DeleteSpec - it now works as follows when I test: "-1" - final row deleted "" - selected row deleted Range - range of rows deleted Please give this Beta code a try and see if it works for you too. M23 Edited September 27, 2017 by Melba23 Wrong button, too soon 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
Arcus Posted February 2, 2016 Posted February 2, 2016 Melba, I've been trying to get my images to "reload" when being moved around through your UDF. The problem is when I drag and drop to reorder something, all of the images change to what's first on the image list and stay that way unless I exit the GUI and reenter it. Afterwards the images are fine but reordering something causes the issue to occur again. If it helps, I'm using the #AutoIt3Wrapper_Res_File_Add feature to embed my bitmaps into the program. Thanks. Func Change_Order() $listentries[$entries] $image[$entries] $ListGUI = GUICreate("Change Order", 400, 500, -1, -1) $Done = GUICtrlCreateButton("Done", 157, 471, 86, 25) $listview = _GUICtrlListView_Create($ListGUI, "", 2, 2, 396, 465) _GUICtrlListView_AddColumn($listview, "Entries", 375) _GUICtrlListView_Scroll($listview, 0, 0) $hImage = _GUIImageList_Create(105, 59) For $n = 0 To $entries - 1 $listentries[$n] = _StreamIniRead("Entries", "$order" & $n, "") $image[$n] = _GUIImageList_Add($hImage, _Resource_GetAsBitmap(String("BMP_" & StringTrimRight(_StreamIniRead("Entries", "$order" & $n, ""), StringLen(_StreamIniRead("Entries", "$order" & $n, "")) - StringInStr(_StreamIniRead("Entries", "$order" & $n, ""), ":") + 1)))) ;Image _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddItem($listview, _StreamIniRead("Entries", "$order" & $n, ""), $image[$n]) ;Entry Next $iListView = _GUIListViewEx_Init($listview, $listentries, 0, 0, True, 128 + 256) _GUIListViewEx_MsgRegister() GUISetState(@SW_SHOW, $ListGUI) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $Done For $n = 0 To $entries - 1 _StreamIniWrite("Entries", "$order" & $n, _GUICtrlListView_GetItemText($listview, $n)) Next GUIDelete($ListGUI) Edit_Entries() EndSelect WEnd EndFunc ;==>Change_Order
Moderators Melba23 Posted February 3, 2016 Author Moderators Posted February 3, 2016 (edited) Arcus, That does not surprise me as I have made no provision for the reordering of images via the UDF - hence when it reloads it uses the order determined when initially loaded. Let me have a look over the next few days to see if there is an easy solution. However, I have just finished a major upgrade of the UDF and was looking to release a new version in the near future - I am not prepared to delay that if the solution requires more that a simple fix, so I am afraid you might have to wait a while. M23 P.S. Welcome to the AutoIt forums. Edited February 4, 2016 by Melba23 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
Moderators Melba23 Posted February 4, 2016 Author Moderators Posted February 4, 2016 Arcus, I think you can do what you want by looking for drag events and then redrawing the ListView. I have not tested this idea as I am not prepared to write all the additional code necessary to make it run , but see if this suggested function works with your script: expandcollapse popupFunc Change_Order() $listentries[$entries] $image[$entries] $ListGUI = GUICreate("Change Order", 400, 500, -1, -1) $Done = GUICtrlCreateButton("Done", 157, 471, 86, 25) $listview = _GUICtrlListView_Create($ListGUI, "", 2, 2, 396, 465) _GUICtrlListView_AddColumn($listview, "Entries", 375) _GUICtrlListView_Scroll($listview, 0, 0) $hImage = _GUIImageList_Create(105, 59) For $n = 0 To $entries - 1 $listentries[$n] = _StreamIniRead("Entries", "$order" & $n, "") $image[$n] = _GUIImageList_Add($hImage, _Resource_GetAsBitmap(String("BMP_" & StringTrimRight(_StreamIniRead("Entries", "$order" & $n, ""), StringLen(_StreamIniRead("Entries", "$order" & $n, "")) - StringInStr(_StreamIniRead("Entries", "$order" & $n, ""), ":") + 1)))) ;Image _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddItem($listview, _StreamIniRead("Entries", "$order" & $n, ""), $image[$n]) ;Entry Next $iListView = _GUIListViewEx_Init($listview, $listentries, 0, 0, True, 128 + 256) _GUIListViewEx_MsgRegister() GUISetState(@SW_SHOW, $ListGUI) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $Done For $n = 0 To $entries - 1 _StreamIniWrite("Entries", "$order" & $n, _GUICtrlListView_GetItemText($listview, $n)) Next GUIDelete($ListGUI) Edit_Entries() EndSelect ; If a drag event has occurred If _GUIListViewEx_DragEvent() Then ; Save new ini order For $n = 0 To $entries - 1 _StreamIniWrite("Entries", "$order" & $n, _GUICtrlListView_GetItemText($listview, $n)) Next ; Clear ListView and remove from UDF _GUICtrlListView_DeleteAllItems($listview) _GUIListViewEx_Close($iListView) ; Destroy and recreate ImageList _GUIImageList_Destroy($hImage) $hImage = _GUIImageList_Create(105, 59) ; Reload ListView using new list order For $n = 0 To $entries - 1 $listentries[$n] = _StreamIniRead("Entries", "$order" & $n, "") $image[$n] = _GUIImageList_Add($hImage, _Resource_GetAsBitmap(String("BMP_" & StringTrimRight(_StreamIniRead("Entries", "$order" & $n, ""), StringLen(_StreamIniRead("Entries", "$order" & $n, "")) - StringInStr(_StreamIniRead("Entries", "$order" & $n, ""), ":") + 1)))) ;Image _GUICtrlListView_SetImageList($listview, $hImage, 1) _GUICtrlListView_AddItem($listview, _StreamIniRead("Entries", "$order" & $n, ""), $image[$n]) ;Entry Next ; Reinitialise ListView $iListView = _GUIListViewEx_Init($listview, $listentries, 0, 0, True, 128 + 256) EndIf WEnd EndFunc ;==>Change_Order If it does work then you could look to put much of the duplicated code into another function - I would be happy to help you with that. If it does not then please let me have a working reproducer script with all the images so I can test with some runnable code (always a good idea if you want help on complex problems). 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
Moderators Melba23 Posted February 6, 2016 Author Moderators Posted February 6, 2016 [NEW VERSION] - 6 Feb 16 An important update this time with lots of new functions: Added: ListView contents can now be saved to and reloaded from file - the new functions _GUIListViewEx_Save/LoadListView allow you save the content, the column headers, any checkbox states and (see below) any user colour settings. The current _GUIListViewEx_Insert/Delete functions act on the selected items within the active ListView (activaton being either by clicking or programatically) - 2 new functions _GUIListViewEx_Insert/DeleteSpec allow the user to programatically specify the ListView and row/col to add/remove. In the same manner as the functions above add/remove rows, 4 new functions (_GUIListViewEx_Insert/DeleteCol & _GUIListViewEx_Insert/DeleteColSpec) allow the user to add/remove columns. If the containing GUI was closed using the titlebar [X] while item editing was taking place, it sometimes took more then one click to get a response. A new handler _GUIListViewEx_WM_SYSCOMMAND_Handler has been added to intercept the closure message and act more quickly. This handler only manages this specific task and is not involved for any other UDF functionality And now the most exciting part of this update - colour! Users can now colour individual items with in the ListView using the _GUIListViewEx_SetColour function. The text and background can be coloured individually or together and can be reset to the default colours if required. The ListView can also be created with coloured elements by creating a suitable array and using the _GUIListViewEx_LoadColour function. Note that if colours are set, using the load/save functions mentioned above will also save/load the colours. The UDF now logs the row and column of the last right-click so that a context menu can be used to trigger actions - the index of the last righ-clicked ListView and the specific row/column can be obtained via the _GUIListViewEx_ContextPos function. Changed: All "Internal Use Only" functions now have a leading double-underscore - so if you have been using any of them in your scripts (which I hope is not the case) you will have to add an underscore to the name. There is also a new example script (Example_6) which shows all these new functions in use. The LH native ListView can have rows and columns added/removed using both the old and new functions and has a context menu to allow for colour selection. The contents of this listView can be mirrored to the RH UDF-created ListView, where the colours of any item can be changed programatically. Thanks to error471 (colour) and Omega19 (specific Insert/Delete) for the feature requests. New files in the zip in the first post - enjoy! M23 argumentum 1 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
Arcus Posted February 6, 2016 Posted February 6, 2016 Thanks Melba! Your idea of looking for a drag event seemed to have worked. I had the idea of detecting when a mouse press was "up" to refresh the list but that would apply to single clicks rather than dragging so your solution helped me a lot.
Moderators Melba23 Posted February 6, 2016 Author Moderators Posted February 6, 2016 Arcus, Delighted I could help - and that my idea worked despite being untested! 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
argumentum Posted February 6, 2016 Posted February 6, 2016 11 hours ago, Melba23 said: [NEW VERSION] - 6 Feb 16 "G:\au3forum\124980-guilistviewex-new-version\GUIListViewEx(6-feb-16)\GUIListViewEx.au3" (2164) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: Local $aCurrSplit = StringSplit($aColArray[$iRow + 1][$iCol], ";") Local $aCurrSplit = StringSplit(^ ERROR while clicking $cSetCol = GUICtrlCreateButton("Set Colour", Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Moderators Melba23 Posted February 7, 2016 Author Moderators Posted February 7, 2016 argumentum, Ooops - incorrect check for the existence of the row/col combination meant it crashed on an empty ListView. Now fixed - please download again. M23 argumentum 1 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
jazzyjeff Posted February 12, 2016 Posted February 12, 2016 (edited) Hey Melba23, I am using your UDF and was pretty excited to see you have added the color option. I am trying to change an items text color in the list, but I always return an error code. I am using the _GUIListViewEx_LoadColour function, and return an error 2 "ListView not user colour enabled". Here is the code that I have for this part of the script. $lvIndex = _GUIListViewEx_Init($listApps) ;MsgBox(0,"",$lvIndex) $arrayList = _GUIListViewEx_ReadToArray($listApps) $color = "" If IsArray($arrayUpdates) Then For $x = 0 To UBound($arrayList) -1 ;MsgBox(0,"loop: " & $x,$arrayList[$x][0]) For $z = 1 To $arrayUpdates[0] ;MsgBox(0,$x,$arrayUpdates[$z]) If StringInStr($arrayUpdates[$z],$arrayList[$x][0]) Then ;MsgBox(0,"Match!!!",$arrayUpdates[$z]) $color = $color & "0xFF0000|" ExitLoop Else If $z = $arrayUpdates[0] Then $color = $color & "|" EndIf EndIf Next Next EndIf If StringRight($color,1) = "|" Then $color = StringTrimRight($color,1) EndIf $colorArray = StringSplit($color,"|") If $colorArray[0] > 1 Then _ArrayDelete($colorArray,0) ;_ArrayDisplay($colorArray) EndIf _GUIListViewEx_LoadColour($lvIndex,$colorArray) If @error Then MsgBox(0,"List Error",@error) _GUIListViewEx_Close($lvIndex) Just to go over the code briefly, I have a list of items in place and export that list to an array. I compare the list to a smaller list (an array) that sometimes has identical values. If those values match, then the text in the listview changes colour. I do this by creating a srting using | as a delimiter and then convert that string to an array to use with the LoadColour function. It seems like I am missing something to enable the colour option in this UDF. Any help is appreciated. Thanks, Jeff Edited February 12, 2016 by jazzyjeff
Moderators Melba23 Posted February 12, 2016 Author Moderators Posted February 12, 2016 jazzyjeff, if this is all you are using an initialisation line: _GUIListViewEx_Init($listApps) then I am not surprised you get the error "ListView not user colour enabled". Did you look at the _GUIListViewEx_Init function header? ; #FUNCTION# ========================================================================================================= ; Name...........: _GUIListViewEx_Init ; Description ...: Enables UDF functions for the ListView and sets various flags ; Syntax.........: _GUIListViewEx_Init($hLV, [$aArray = ""[, $iStart = 0[, $iColour[, $fImage[, $iAdded[, $sCols]]]]]]) ; Parameters ....: $hLV - Handle or ControlID of ListView ; $aArray - Name of array used to fill ListView. "" for empty ListView ; $iStart - 0 = ListView data starts in [0] element of array (default) ; 1 = Count in [0] element ; $iColour - RGB colour for insert mark (default = black) ; $fImage - True = Shadow image of dragged item when dragging ; False = No shadow image (default) ; $iAdded - 0 - No added features (default). To get added features add the following ; + 1 - Sortable by clicking on column headers (if not user colour enabled) ; + 2 - Editable when double clicking on a subitem in user-defined columns ; + 4 - Edit continues within same ListView by triple mouse-click (only if ListView editable) ; + 8 - Headers editable by Ctrl-click (only if ListView editable) ; + 16 - Left/right cursor active in edit - use Ctrl-arrow to move to next item (if set) ; + 32 - User coloured items (force no column sort) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; + 64 - No external drag ; + 128 - No external drop ; + 256 - No delete on external drag/drop I have highlighted the relevant line. If you correctly initialise the ListView the UDF will display coloured items (I hope)! 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
jazzyjeff Posted February 12, 2016 Posted February 12, 2016 Thanks Melba. I see it. Sorry, I looked after I sent the message. I'm getting an error 3 now, but I think that's a problem with the array I am using and nothing wrong with UDF part. Thanks again!
Moderators Melba23 Posted February 12, 2016 Author Moderators Posted February 12, 2016 jazzyjeff, if you let me have the ListView code and the colour array I will try and help you resolve the problem. For a start: what does @extended read after the error: 3 = Array not 2D (@extended = 0) or not correct size for LV (@extended = 1) That might give you a clue. 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
jazzyjeff Posted February 12, 2016 Posted February 12, 2016 Thanks Melba. So I am still having problems getting the colour to populate in the list box. Here is my code: expandcollapse popup$lvIndex = _GUIListViewEx_Init($listApps,"", "", "", "", 32) ;MsgBox(0,"",$lvIndex) $arrayList = _GUIListViewEx_ReadToArray($listApps) ;_ArrayDisplay($arrayList) $color = "" If IsArray($arrayUpdates) Then For $x = 0 To UBound($arrayList) -1 ;MsgBox(0,"loop: " & $x,$arrayList[$x][0]) For $z = 1 To $arrayUpdates[0] ;MsgBox(0,$x,$arrayUpdates[$z]) If StringInStr($arrayUpdates[$z],$arrayList[$x][0]) Then ;MsgBox(0,"Match!!!",$arrayUpdates[$z]) _GUIListViewEx_SetColour($lvIndex, "0xFF0000;", $x, 0) If @error Then MsgBox(0,"List Error","Error: " & @error & @CRLF & "Extended: " & @extended) $color = $color & "0xFF0000;|" ExitLoop Else If $z = $arrayUpdates[0] Then $color = $color & "|" EndIf EndIf Next Next EndIf If StringRight($color,1) = "|" Then $color = StringTrimRight($color,1) EndIf $colorArray = StringSplit($color,"|") If $colorArray[0] > 1 Then _ArrayDelete($colorArray,0) _ArrayColInsert($colorArray,1) _ArrayColDelete($colorArray,1) EndIf If IsArray($arrayUpdates) Then _ArrayDisplay($colorArray) _GUIListViewEx_LoadColour($lvIndex,$colorArray) If @error Then MsgBox(0,"List Error","Error: " & @error & @CRLF & "Extended: " & @extended) EndIf _GUIListViewEx_Close($lvIndex) I resolved the array issue and made sure that both my listview array and my colour array matched in terms of size, so no errors now. The problem was though that the colours in the listview didn't change. I then thought I perhaps needed to add the SetColour function, so I did inside one of the For Loops, but I now get an error 4, indicating the rows and columns I am using are not quite right. Here are the 2 arrays. The first is for the listview, which I want to have the text colour changed, and the second is the colour array that was created for the LoadColour function. Any help you can offer here would be appreciated. Perhaps I don't even need the setColour function, but I must be doing something wrong with the LoadColour function then.
Moderators Melba23 Posted February 12, 2016 Author Moderators Posted February 12, 2016 jazzyjeff, Firstly _GUIListViewEx_SetColour: In fixing argumentum's bug above I alas introduced another one. I forgot that although there was a count row, there was not a count column and so made the alteration to both whereas I should have only done so for the rows - as a result the UDF crashes when trying to colour the rightmost column. Sorry about that - I will upload a BugFix version tomorrow when I have tested against some other scenarios to make sure I have not done the same thing again. Thanks for the pointer. Now, _GUIListViewEx_LoadColour: That works fine for me - the bug does not affect this function. I do not see you calling _GUIListViewEx_MsgRegister in that snippet - do you do so elsewhere? if you do not register the various message handlers then the UDF will not function at all. Here is my test script: expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <Array.au3> #include "GUIListViewEx.au3" Global $aColArray[70][1] $hGUI = GUICreate("Test", 500, 500) $listApps = GUICtrlCreateListView("Items ", 10, 10, 400, 400, $LVS_SHOWSELALWAYS) For $i = 0 To 69 GUICtrlCreateListViewItem("Item " & $i, $listApps) If StringinStr($i, "7") Then $aColArray[$i][0] = "0xFF0000;" Else $aColArray[$i][0] = ";" EndIf Next $arrayList = _GUIListViewEx_ReadToArray($listApps) _ArrayDisplay($arrayList, "Items", Default, 8) _ArrayDisplay($aColArray, "Colours", Default, 8) $lvIndex = _GUIListViewEx_Init($listApps, $arrayList, "", "", "", 32) _GUIListViewEx_LoadColour($lvIndex, $aColArray) _GUIListViewEx_MsgRegister() GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd I get every item with a "7" coloured red - do you? 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
jazzyjeff Posted February 12, 2016 Posted February 12, 2016 (edited) Thanks for your response Melba. So I was missing the _GUIListViewEx_MsgRegister() function. I have now placed this in my code, but the problem still persists. I have about 2500 lines of code, so you probably don't want to see all of that. A lot of the information is being pulled from a SQL database too. I am wondering, do you think the problem could be caused by me doing a sort in the listview with this function? _GUICtrlListView_SimpleSort I am using the same builtin ListView Create functions that you are using in your example. Your code works flawlessly by the way. Thanks! UPDATE: I just removed the SimpleSort function, but this didn't resolve the issue. Edited February 12, 2016 by jazzyjeff
Recommended Posts