Jump to content

why not color green


faustf
 Share

Recommended Posts

hi guys  why this  script  not  colored green  ?

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Text Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)

    ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)

        If Not Mod($iI, 2) Then
            ;Even
            _GUICtrlListView_SetTextColor($idListview, $CLR_RED)
        Else
            ;Odd
            _GUICtrlListView_SetTextColor($idListview, $CLR_GREEN)
        EndIf

    Next
    _GUICtrlListView_EndUpdate($idListview)


    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

 

Link to comment
Share on other sites

  • Moderators

faustf, 

Look at my GUIListViewEx UDF (the link is in my sig) - it allows you to colour individual cells of a List View. Example 6 shows it in action. 

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

i tryed  but is very complicated  for understund  , so , but i try to understund

i  create a script now in this mode 

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

#include "GUIListViewEx.au3"

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Text Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)

    ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    Local $iCol
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)

        If Not Mod($iI, 2) Then
            $iCol= "0xFF0000"
            ;Even
            ;_GUICtrlListView_SetTextColor($idListview, $CLR_RED)
            GUIListViewEx_SetColour($idListview, 1, $iI, $iCol)
        Else
            $iCol="0x00FF00"
            ;Odd
            ;_GUICtrlListView_SetTextColor($idListview, $CLR_GREEN)
            GUIListViewEx_SetColour($idListview, 1, $iI, $iCol)
        EndIf

    Next
    _GUICtrlListView_EndUpdate($idListview)


    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

i include your udf  inside but return me this error

C:\Users\pc\Desktop\dacancellare\_GUICtrlListView_SetTextColor.au3"(36,54) : error: GUIListViewEx_SetColour(): undefined function.
            GUIListViewEx_SetColour($idListview, 1, $iI, $iCol)
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\pc\Desktop\dacancellare\_GUICtrlListView_SetTextColor.au3 - 1 error(s), 0 warning(s)

o_O

Link to comment
Share on other sites

4 minutes ago, Nine said:

You also can use GUICtrlSetBkColor or GUICtrlSetColor to change the color of a list view item (whole line).

is not good   color  all  like

_GUICtrlListView_SetTextColor

2 function for do  the same work o_O

 

Edited by faustf
Link to comment
Share on other sites

underline  pfff

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

#include "GUIListViewEx.au3"


Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Text Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)

    ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    Local $iCol
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)

        If Not Mod($iI, 2) Then
            $iCol = "0xFF0000"
            ;Even
            ;_GUICtrlListView_SetTextColor($idListview, $CLR_RED)
            _GUIListViewEx_SetColour($idListview, 1, $iI, $iCol)
        Else
            $iCol = "0x00FF00"
            ;Odd
            ;_GUICtrlListView_SetTextColor($idListview, $CLR_GREEN)
            _GUIListViewEx_SetColour($idListview, 1, $iI, $iCol)
        EndIf

    Next
    _GUICtrlListView_EndUpdate($idListview)


    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

now  work but nothing happen

Link to comment
Share on other sites

yep sorry

#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

#include "GUIListViewEx.au3"


Example()

Func Example()
    Local $idListview

    GUICreate("ListView Set Text Color", 400, 300)
    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
    GUISetState(@SW_SHOW)

    ; Set colors
    ;_GUICtrlListView_SetBkColor($idListview, $CLR_MONEYGREEN)

    ;_GUICtrlListView_SetTextBkColor($idListview, $CLR_MONEYGREEN)

    ; Add columns
    _GUICtrlListView_AddColumn($idListview, "Items", 100)

    ; Add items
    _GUICtrlListView_BeginUpdate($idListview)
    Local $iCol
    For $iI = 1 To 10
        _GUICtrlListView_AddItem($idListview, "Item " & $iI)

        If Not Mod($iI, 2) Then
            $iCol = "0xFF0000"
            ;Even
            ;_GUICtrlListView_SetTextColor($idListview, $CLR_RED)
        Local $de=  _GUIListViewEx_SetColour($idListview,$iCol,$iI,0 )
If $de =0 Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
        EndIf
        Else
            $iCol = "0x00FF00"
            ;Odd
            ;_GUICtrlListView_SetTextColor($idListview, $CLR_GREEN)
            _GUIListViewEx_SetColour($idListview,$iCol,$iI,0 )
        EndIf

    Next
    _GUICtrlListView_EndUpdate($idListview)


    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

_GUIListViewEx_SetColour($iLV_Index, $sColSet, $iRow, $iCol)

return me

event error 1

   Failure: Returns 0 and sets @error as follows:
;                      1 = Invalid index

 

but use $idListview  and is correct why return me error ?

Link to comment
Share on other sites

@Melba23

special thankz for your UDF , is very powerfull and i think  is also stable , but  example 6 is extreamly complicated, doc instrunctions is very short , if you never seen before , apply this  udf  is necessary minimum one intensive week studying .

i think autoit instead of insert debugarray , if  re-think listview is much better , because i think simply is better 

therefore i adop simply solution

#include <GuiConstants.au3>
#include <GuiListView.au3>

$GUI = GUICreate("Test")
$List = GUICtrlCreateListView("Column 1|Column 2", _
        10, 10, 380, 380, -1, $LVS_EX_FULLROWSELECT)

GUISetState()

For $i = 1 To 20
    GUICtrlCreateListViewItem("My description " & $i & "|" & "Initial Value " & $i, $List)
    If $i = 5 Then
        GUICtrlSetColor(-1, 0x0000FF)
    ElseIf $i = 10 Then
        GUICtrlSetColor(-1, 0xFF0000)
    EndIf
Next

While GUIGetMsg() <> $GUI_EVENT_CLOSE
    Sleep(10)
WEnd

thankz again for support , when  i have  time sure  i try to study and use your UDF

P.S.  the problem is only a type of insert o_O i never understund maybe

_GUICtrlListView_AddItem($idListview, "Item " & $iI)    to   GUICtrlCreateListViewItem("My description " & $i & "|" & "Initial Value " & $i, $List)

i dream a simply option

_GUICtrlListView_AddItem($idListview, "Item " & $iI, COLORTEXT, CELLTOCOLOR )

IF CELLTOCOLOR= *  ALL ROW COLORED

next update i hope find

 

thankz again

 

 

Link to comment
Share on other sites

Regarding the UDF, i understand what you mean, the examples are packed with different ways things can be done and when you want only one of them, you have to sort through the code to extract only what you need.

But take a look at this example, i think you will find it's not that complex.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>
Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0
$hGUI = GUICreate("LVEx Example 1", 500, 430)
$hListView_Right = _GUICtrlListView_Create($hGUI, "", 10, 20, 480, 400, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)
;=============================================================================
For $i = 1 To $iCount_Right
    _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1)
    If Mod($i, 4) Then
        _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1)
    EndIf
    _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2)
Next
;=============================================================================
; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - move edit by click + headers editable
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 32)
; All columns editable - simple text selected on open
_GUIListViewEx_SetEditStatus($iLV_Right_Index, "*")
; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()
GUISetState()
;Coloring only the background of some items, text remains black.
;=============================================================================
$Count = _GUICtrlListView_GetItemCount($hListView_Right)
ConsoleWrite($Count &@CRLF)
    For $c = 0 To $Count
        If $c < 5 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 2)
        ElseIf $c > 10 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 2)
        EndIf
    Next
;=============================================================================
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    $vRet = _GUIListViewEx_EventMonitor($iEditMode)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
    EndIf
    Sleep(100)
WEnd
;=============================================================================

Dont forget to put GUIListViewEx.au3 in the script folder.

EDIT: updated example

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • Moderators

faustf,

I do realise that the UDF is a very complex beast - but ListViews are very complex controls and trying to manipulate them is not an easy task! However, i am always happy to help users amend their scripts to use the UDF, so do not hesitate to ask if you run into problems.

As to your specific problem with _GUIListViewEx_SetColour - you need to use the index from a _GUIListViewEx_Init call to identify the ListView to the UDF, not the ControlID returned by AutoIt when you create the control, and also call the _GUIListViewEx_MsgRegister function to allow the UDF to do the colouring.

Let me know if you are still interested in using the UDF and post your basic code with the necessary colour requirements and I will see what I can do.

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

1 hour ago, faustf said:

i use your exmple  but  colored  all background  i want color only a write  look my simply example last

I supose i was expecting you to modify the example, but check this one out.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>
Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0
$hGUI = GUICreate("LVEx Example 1", 500, 430)
$hListView_Right = _GUICtrlListView_Create($hGUI, "", 10, 20, 480, 400, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)
;=============================================================================
For $i = 1 To $iCount_Right
    _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1)
    If Mod($i, 4) Then
        _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1)
    EndIf
    _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2)
Next
;=============================================================================
; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - move edit by click + headers editable
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 32)
; All columns editable - simple text selected on open
_GUIListViewEx_SetEditStatus($iLV_Right_Index, "*")
; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()
GUISetState()
;Coloring only the background of some items, text remains black.
;=============================================================================
$Count = _GUICtrlListView_GetItemCount($hListView_Right)
ConsoleWrite($Count &@CRLF)
    For $c = 0 To $Count
        If $c < 5 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 2)
        ElseIf $c > 10 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 2)
        EndIf
    Next
;=============================================================================
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    $vRet = _GUIListViewEx_EventMonitor($iEditMode)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
    EndIf
    Sleep(100)
WEnd
;=============================================================================

 

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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