argumentum Posted March 13, 2017 Share Posted March 13, 2017 I'd like to color the background of a _GUICtrlListView_InsertItem() created item, but I don't find an easy way ( with a function call ). Help =/ expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> Example() Func Example() ; fails, but is the one I'd like to use with _GUICtrlListView_InsertItem() Local $aItem, $idListview GUICreate("Color row FAIL", 300, 200) $idListview = GUICtrlCreateListView("", 2, 2, 294, 196) GUISetState(@SW_SHOW) _GUICtrlListView_InsertColumn($idListview, 0, "Column 1", 100) ; Add items as such _GUICtrlListView_InsertItem($idListview, "Item 1", 0) _GUICtrlListView_InsertItem($idListview, "Item 2", 0) _GUICtrlListView_InsertItem($idListview, "Item 3", 0) $aItem = _GUICtrlListView_GetItem($idListview, 1) GUICtrlSetBkColor($aItem[5],0xF0F0F0) _GUICtrlListView_SetItemColor($idListview, 2, 0xF0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example Example2() Func Example2() ; works Local $aItem, $idListview GUICreate("Color row OK", 300, 200) $idListview = GUICtrlCreateListView("Items", 2, 2, 294, 196) GUISetState(@SW_SHOW) ; Add items as such GUICtrlCreateListViewItem("Row 1", $idListview) GUICtrlCreateListViewItem("Row 2", $idListview) GUICtrlCreateListViewItem("Row 3", $idListview) $aItem = _GUICtrlListView_GetItem($idListview, 1) GUICtrlSetBkColor($aItem[5],0xF0F000) _GUICtrlListView_SetItemColor($idListview, 2, 0xF0) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>Example2 Func _GUICtrlListView_SetItemColor($hListView, $iItem, $xColor) ; https://www.autoitscript.com/forum/topic/115871-set-color-line-guictrlcreatelistview-and-_guictrllistview/?do=findComment&comment=871218 If Not IsHWnd($hListView) Then $hListView = GUICtrlGetHandle($hListView) $iReturn = GUICtrlSetColor(_GUICtrlListView_GetItemParam($hListView, $iItem), $xColor) Select Case $iReturn = 0 Return SetError(1, 0, 0) ; Failure Case $iReturn = 1 Return SetError(0, 0, 1) ; Success EndSelect EndFunc ;==> END _GUICtrlListView_SetItemColor() Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2017 Moderators Share Posted March 13, 2017 argumentum, As you have it working with the native GUICtrlCreateListViewitem, why do you need it to work with the UDF function? Why not just use the native function? M23 P.S. My GUIListViewEx UDF will do what you require, but it seems a bit overcomplicated when you have a working solution. 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...
argumentum Posted March 13, 2017 Author Share Posted March 13, 2017 Just now, Melba23 said: you have it working with the native GUICtrlCreateListViewitem, why do you need it to work with the UDF function? it's for a log entry in a listview. Using _GUICtrlListView_InsertItem($lv,"text",0) , the next entry will show on top of the listview. ...unless there is a way to move the GUICtrlCreateListViewItem to the top. If there is no func. that can be created to ( seemingly ) simplify this, I'll try the GUIListViewEx . Thanks Melba23. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. 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