dromenox Posted October 1, 2014 Share Posted October 1, 2014 I already googled but no results worked. I want to know how can I do to change the background color of a particular row in a GuiListView. I am creating a UDF to facilitate create ListViews with running processes. Have a function to automatically update the list and will be called every 1 second. When a new process is created, his line will turn green for 1 second and when finished will be red for 1 second until the next update. When the process is running will have the default color. Know how to change the color of the entire ListView, but I do not know a single line. Link to comment Share on other sites More sharing options...
Zedna Posted October 1, 2014 Share Posted October 1, 2014 (edited) For example here There are more examples on the forum but princip is the same ... use WM_NOTIFY and NM_CUSTOMDRAW --> search forum for these keywords Edited October 1, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
dromenox Posted October 1, 2014 Author Share Posted October 1, 2014 (edited) For example here There are more examples on the forum but princip is the same ... use WM_NOTIFY and NM_CUSTOMDRAW --> search forum for these keywords It works! But I want to paint the entire row even! But I'll try to study how it works. Edit: I've managed to make it work in the entire line! And what can I do to make it work with 2 clicks and the right click? Edited October 1, 2014 by dromenox Link to comment Share on other sites More sharing options...
Zedna Posted October 1, 2014 Share Posted October 1, 2014 (edited) http://www.autoitscript.com/forum/index.php?s=&showtopic=71681&view=findpost&p=524257 ;~ DllStructSetData($tCustDraw, 'clrText', 0x5555DD) DllStructSetData($tCustDraw, 'clrTextBk', 0xFFFF00) Edited October 1, 2014 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 1, 2014 Moderators Share Posted October 1, 2014 dromenox,You can also do it in native AutoIt code:expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Array.au3> Global $iCount = 0 Global $aListing[1][2] = [[0]] $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 1 ", 10, 10, 200, 300) $cInput = GUICtrlCreateInput("", 10, 350, 200, 20, $ES_NUMBER) $cAdd = GUICtrlCreateButton("Add", 10, 450, 80, 30) $cDel = GUICtrlCreateButton("Delete", 260, 450, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAdd $cItem = GUICtrlCreateListViewItem("Item " & $iCount, $cLV) $aListing[0][0] += 1 ReDim $aListing[$aListing[0][0] + 1][2] $aListing[$aListing[0][0]][0] = "Item " & $iCount $aListing[$aListing[0][0]][1] = $cItem GUICtrlSetBkColor($cItem, 0x00FF00) Sleep(1000) GUICtrlSetBkColor($cItem, 0xFFFFFF) $iCount += 1 Case $cDel $iIndex = _ArraySearch($aListing, "Item " & GUICtrlRead($cInput)) If $iIndex <> - 1 Then $cItem = $aListing[$iIndex][1] GUICtrlSetBkColor($cItem, 0xFF0000) _ArrayDelete($aListing, $iIndex) $aListing[0][0] -= 1 Sleep(1000) GUICtrlDelete($cItem) EndIf EndSwitch WEndUse the Addbutton to get a few items and add a number to the input to delete one of them. 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...
dromenox Posted October 1, 2014 Author Share Posted October 1, 2014 (edited) dromenox, You can also do it in native AutoIt code: expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <Array.au3> Global $iCount = 0 Global $aListing[1][2] = [[0]] $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Col 1 ", 10, 10, 200, 300) $cInput = GUICtrlCreateInput("", 10, 350, 200, 20, $ES_NUMBER) $cAdd = GUICtrlCreateButton("Add", 10, 450, 80, 30) $cDel = GUICtrlCreateButton("Delete", 260, 450, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cAdd $cItem = GUICtrlCreateListViewItem("Item " & $iCount, $cLV) $aListing[0][0] += 1 ReDim $aListing[$aListing[0][0] + 1][2] $aListing[$aListing[0][0]][0] = "Item " & $iCount $aListing[$aListing[0][0]][1] = $cItem GUICtrlSetBkColor($cItem, 0x00FF00) Sleep(1000) GUICtrlSetBkColor($cItem, 0xFFFFFF) $iCount += 1 Case $cDel $iIndex = _ArraySearch($aListing, "Item " & GUICtrlRead($cInput)) If $iIndex <> - 1 Then $cItem = $aListing[$iIndex][1] GUICtrlSetBkColor($cItem, 0xFF0000) _ArrayDelete($aListing, $iIndex) $aListing[0][0] -= 1 Sleep(1000) GUICtrlDelete($cItem) EndIf EndSwitch WEnd Use the Addbutton to get a few items and add a number to the input to delete one of them. M23 Perfect! How can I get the handle of the item from your text? Edited October 1, 2014 by dromenox Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 2, 2014 Moderators Share Posted October 2, 2014 dromenox,Only just seen the edit. You get the ControlID of the item deleted like this: $cItem = $aListing[$iIndex][1]. But ListView items do not have handles - why do you think you need it? 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...
dromenox Posted October 2, 2014 Author Share Posted October 2, 2014 dromenox, Only just seen the edit. You get the ControlID of the item deleted like this: $cItem = $aListing[$iIndex][1]. But ListView items do not have handles - why do you think you need it? M23 I was thinking of creating an array with the ProcessList and one with the elements that are in the ListView. Then I would go this last array and making comparisons if the process is new, it was finished ... And on that basis I would changing the color of each item if necessary. For example if the item was green at the next check he should stay white. For this I believe would have to use ControlID of each item. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 3, 2014 Moderators Share Posted October 3, 2014 dromenox,For this I believe would have to use ControlID of each itemCorrect. But you have all of the required information in the script - the process name would take place of the the "Item " & $iCount" element in the [0] element of the array and the ControlID is alreay in the [1] element. 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...
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