Jump to content

Custom drawn TreeViews and ListViews


LarsJ
 Share

Recommended Posts

I was looking for some examples of custom drawn TreeViews. I didn't find any so here is two. I have made the examples for ListViews too.

The first example shows some named colors from the MS HTML documentation. The colors are sorted in different ways in five text files in the zipfile. The forecolor, backcolor, color name and RGB value is shown in the GUI's. Remark that the forecolor in the first column in the ListView is bold. Click on the colors in the TreeView to see some of the effects of custom drawing.

The second example enumerates the fonts for the character sets in FontConstants.au3 and shows the fonts in the GUI's. Click on the fonts in the TreeView to see the name of the fonts.

The zipfile contains 5 text files with color definitions and 4 au3-files with GUI's.

CustDrawTvLv.zip

 

2016-03-22:
For colors and fonts in listviews take a look at Colors and fonts in custom drawn ListViews - UDF version.
 

Edited by LarsJ
Link to comment
Share on other sites

  • 4 weeks later...
Link to comment
Share on other sites

  • 5 months later...

jcpetu, Yes it is. The key point is to set the selected state of the selected item to false. If you only use single selection you can use the focused state to keep track of the selected item. If you use multiple selections you have to keep track of the selected items yourself.

In the example in the zip (you need the text files from the original zip) the focused state is used to keep track of the selected item which is painted with a cyan backcolor.

Regards Lars

lvCustDrawColors2.zip

 

2016-03-22:
For a better way to change background color of selected rows take a look at Colors and fonts in custom drawn ListViews - UDF version. Changing state values to be able to set the background color, as is done here, can easily become a mess.

Edited by LarsJ
Link to comment
Share on other sites

  • 9 months later...

How to create a ListView with only a few colored cells. I got a message with that question some days ago.

Here is an example:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>

Opt( "MustDeclareVars", 1 )

Global $hGui, $hLV, $hLVfont, $hLVfontBold, $aColors[1][1] ; Use an array to store cell colors

MainFunc()


Func MainFunc()

    ; Create GUI
    $hGui = GUICreate( "ListView with a few colored and bold cells", 549, 310, 400, 200 )

    ; Create ListView control
    Local $idLV = GUICtrlCreateListView( "", 10, 10, 529, 290, $GUI_SS_DEFAULT_LISTVIEW, BitOR( $WS_EX_CLIENTEDGE, $LVS_EX_FULLROWSELECT ) )
    $hLV = ControlGetHandle( $hGui, "", $idLV )

    ; Add 4 columns
    _GUICtrlListView_AddColumn( $hLV, "Column 0", 125 )
    _GUICtrlListView_AddColumn( $hLV, "Column 1", 125 )
    _GUICtrlListView_AddColumn( $hLV, "Column 2", 125 )
    _GUICtrlListView_AddColumn( $hLV, "Column 3", 125 )

    ; Add 50 rows
    Local $aRows[50][4]
    For $i = 0 To 9
        $aRows[$i][0] = "Row   " & $i & ", Column 0"
        $aRows[$i][1] = "Row   " & $i & ", Column 1"
        $aRows[$i][2] = "Row   " & $i & ", Column 2"
        $aRows[$i][3] = "Row   " & $i & ", Column 3"
    Next
    For $i = 10 To 49
        $aRows[$i][0] = "Row " & $i & ", Column 0"
        $aRows[$i][1] = "Row " & $i & ", Column 1"
        $aRows[$i][2] = "Row " & $i & ", Column 2"
        $aRows[$i][3] = "Row " & $i & ", Column 3"
    Next
    _GUICtrlListView_AddArray( $hLV, $aRows )

    ; ReDim $aColors to match the ListView
    ReDim $aColors[50][4]

    ; Make a few cells colored
    $aColors[ 0][2] = ColorConvert( 0xFF0000 ) ; Set (  0, 2 ) to red
    $aColors[ 5][0] = ColorConvert( 0xFF0000 ) ; Set (  5, 0 ) to red
    $aColors[ 9][1] = ColorConvert( 0xFF0000 ) ; Set (  9, 1 ) to red
    $aColors[ 9][3] = ColorConvert( 0x0000FF ) ; Set (  9, 3 ) to blue
    $aColors[35][1] = ColorConvert( 0x00FF00 ) ; Set ( 35, 1 ) to green
    $aColors[45][1] = ColorConvert( 0x00FF00 ) ; Set ( 45, 1 ) to green
    $aColors[45][2] = ColorConvert( 0x0000FF ) ; Set ( 45, 2 ) to blue
    ; To clear a color set $aColors[row][col] = 0 ; Black

    ; Set row 15 to BlueViolet = 0x8A2BE2
    $aColors[15][0] = ColorConvert( 0x8A2BE2 )
    $aColors[15][1] = ColorConvert( 0x8A2BE2 )
    $aColors[15][2] = ColorConvert( 0x8A2BE2 )
    $aColors[15][3] = ColorConvert( 0x8A2BE2 )

    ; Use a bold font in colored cells
    ; Get the font of the ListView control
    ; Copied from the _GUICtrlGetFont example by KaFu
    ; See http://www.autoitscript.com/forum/index.php?showtopic=124526
    Local $hDC = _WinAPI_GetDC($hLV)
    Local $hFont = _SendMessage($hLV, $WM_GETFONT)
    Local $hObject = _WinAPI_SelectObject($hDC, $hFont)
    Local $lvLOGFONT = DllStructCreate($tagLOGFONT)
    Local $aRet = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFont, 'int', DllStructGetSize($lvLOGFONT), 'ptr', DllStructGetPtr($lvLOGFONT))
    _WinAPI_SelectObject($hDC, $hObject)
    _WinAPI_ReleaseDC($hLV, $hDC)
    $hLVfont = _WinAPI_CreateFontIndirect( $lvLOGFONT )
    Local $iWeight = BitOR( DllStructGetData( $lvLOGFONT, "Weight" ), $FW_BOLD )
    DllStructSetData( $lvLOGFONT, "Weight", $iWeight )
    $hLVfontBold = _WinAPI_CreateFontIndirect( $lvLOGFONT )

    ; Use WM_NOTIFY events to draw the cells
    GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )

    ; Show GUI
    GUISetState( @SW_SHOW, $hGui )

    ; Message loop
    Local $iMsg
    While 1
        $iMsg = GUIGetMsg()
        Switch $iMsg
            Case $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
    GUIDelete( $hGui )
    Exit

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 $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 $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")              ; Item index
                            Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")                  ; Subitem index
                            Local $hDC = DllStructGetData($tNMLVCUSTOMDRAW, "HDC")                            ; Handle to the item's device context
                            If $aColors[$dwItemSpec][$iSubItem] Then
                                _WinAPI_SelectObject($hDC, $hLVfontBold)                                        ; Bold font
                            Else
                                _WinAPI_SelectObject($hDC, $hLVfont)                                            ; Normal font
                            EndIF
                            DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", $aColors[$dwItemSpec][$iSubItem])  ; Forecolor of item text
                            Return $CDRF_NEWFONT                                        ; $CDRF_NEWFONT must be returned after changing font or colors

                    EndSwitch

            EndSwitch

    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc


;RGB to BGR or BGR to RGB
Func ColorConvert($iColor)
    Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16))
EndFunc
You don't need anything else to run the example.

The colored cells are drawn with a bold font. If you don't need that, it should be easy to remove.

Link to comment
Share on other sites

  • 1 month later...

DarkAaly, Can you provide a little more information about what it is you want? Do you have some code that shows what you need? There are already some examples in the posts above but it's probably not what you need.

Regards Lars.

Link to comment
Share on other sites

Thanks for the reply.
This is a small script that they asked me to do, I would like to change the font or color to the folders that contain characters in the name, such as "[APERTA]", "[CHIUSA]" and "[sOSPESA]," but in 'example above was applied to a list.
Thank you. :)
 
 
EDIT: The example that I needed stop working when I try to run "vCustDrawColors.au3" and "tvCustDrawFonts.au3" works but the font do not change.

Nuova cartella.rar

Edited by DarkAaly
Link to comment
Share on other sites

This code will draw the first level items of the TV with a red forecolor:

Case $NM_CUSTOMDRAW
    Local $tNMTVCUSTOMDRAW = DllStructCreate($tagNMTVCUSTOMDRAW, $lParam)
    Local $dwDrawStage = DllStructGetData($tNMTVCUSTOMDRAW, "DrawStage")

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

        Case $CDDS_PREPAINT
            ; Before the paint cycle begins
            Return BitOr( $CDRF_NOTIFYITEMDRAW, _ ; Notify the parent window of any item-related drawing operations
                          $CDRF_NOTIFYPOSTPAINT ) ; Notify the parent window after item-related drawing operations

        Case $CDDS_ITEMPREPAINT
            ; Before painting an item
            Local $hItemSpec  = DllStructGetData($tNMTVCUSTOMDRAW, "ItemSpec")   ; $hItemSpec = $hItem
            If _GUICtrlTreeView_Level( $hTV, $hItemSpec ) = 1 Then
                DllStructSetData( $tNMTVCUSTOMDRAW, "ClrText", 0x0000FF )        ; Forecolor of item text
            EndIf

            Return BitOr( $CDRF_NEWFONT, _        ; $CDRF_NEWFONT must be returned after changing font or colors
                          $CDRF_NOTIFYPOSTPAINT ) ; Notify the parent window after item-related drawing operations

    EndSwitch

Insert the code in function WM_NOTIFY in __Gestore.au3 immediately after these three lines:

Switch $hTV
        Case $hTreeView
                Switch $ID

Lars

Link to comment
Share on other sites

  • 2 weeks later...

Good to see.

Bold

You can use this command:

_GUICtrlTreeView_SetState( $hTV, $item, $TVIS_BOLD )
when you create the TV.
Link to comment
Share on other sites

  • 1 year later...

weirddave, This is code for your example here. The code sets the background color in third column to red/green for last/second last row.

 

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

Global $idLast1 = -1, $idLast2 = -1 ; Last and second last row

$MyGUI = GUICreate("listview items", 320, 200, 0,-1, -1)
$idListview = GUICtrlCreateListView("A|B|C", 10, 10, 250, 155)
$idButton = GUICtrlCreateButton("Add", 125, 175, 70, 20)
$hListview = GUICtrlGetHandle( $idListview )
GUISetState(@SW_SHOW)

GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )

while 1
  $msg = GUIGetMsg()
  Switch $msg
    Case $GUI_EVENT_CLOSE
      ExitLoop
    Case $idButton
      $idLast2 = $idLast1
      $idLast1 = GUICtrlCreateListViewItem("a|b|c", $idListview)
      _GUICtrlListView_RedrawItems( $hListview, 0, _GUICtrlListView_GetItemCount( $hListview ) - 1 )
  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 $hListview

      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 $iItemParam = DllStructGetData( $tNMLVCUSTOMDRAW, "lItemlParam" ) ; Item param (item control ID)
              Local $iSubItem   = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem"    ) ; Subitem index
              Switch $iItemParam
                Case $idLast1 ; Last row
                  Switch $iSubItem
                    Case 2    ; Third column
                      DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0x0000FF )     ; Backcolor red, BGR
                    Case Else ; Other columns
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )     ; Backcolor white
                  EndSwitch
                Case $idLast2 ; Second last row
                  Switch $iSubItem
                    Case 2    ; Third column
                      DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0x00FF00 )     ; Backcolor green, BGR
                    Case Else ; Other columns
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )     ; Backcolor white
                  EndSwitch
                Case Else     ; Other rows
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )         ; Backcolor white
              EndSwitch
              Return $CDRF_NEWFONT                          ; $CDRF_NEWFONT must be returned after changing font or colors

          EndSwitch

      EndSwitch

  EndSwitch

  Return $GUI_RUNDEFMSG
EndFunc
Edited by LarsJ
Link to comment
Share on other sites

This does indeed work. I'm now trying to understand what it's actually doing.

The log window I'm trying to create will need to keep the colour/color, so I figured just comment out all but the last row third column case. This didn't work, I assume because all of the items are being redrawn. So, changed it so that only the last row is redrawn. At first I thought this was working, but as the window filled up and items scrolled off the bottom, I realised that they were losing their colour information.

Does this mean I need to create an ever expanding list containing the colour for each item?

Here's my lightly modified code:

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

Global $idLast1 = -1, $idLast2 = -1 ; Last and second last row
$MyGUI = GUICreate("listview items", 320, 200, 0,-1, -1)
$idListview = GUICtrlCreateListView("A|B|C", 10, 10, 250, 155)
$idButton = GUICtrlCreateButton("Add", 125, 175, 70, 20)
$hListview = GUICtrlGetHandle( $idListview )
GUISetState(@SW_SHOW)

GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )

while 1
  $msg = GUIGetMsg()
  Switch $msg
    Case $GUI_EVENT_CLOSE
      ExitLoop
    Case $idButton
      $idLast1 = GUICtrlCreateListViewItem("a|b|c", $idListview)
      $itemcount = _GUICtrlListView_GetItemCount( $hListview ) - 1
      _GUICtrlListView_RedrawItems( $hListview, $itemcount, $itemcount)
  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 $hListview
      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 $iItemParam = DllStructGetData( $tNMLVCUSTOMDRAW, "lItemlParam" ) ; Item param (item control ID)
              Local $iSubItem   = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem"    ) ; Subitem index
              Switch $iItemParam
                Case $idLast1 ; Last row
                  Switch $iSubItem
                    Case 2    ; Third column
                      DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0x0000FF )     ; Backcolor red, BGR
                  EndSwitch
              EndSwitch
              Return $CDRF_NEWFONT                          ; $CDRF_NEWFONT must be returned after changing font or colors
          EndSwitch
      EndSwitch
  EndSwitch
  Return $GUI_RUNDEFMSG
EndFunc

If I do have to create a list of colours, it will save the problem of how to pass the newest one to WM_NOTIFY :)

Link to comment
Share on other sites

This does indeed work. I'm now trying to understand what it's actually doing.

The log window I'm trying to create will need to keep the colour/color, so I figured just comment out all but the last row third column case. This didn't work, I assume because all of the items are being redrawn. So, changed it so that only the last row is redrawn. At first I thought this was working, but as the window filled up and items scrolled off the bottom, I realised that they were losing their colour information.

Does this mean I need to create an ever expanding list containing the colour for each item?

Here's my lightly modified code:

 

Here's some code to get you started:

#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <GuiListView.au3>
#include <WinAPI.au3>

Global $idLast1 = -1, $idLast2 = -1 ; Last and second last row
$MyGUI = GUICreate("listview items", 320, 200, 0,-1, -1)
_WinAPI_SetClassLongEx($MyGUI, -26, BitAND(_WinAPI_GetClassLongEx($MyGUI, -26), BitNOT(1), BitNOT(2)))
$idListview = GUICtrlCreateListView("A|B|C", 10, 10, 250, 155, 0x200)
_GUICtrlListView_SetExtendedListViewStyle($idListview, $LVS_EX_DOUBLEBUFFER)

$hLV = ControlGetHandle($MyGUI, "", $idListview)
$idButton = GUICtrlCreateButton("Add", 125, 175, 70, 20)
$hListview = GUICtrlGetHandle( $idListview )

$hDC = _WinAPI_GetDC($hLV)
$hFont = _SendMessage($hLV, $WM_GETFONT)
$hObject = _WinAPI_SelectObject($hDC, $hFont)
$lvLOGFONT = DllStructCreate($tagLOGFONT)
$aRet = DllCall('gdi32.dll', 'int', 'GetObjectW', 'ptr', $hFont, 'int', DllStructGetSize($lvLOGFONT), 'ptr', DllStructGetPtr($lvLOGFONT))
_WinAPI_SelectObject($hDC, $hObject)
_WinAPI_ReleaseDC($hLV, $hDC)
$hLVfont = _WinAPI_CreateFontIndirect($lvLOGFONT)
$iWeight = BitOR( DllStructGetData($lvLOGFONT, "Weight"), $FW_BOLD)
DllStructSetData( $lvLOGFONT, "Weight", $iWeight)
$hLVfontBold = _WinAPI_CreateFontIndirect($lvLOGFONT)

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

while 1
  $msg = GUIGetMsg()
  Switch $msg
    Case $GUI_EVENT_CLOSE
      ExitLoop
    Case $idButton
      $idLast1 = GUICtrlCreateListViewItem("a|b|c", $idListview)
      $itemcount = _GUICtrlListView_GetItemCount( $hListview ) - 1
      _GUICtrlListView_RedrawItems( $hListview, $itemcount, $itemcount)
  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
                        Case $CDDS_PREPAINT
                            Return $CDRF_NOTIFYITEMDRAW
                        Case $CDDS_ITEMPREPAINT
                            Return $CDRF_NOTIFYSUBITEMDRAW
                        Case BitOR( $CDDS_ITEMPREPAINT, $CDDS_SUBITEM )
                            Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem")
                            Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec")
                            Local $hDC = DllStructGetData($tNMLVCUSTOMDRAW, "HDC")
                            Switch $iSubItem
                                Case 2
                                    _WinAPI_SelectObject($hDC, $hLVfont)
                                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", ColorConvert(0x000000))
                                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", ColorConvert(0xFF0000))
                                Case Else
                                    _WinAPI_SelectObject($hDC, $hLVfont)
                                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText", ColorConvert(0x000000))
                                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", ColorConvert(0xFFFFFF))
                            EndSwitch
                            Return $CDRF_NEWFONT
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Func ColorConvert($iColor)
    Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16))
EndFunc

As you can see we custom draw the red bg in column 2 but we also custom draw all other colums as normal (white bg/black text)

I've set a couple of styles to the GUI and the ListView to remove any flicker when scrolling etc

Edited by mpower
Link to comment
Share on other sites

I need the colour in column 2 to be dependent on some other variable, not always red, but once it's set to red, green or white, I don't want to change it, it's so I can quickly locate problems which are being logged.

A bit of googling suggests there may be a limit on the number of items I can add to the listview, am I going down completely the wrong path for a log window?

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