Jump to content

Recommended Posts

Posted

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 =/ 

#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.
autoit_scripter_blue_userbar.png

  • Moderators
Posted

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.

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted
  On 3/13/2017 at 5:58 PM, Melba23 said:

you have it working with the native GUICtrlCreateListViewitem, why do you need it to work with the UDF function?

Expand  

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.
autoit_scripter_blue_userbar.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...