Jump to content

Recommended Posts

Posted (edited)

Looking for a way to set the colour of listview item and subitem colours.

looking through the forum it seems to be a terribly convoluted task.

I found >this topic which looked promising, but it simply does not change the colour of any items or sub items at all.

Is that code very old or something?

EDIT:

Just to clarify, it is not enough for me to set the colour of the whole index item (row) I need to set sub item colours individually, and after the list view has been populated.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

?

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("Form1", 350, 250, -1, -1)
$ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 250)

GuiCtrlCreateListViewItem('White|White|White',$ListView1)
GuiCtrlCreateListViewItem('Pink|Green|Pink',$ListView1)
GuiCtrlCreateListViewItem('White|White|White',$ListView1)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd


Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
     Local $tNMHDR, $hWndFrom, $iCode
     $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
     $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
     $iCode = DllStructGetData($tNMHDR, "Code")
     $hListView = GuiCtrlGetHandle($ListView1)

    Switch $hWndFrom
         Case $hListView
             Switch $iCode
               Case $NM_CUSTOMDRAW
                     Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                     Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")
                     If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW
                     If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW
                     Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")
                     Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
                     Local $iColor, $iColor2

                     If $iItem = 1 Then
                           If $iSubItem = 1 Then
                               $iColor = RGB2BGR(0x00aa00)  ; green
                           Else
                               $iColor = RGB2BGR(0xffaaff)  ; pink
                           EndIf
                    Else
                           $iColor = RGB2BGR(0xFFFFFF)  ; white
                    EndIf
                     DllStructSetData($tCustDraw, "clrTextBk", $iColor) ; background color
                     Return $CDRF_NEWFONT
             EndSwitch
     EndSwitch
    Return $GUI_RUNDEFMSG
 EndFunc   ;==>WM_NOTIFY

Func RGB2BGR($iColor)
     Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
EndFunc   ;==>RGB2BGR()
Posted (edited)

That's what I mean by each sub item, yes.

Cheers.

But once That listview is showing and the while loop is running, how then would I change row 2 column 2 to red, say on the press of a button?

EDIT:

It seems that the structure needed to change the colour is linked to $lParam of WM_NOTIFY params, so I can't see how to target a specific item to set the colour.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

Depending on the requirements you will need to manage it  :)

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $var = 0
$Form1 = GUICreate("Form1", 350, 250, -1, -1)
$ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 200)

GuiCtrlCreateListViewItem('White|White|White',$ListView1)
GuiCtrlCreateListViewItem('Pink|Green|Pink',$ListView1)
GuiCtrlCreateListViewItem('White|White|White',$ListView1)
$btn = GuiCtrlCreateButton('button', 20, 210, 50, 25)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            _GUICtrlListView_SetItemText($ListView1, 1, "Red", 1)
    EndSwitch
WEnd


Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
     Local $tNMHDR, $hWndFrom, $iCode
     $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
     $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
     $iCode = DllStructGetData($tNMHDR, "Code")
     $hListView = GuiCtrlGetHandle($ListView1)

    Switch $hWndFrom
         Case $hListView
             Switch $iCode
               Case $NM_CUSTOMDRAW
                     Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                     Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")
                     If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW
                     If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW
                     Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")
                     Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
                     Local $iColor

                     If $iItem = 1 Then
                           If $iSubItem = 1 Then
                               $iColor = RGB2BGR(0x00aa00)  ; green
                               $text = _GUICtrlListView_GetItemText($hListView, $iItem, 1)
                               If stringInStr($text, "Red") Then $iColor = RGB2BGR(0xFF0000)
                           Else
                               $iColor = RGB2BGR(0xffaaff)  ; pink
                           EndIf
                    Else
                           $iColor = RGB2BGR(0xFFFFFF)  ; white
                    EndIf
                     DllStructSetData($tCustDraw, "clrTextBk", $iColor) ; background color
                     Return $CDRF_NEWFONT
             EndSwitch
     EndSwitch
    Return $GUI_RUNDEFMSG
 EndFunc   ;==>WM_NOTIFY

Func RGB2BGR($iColor)
     Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
EndFunc   ;==>RGB2BGR()
Posted (edited)

0.jpg

Start here

$WinMain = GUICreate('Jim Smiths (Flyboy) Personal Encryption tool', 800, 400)
    GUISetBkColor(0xA6CAF0)
    GUICtrlSetDefBkColor( 0x00ced1)  ; Creates window

This sets the color for everything in the script..

except pop ups//

and to set them just

$file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
   ; GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files

set the color after the create

Then for those pesky OK boxes.. go find Melba23's excellent

Title .........: ExtMsgBox
; AutoIt Version : v3.2.12.1 or higher
; Language ......: English
; Description ...: Generates user defined message boxes centred on an owner, on screen or at defined coordinates
; Remarks .......:
; Note ..........:
; Author(s) .....: Melba23, based on some original code by photonbuddy & YellowLab, and KaFu (default font data)

example 3 shows a easy way to colorize them,

HINT another way to colorize a whole program is to get XSkin_Fully_Loaded but they dropped the ball at the end of this excellent program as you will require Melba23's excellence to colorize OK boxes.

Best to you

Add the color to each item if necessary using the sample at the top. Right after you create it.

1465
1538
Edited by meows
Posted (edited)

JO,

Setting a new color for a subitem needs the listview to be repainted, which is done when a message is sent to the LV

But you can turn around the hard-coding in the wm_notify - I believe - just by using global vars

Anyway I still don't know what you exactly need  :)

#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

Global $myitem = -1, $mysubitem = -1

$Form1 = GUICreate("Form1", 350, 250, -1, -1)
$ListView1 = GUICtrlCreateListView("Header|Header|Header", 0, 0, 350, 200)

GuiCtrlCreateListViewItem('White|White|White',$ListView1)
GuiCtrlCreateListViewItem('Pink|Green|Pink',$ListView1)
GuiCtrlCreateListViewItem('White|White|White',$ListView1)
$btn = GuiCtrlCreateButton('button', 20, 210, 50, 25)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn
            $myitem = 1
            $mysubitem = 1
            _GUICtrlListView_SetItemText($ListView1, 1, "Red", 1)
    EndSwitch
WEnd


Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
     Local $tNMHDR, $hWndFrom, $iCode
     $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
     $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
     $iCode = DllStructGetData($tNMHDR, "Code")
     $hListView = GuiCtrlGetHandle($ListView1)

    Switch $hWndFrom
         Case $hListView
             Switch $iCode
               Case $NM_CUSTOMDRAW
                     Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
                     Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage")
                     If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW
                     If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW
                     Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem")
                     Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec")
                     Local $iColor

                     If $iItem = 1 Then
                           If $iSubItem = 1 Then
                               $iColor = RGB2BGR(0x00aa00)  ; green
                           Else
                               $iColor = RGB2BGR(0xffaaff)  ; pink
                           EndIf
                    Else
                           $iColor = RGB2BGR(0xFFFFFF)  ; white
                    EndIf

                    If $iItem = $myitem and $iSubItem = $mysubitem Then $iColor = RGB2BGR(0xFF0000)  ; red

                     DllStructSetData($tCustDraw, "clrTextBk", $iColor) ; background color
                     Return $CDRF_NEWFONT
             EndSwitch
     EndSwitch
    Return $GUI_RUNDEFMSG
 EndFunc   ;==>WM_NOTIFY

Func RGB2BGR($iColor)
     Return BitAND(BitShift(String(Binary($iColor)), 8), 0xFFFFFF)
EndFunc   ;==>RGB2BGR()
Edited by mikell
Posted (edited)

I'll try to explain my goal.

I have an array which I will be entering into a listview and the array looks like so...

lv2.jpg

It can have a varying amount of columns with varying numbers in, but Col 0 is always the Parent Type and its child Subtypes (which can also vary)

I need to make the parent type and its subtypes an arbitrary colour for each set. (toward that end I prefix each parent Type with an Asterix (*).

So ..

Type1

Subtype1

Subtype2

Subtype3

Type2

Subtype4

Subtype5

Type3

Subtype5

etc..

Col 1 subitems should remain white, but if col 2 value is lesser than col 1 value in same row, it should be coloured red, and if col 2 value is greater than col 1 value in same row it should be green.

The same with Col 3, if it is lesser than the col preceding it in the same row it should be red, and green if it is greater. And so on.

Kind of...

22  21 30  29 32 33 34 31

EDIT:

Code for creating that array can be found >here

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

A listview is the proper control. It is very easy to code with an array to hold the colors, and it will be lightning fast. I'll show some code tomorrow.

Posted

Here you go (3.3.10 or later)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Array.au3>


Global $aFirstArray[10][5] = [["Type1", "Subtype1", 10, 1, 0.1],["Type1", "Subtype2", 20, 2, 0.2], _
        ["Type1", "Subtype3", 30, 3, 0.3],["Type2", "Subtype4", 40, 4, 0.4], _
        ["Type2", "Subtype5", 50, 5, 0.5],["Type3", "Subtype5", 60, 6, 0.6], _
        ["Type4", "Subtype6", 70, 7, 0.7],["Type4", "Subtype7", 80, 8, 0.8], _
        ["Type5", "Subtype8", 90, 9, 0.9],["Type5", "Subtype9", 100, 10, 0.0]]


;_ArrayDisplay($aFirstArray, "First")

Local $iCols = UBound($aFirstArray, 2) - 1

Local $aResult[UBound($aFirstArray) * 2][$iCols], $sLast, $n = 0

For $x = 2 To $iCols
    $sLast = ""
    $n = 0
    For $i = 0 To UBound($aFirstArray) - 1

        If $aFirstArray[$i][0] <> $sLast Or $n = 0 Then

            $sLast = $aFirstArray[$i][0]
            $aResult[$n][0] = $sLast ; Add Type to array
            $n += 1
            $aResult[$n][0] = $aFirstArray[$i][1] ; Add Subtype to array
            $aResult[$n][$x - 1] = $aFirstArray[$i][$x] ; Add Value to array
        Else

            $aResult[$n][0] = $aFirstArray[$i][1] ; Add Subtype to array
            $aResult[$n][$x - 1] = $aFirstArray[$i][$x] ; Add Value to array
        EndIf
        $n += 1

    Next
Next
ReDim $aResult[$n][$iCols]

;_ArrayDisplay($aResult, "Second")

; Adding The values of subtypes
$iTotalIndex = 0
$iTotalValue = 0
$iCols = UBound($aResult, 2) - 1

For $x = 1 To $iCols
    $iTotalIndex = 0
    $iTotalValue = 0
    For $i = 1 To UBound($aResult) - 1
        If $aResult[$i][$x] <> "" Then
            $iTotalValue += $aResult[$i][$x] ; Add value of Subtype
        Else
            $aResult[$iTotalIndex][$x] = $iTotalValue ; Insert total of subtype values into parent type
            $iTotalValue = 0 ; Reset Total
            $iTotalIndex = $i ; Remember index of lat parent type
        EndIf
    Next
    $aResult[$iTotalIndex][$x] = $iTotalValue ; Insert last total of subtype values into parent type
Next
;_ArrayDisplay($aResult, "Third")


; All colors in BGR

; Colors for types/subtypes in col 0
Global $aColTypes = [ 0xADDEFF, 0xFFFFE0, 0xC1B6FF, 0xFFFF00, 0xFF0000, 0xFFFF00 ], $iColTypes = 0

Global $iWhite = 0xFFFFFF, $iRed = 0xCCCCFF, $iGreen = 0xCCFFCC

; Color array
$iRows = UBound($aResult)
$iCols = UBound($aResult, 2)
Global $aColors[$iRows][$iCols]

; Fill color array
For $i = 0 To $iRows - 1
  If StringLeft( $aResult[$i][0], 4 ) = "Type" Then
    $iColorCol0 = $aColTypes[$iColTypes]
    $iColTypes += 1
  EndIf
  $aColors[$i][0] = $iColorCol0
  $aColors[$i][1] = $iWhite
  For $j = 2 To $iCols - 1
    $aColors[$i][$j] = $aResult[$i][$j-1] > $aResult[$i][$j] ? $iRed : $iGreen
  Next
Next
;_ArrayDisplay($aColors, "Colors")


; Listview
GUICreate("Listview", 400, 300)
$idLV = GUICtrlCreateListView("col0        |col1|col2|col3", 10, 10, 380, 280)
$hLV = GUICtrlGetHandle( $idLV )
For $i = 0 To $iRows - 1
  $s = $aResult[$i][0]
  For $j = 1 To $iCols - 1
    $s &= "|" & $aResult[$i][$j]
  Next
  GUICtrlCreateListViewItem($s, $idLV)
Next
GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )
GUISetState(@SW_SHOW)

While 1
  Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
      ExitLoop
  EndSwitch
WEnd


Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
  #forceref $hWnd, $iMsg, $wParam
  Local $tNMHDR, $hWndFrom, $iCode
  $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
  $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
  $iCode = DllStructGetData($tNMHDR, "Code")

  Switch $hWndFrom

    Case $hLV

      Switch $iCode

        Case $NM_CUSTOMDRAW
          Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
          Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage")

          Switch $dwDrawStage                ; Holds a value that specifies the drawing stage

            Case $CDDS_PREPAINT
              ; Before the paint cycle begins
              Return $CDRF_NOTIFYITEMDRAW    ; Notify the parent window of any item-related drawing operations

            Case $CDDS_ITEMPREPAINT
              ; Before painting an item
              Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations

            Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM )
              ; Before painting a subitem
              ;Local $iItem = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")                ; Item index
              ;Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")               ; Subitem index
              ;DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[$iItem][$iSubItem] ) ; Backcolor of item/subitem
              DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")][DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")] )
              Return $CDRF_NEWFONT           ; $CDRF_NEWFONT must be returned after changing font or colors

          EndSwitch

      EndSwitch

  EndSwitch

  Return $GUI_RUNDEFMSG
EndFunc
Posted

That's ace that LarsJ, works a treat.

After a quick look at the code I still cannot fathom just exactly what's going on and how this is doing what it is, but I'm hoping breakfast and a drink will help me along on that front.

Thank you very kindly good man.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

Here is an example that shows the potential of this method. A virtual listview is filled with 10 columns and 10000/50000/100000 rows. All items are drawn with a random background color. I think it's pretty impressive.

 

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiTab.au3>

Opt( "MustDeclareVars", 1 )

Global $hGui, $hLV, $aItems[100000][10], $aColors[100000][10], $iRows
Global $tText = DllStructCreate( "wchar[100]" )

Example()


Func Example()

  ; Create GUI
  $hGui = GUICreate( "Virtual listview", 850, 400 )

  ; Create Tab
  Local $idTab = GUICtrlCreateTab( 10, 10, 850-20, 400-20 )
  GUICtrlCreateTabItem( "10000 rows" )
  GUICtrlCreateTabItem( "50000 rows" )
  GUICtrlCreateTabItem( "100000 rows" )
  GUICtrlCreateTabItem( "" )

  ; Create ListView
  Local $idLV = GUICtrlCreateListView( "", 20, 40, 850-40, 400-60, $LVS_OWNERDATA, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_DOUBLEBUFFER, $LVS_EX_FULLROWSELECT ) )
  $hLV = GUICtrlGetHandle ( $idLV )
  For $i = 0 To 9
    _GUICtrlListView_AddColumn( $hLV, "Col" & $i, 75 )
  Next

  GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )
  GUISetState( @SW_SHOW )

  $iRows = 10000
  FillArray( $iRows )
  FillColors( $iRows )
  GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 )

  ; Message loop
  While 1
    Switch GUIGetMsg()
      Case $idTab
        Switch GUICtrlRead( $idTab )
          Case 0
            $iRows = 10000
          Case 1
            $iRows = 50000
          Case 2
            $iRows = 100000
        EndSwitch
        FillArray( $iRows )
        FillColors( $iRows )
        GUICtrlSendMsg( $idLV, $LVM_SETITEMCOUNT, $iRows, 0 )
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
EndFunc

Func FillArray( $iRows )
  For $i = 0 To $iRows - 1
    If Not Mod( $i, 10000 ) Then _
      WinSetTitle( $hGui, "", "Virtual listview. Fills arrays: " & $i & " rows" )
    For $j = 0 To 9
      $aItems[$i][$j] = $i & "|" & $j
    Next
  Next
  If Not Mod( $i, 10000 ) Then _
    WinSetTitle( $hGui, "", "Virtual listview: " & $i & " rows" )
EndFunc

Func FillColors( $iRows )
  Local $aItemCols = [ 0xCCCCFF, 0xCCFFFF, 0xCCFFCC, 0xFFFFCC, 0xFFCCCC, 0xFFCCFF ] ; BGR
  For $i = 0 To $iRows - 1
    If Not Mod( $i, 10000 ) Then _
      WinSetTitle( $hGui, "", "Virtual listview. Fills arrays: " & $iRows & " rows and " & $i & " colors" )
    For $j = 0 To 9
      $aColors[$i][$j] = $aItemCols[Random(0,5,1)]
    Next
  Next
  If Not Mod( $i, 10000 ) Then _
    WinSetTitle( $hGui, "", "Virtual listview: " & $iRows & " rows and " & $i & " colors" )
EndFunc

Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam )
  #forceref $hWnd, $iMsg, $wParam
  Local $tNMHDR, $hWndFrom, $iCode
  $tNMHDR = DllStructCreate( $tagNMHDR, $lParam )
  $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) )
  $iCode = DllStructGetData( $tNMHDR, "Code" )

  Switch $hWndFrom

    Case $hLV

      Switch $iCode

        Case $LVN_GETDISPINFOW
          ; Fill virtual listview
          Local $tNMLVDISPINFO = DllStructCreate( $tagNMLVDISPINFO, $lParam )
          If BitAND( DllStructGetData( $tNMLVDISPINFO, "Mask" ), $LVIF_TEXT ) Then
            Local $sItem = $aItems[DllStructGetData($tNMLVDISPINFO,"Item")][DllStructGetData($tNMLVDISPINFO, "SubItem")]
            DllStructSetData( $tText, 1, $sItem )
            DllStructSetData( $tNMLVDISPINFO, "TextMax", StringLen( $sItem ) )
            DllStructSetData( $tNMLVDISPINFO, "Text", DllStructGetPtr( $tText ) )
          EndIf

        Case $NM_CUSTOMDRAW
          Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam)
          Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage")

          Switch $dwDrawStage                ; Holds a value that specifies the drawing stage

            Case $CDDS_PREPAINT
              ; Before the paint cycle begins
              Return $CDRF_NOTIFYITEMDRAW    ; Notify the parent window of any item-related drawing operations

            Case $CDDS_ITEMPREPAINT
              ; Before painting an item
              Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any subitem-related drawing operations

            Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM )
              ; Before painting a subitem
              ;Local $iItem = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")                ; Item index
              ;Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")               ; Subitem index
              ;DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[$iItem][$iSubItem] ) ; Backcolor of item/subitem
              DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", $aColors[DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")][DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")] )
              Return $CDRF_NEWFONT           ; $CDRF_NEWFONT must be returned after changing font or colors

          EndSwitch

      EndSwitch

  EndSwitch

  Return $GUI_RUNDEFMSG
EndFunc

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