Jump to content

Change text color of a List


devrandom
 Share

Recommended Posts

  • Moderators

devrandom,

You would need an ownerdrawn list to do that - a lot of work. ;)

But here is a workaround using labels and my GUIScrollBars_Ex UDF (look in my sig) - just click on a line to change the colour: :idiot:

#include <GUIConstantsEx.au3>

#Include <GuiScrollBars_Ex.au3>

Global $iItems = 50        ; Number of items in list
Global $iDisplayItems = 20 ; Number of items in GUI
Global $aLabelID[$iItems]  ; ControlIDs of labels
Global $aData[$iItems][2]  ; Data and colour state of labels

; Fill data array
For $i = 0 To UBound($aData) - 1
    $aData[$i][0] = $i & " - " & $i & " - " & $i & " - " & $i ; Data
    $aData[$i][1] = 0                                         ; State
Next

; Create GUI
$hGui = GUICreate("Scroll Colour Line List", 420, 20 + $iDisplayItems * 20)

; Create "list"
For $i = 0 To $iItems - 1
    $aLabelID[$i] = GUICtrlCreateLabel($aData[$i][0], 10, 10 + ($i * 20), 380, 20)
Next

GUISetState()

; Generate scrollbars
_GUIScrollbars_Generate($hGui, 0, 4 + ($iItems * 20)) ; Just this one line is all you need to get scrollbars !!!!!!!!!!!!!!!!!!!!!!!!!!

While 1

    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit
        ; Click on label so change colour
        Case $aLabelID[0] To $aLabelID[19]
            $iIndex = $iMsg - $aLabelID[0]
            ; Toggle colour data
            $aData[$iIndex][1] = Not $aData[$iIndex][1]
            ; Change line colour
            Switch $aData[$iIndex][1]
                Case 0
                    GUICtrlSetColor($aLabelID[$iIndex], 0x000000)
                Case 1
                    GUICtrlSetColor($aLabelID[$iIndex], 0xFF0000)
            EndSwitch
    EndSwitch

WEnd

Any use? :)

M23

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:

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

 

Link to comment
Share on other sites

  • Moderators

devrandom,

Glad I could help. :)

M23

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:

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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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