Sign in to follow this  
Followers 0
dromenox

GuiListView Item Bk

9 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Zedna

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by dromenox

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

http://www.autoitscript.com/forum/index.php?s=&showtopic=71681&view=findpost&p=524257

;~                             DllStructSetData($tCustDraw, 'clrText', 0x5555DD)
                            DllStructSetData($tCustDraw, 'clrTextBk', 0xFFFF00)

 

Edited by Zedna

Share this post


Link to post
Share on other sites

dromenox,

You can also do it in native AutoIt code:

#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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

dromenox,

You can also do it in native AutoIt code:

#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 by dromenox

Share this post


Link to post
Share on other sites

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? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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? :huh:

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.

Share this post


Link to post
Share on other sites

dromenox,

For this I believe would have to use ControlID of each item

Correct. 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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0