Jump to content

Listview with clickable cells?


Nhardel
 Share

Recommended Posts

Okay, who is ready to point me to the quickest answer ever on this forum?  I am attempting to make a listview type control and cant get my head around how to pull this off.

Requirements

DYNAMIC number of rows and columns

Autoscroll capabilities for a set ctrl size

Ability to click individual cells

Issues with listviews

I can select an item but that really just selects the whole row - perhaps I am missing a style or exstyle setting?

meets all other requirements

Issues with table.au3  even modified to use input boxes

Don't know how I would stick entire table into some type of ctrl box that would do the autoscroll capabilities when the table starts to get large

Groupbox?

Issues with Embeded excel

No way to know for sure that computer that is being used will have excel

Don't want to go down the road of making sure installed if I don't have to.

Another possible answer is Gridviews

but there isnt much info on these in the forum other than how to interact with one already in another application.  Not sure how I might go about creating one for myself in autoit

So there we go, I have scoured the forums and I can post some code if that helps.  Not sure how it will as the code I have works as expected from an Autoit standpoint, just not what I need.    Let the 'Ah Ha' moments begin! :thumbsup:

Link to comment
Share on other sites

  • Moderators

nhardel,

I have been looking for a way to hightlight individual cells in a ListView for a long time and never found anything really satisfactory. This is the best I have ever managed myself based on my GUIListViewEx UDF:

 

Let me know what you think. :)

M23

Edited by Melba23

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

Wow, my skills must be improving.  I have stumped one of the AutoIT sorcerers. :sorcerer:   

Melba,

Looking thru the sample script, I see your point.  It works but man, ouch.  I don't need to really edit the cell, just recognize what cell it is and maybe change the background color so the user knows that they selected that cell.  I think I can adapt what you have to pull this off, still looking thru it and at work so tons of interuptions.  It really seems like such a simple request for individual selectable cells.  :think:  Thanks for the input.

To all others

Keep the ideas coming.  As you can see there is a demand for a good way to do this. 

Link to comment
Share on other sites

  • Moderators

nhardel,

 

It works but man, ouch

I could not have put it better myself! :D

But seriously, if all you are looking for is to highlight a single cell then it should be possible to reduce the code significantly. We are forecast a wet weekend here - so if you think there is some merit in the line I have taken I could see what I could develop. ;)

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

May be a custom drawn listview:

 

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

Opt( "MustDeclareVars", 1 )

Global $hGui, $hLV, $aHit[2] = [ -1, -1 ] ; $aHit contains row & col of marked cell

MainFunc()

Func MainFunc()

  $hGui = GUICreate( "Mark Cell in Listview", 300, 222 )

  Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", 2, 2, 300-4, 222-4 )
  $hLV = ControlGetHandle( $hGui, "", $idLV )
  For $i = 0 To 49
    GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV )
  Next

  GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )

  GUISetState()

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

EndFunc

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

  Switch $hWndFrom

    Case $hLV

      Switch $iCode

        Case $LVN_ITEMCHANGED
          $bItemChanged = True
          Local $aInfo = GUIGetCursorInfo( $hGui )
          If $aInfo[2] Then
            $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0], $aInfo[1] )
            If $aInfo[0] > -1 And $aInfo[1] > -1 Then
              If $aHit[0] > -1 Then _
                _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] )
              $aHit[0] = $aInfo[0] ; Row
              $aHit[1] = $aInfo[1] ; Col
              _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] )
              _GUICtrlListView_SetItemSelected( $hLV, $aHit[0], False )
            EndIf
          Else
            Local $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam )
            _GUICtrlListView_SetItemSelected( $hLV, DllStructGetData( $tNMLISTVIEW, "Item" ), False )
          EndIf

        Case $NM_CLICK
          If Not $bItemChanged Then
            Local $aInfo = GUIGetCursorInfo( $hGui )
            $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0], $aInfo[1] )
            If $aInfo[0] > -1 And $aInfo[1] > -1 Then
              If $aHit[0] > -1 Then _
                _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] )
              $aHit[0] = $aInfo[0] ; Row
              $aHit[1] = $aInfo[1] ; Col
              _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] )
              _GUICtrlListView_SetItemSelected( $hLV, $aHit[0], False )
            EndIf
          EndIf
          $bItemChanged = False

        Case $NM_RCLICK
          Local $aInfo = GUIGetCursorInfo( $hGui )
          $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0], $aInfo[1] )
          If $aInfo[0] = $aHit[0] And $aInfo[1] = $aHit[1] Then
            _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] )
            _GUICtrlListView_SetItemSelected( $hLV, $aHit[0], False )
            $aHit[0] = -1 ; Row
            $aHit[1] = -1 ; Col
          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 $dwItemSpec = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) ; Item index
              Local $iSubItem   = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem"   ) ; Subitem index
              Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state
              If $dwItemSpec = $aHit[0] Then ; Marked row
                Switch $iSubItem
                  Case $aHit[1] ; Marked column
                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )      ; Forecolor black
                    DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xFFFF00 )      ; Backcolor cyan, BGR
                  Case Else ; Other columns
                    If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0xFFFFFF )    ; Forecolor white
                      DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 )    ; Backcolor dark blue, BGR
                    Else
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )    ; Forecolor black
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )    ; Backcolor white
                    EndIf
                EndSwitch
              Else ; Other rows
                If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0xFFFFFF )
                  DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 )
                Else
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )
                EndIf
              EndIf
              Return $CDRF_NEWFONT                          ; $CDRF_NEWFONT must be returned after changing font or colors

          EndSwitch

      EndSwitch

  EndSwitch

  Return $GUI_RUNDEFMSG
EndFunc

Edit: Added code for NM_CLICK-event.

Edit 2: Right click to unmark.

Edit 3: Don't use this code. Use the code in post 6 or 7.

Edited by LarsJ
Link to comment
Share on other sites

Click to mark. Click once more to unmark.

 

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

Opt( "MustDeclareVars", 1 )

Global $hGui, $hLV, $aHit[2] = [ -1, -1 ] ; $aHit contains row & col of marked cell

MainFunc()

Func MainFunc()

  $hGui = GUICreate( "Mark Cell in Listview", 250, 222 )

  Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", 2, 2, 250-4, 222-4 )
  $hLV = ControlGetHandle( $hGui, "", $idLV )
  For $i = 0 To 49
    GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV )
  Next

  GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )

  GUISetState()

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

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_ITEMCHANGED
          Local $tNMLISTVIEW, $iItem, $aInfo
          $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam )
          $iItem = DllStructGetData( $tNMLISTVIEW, "Item" )
          _GUICtrlListView_SetItemSelected( $hLV, $iItem, False )

          Local $aInfo = GUIGetCursorInfo( $hGui )
          If $aInfo[2] Then
            $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0]-2, $aInfo[1]-2 ) ; Upper left = ( 2, 2 )
            If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then
              If $aHit[0] > -1 Then _
                _GUICtrlListView_RedrawItems( $hLV, $aHit[0], $aHit[0] )
              If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then
                $aHit[0] = $aInfo[0] ; Row
                $aHit[1] = $aInfo[1] ; Col
              Else
                $aHit[0] = -1 ; Row
                $aHit[1] = -1 ; Col
              EndIf
              _GUICtrlListView_RedrawItems( $hLV, $iItem, $iItem )
            EndIf
          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 $dwItemSpec = DllStructGetData( $tNMLVCUSTOMDRAW, "dwItemSpec" ) ; Item index
              Local $iSubItem   = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem"   ) ; Subitem index
              Local $uItemState = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" ) ; Item state
              If $dwItemSpec = $aHit[0] Then ; Marked row
                Switch $iSubItem
                  Case $aHit[1] ; Marked column
                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )      ; Forecolor black
                    DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xFFFF00 )      ; Backcolor cyan, BGR
                  Case Else ; Other columns
                    If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0xFFFFFF )    ; Forecolor white
                      DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 )    ; Backcolor dark blue, BGR
                    Else
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )    ; Forecolor black
                      DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )    ; Backcolor white
                    EndIf
                EndSwitch
              Else ; Other rows
                If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0xFFFFFF )
                  DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 )
                Else
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )
                EndIf
              EndIf
              Return $CDRF_NEWFONT                          ; $CDRF_NEWFONT must be returned after changing font or colors

          EndSwitch

      EndSwitch

  EndSwitch

  Return $GUI_RUNDEFMSG
EndFunc

Edit: Forgot to take into account that the upper left corner of the listview is ( 2, 2 ) and not ( 0, 0 ). Cleaned up the code.

Edited by LarsJ
Link to comment
Share on other sites

Multiple cells.

 

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

Opt( "MustDeclareVars", 1 )

Global $hGui, $hLV

; $aMarkedCells is used to store columns with marked cells. Line (index) in $aMarkedCells is stored in ItemParam. When all
; marks in a row are cleared the line in question in $aMarkedCells can be reused. Line (index) is stored in $aNotUsedLines.
Global $iMarkedCells = 0, $aMarkedCells[10][4] ; Col 3 = number of marked cells per row
Global $iNotUsedLines = 0, $aNotUsedLines[10]

MainFunc()

Func MainFunc()

  $hGui = GUICreate( "Mark Cells in Listview", 250, 222, 300, 300 )

  Local $idLV = GUICtrlCreateListView( "Column 0|Column 1|Column 2", 2, 2, 250-4, 222-4 ), $idx
  $hLV = ControlGetHandle( $hGui, "", $idLV )
  ; ItemParam will be used to keep track of marked cells
  ; Create rows with _GUICtrlListView_AddItem and _GUICtrlListView_AddSubItem
  ; (For rows created with GUICtrlCreateListViewItem ControlID is stored in ItemParam)
  For $i = 0 To 49
    $idx = _GUICtrlListView_AddItem( $hLV, "Cell " & $i & ".0" )
    _GUICtrlListView_AddSubItem( $hLV, $idx, "Cell " & $i & ".1", 1 )
    _GUICtrlListView_AddSubItem( $hLV, $idx, "Cell " & $i & ".2", 2 )
    ;GUICtrlCreateListViewItem( "Cell " & $i & ".0" & "|Cell " & $i & ".1" & "|Cell " & $i & ".2", $idLV )
  Next

  GUIRegisterMsg( $WM_NOTIFY, "WM_NOTIFY" )

  GUISetState()

  While 1
    Switch GUIGetMsg()
      ;Case $GUI_EVENT_SECONDARYDOWN
      ;  _ArrayDisplay( $aMarkedCells, "$aMarkedCells" )
      ;  _ArrayDisplay( $aNotUsedLines, "$aNotUsedLines" )
      Case $GUI_EVENT_CLOSE
        Exit
    EndSwitch
  WEnd

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_ITEMCHANGED
          Local $tNMLISTVIEW, $iItem, $iParam, $aInfo
          $tNMLISTVIEW = DllStructCreate( $tagNMLISTVIEW, $lParam )
          $iItem = DllStructGetData( $tNMLISTVIEW, "Item" )
          $iParam = DllStructGetData( $tNMLISTVIEW, "Param" )
          _GUICtrlListView_SetItemSelected( $hLV, $iItem, False )

          $aInfo = GUIGetCursorInfo( $hGui )
          If $aInfo[2] Then
            $aInfo = _GUICtrlListView_SubItemHitTest( $hLV, $aInfo[0]-2, $aInfo[1]-2 ) ; Upper left = ( 2, 2 )
            If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then
              If Not $iParam Then
                ; First mark in row
                Local $idxMarkedCells
                If $iNotUsedLines Then ; Unused lines in $aMarkedCells?
                  $idxMarkedCells = $aNotUsedLines[$iNotUsedLines-1]
                  $iNotUsedLines -= 1
                Else ; Allocate a new line in $aMarkedCells?
                  $idxMarkedCells = $iMarkedCells
                  $iMarkedCells += 1
                  If Mod( $iMarkedCells, 10 ) = 0 Then _
                    ReDim $aMarkedCells[$iMarkedCells+10][4]
                EndIf
                $aMarkedCells[$idxMarkedCells][3] = 1
                $aMarkedCells[$idxMarkedCells][$aInfo[1]] = 1
                _GUICtrlListView_SetItemParam( $hLV, $iItem, $idxMarkedCells + 1 )
              Else
                $iParam -= 1
                If Not $aMarkedCells[$iParam][$aInfo[1]] Then
                  ; Add mark in row
                  $aMarkedCells[$iParam][$aInfo[1]] = 1
                  $aMarkedCells[$iParam][3] += 1
                Else
                  ; Del mark in row
                  $aMarkedCells[$iParam][$aInfo[1]] = 0
                  $aMarkedCells[$iParam][3] -= 1
                  If Not $aMarkedCells[$iParam][3] Then
                    _GUICtrlListView_SetItemParam( $hLV, $iItem, 0 )
                    ; When all marks in a row are cleared store the line (index) from $aMarkedCells in
                    ; $aNotUsedLines. This line can be reused to store marks in another row in the LV.
                    $aNotUsedLines[$iNotUsedLines] = $iParam
                    $iNotUsedLines += 1
                    If Mod( $iNotUsedLines, 10 ) = 0 Then _
                      ReDim $aNotUsedLines[$iNotUsedLines+10]
                  EndIf
                EndIf
              EndIf
              _GUICtrlListView_RedrawItems( $hLV, $iItem, $iItem )
            EndIf
          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 $lItemlParam = DllStructGetData( $tNMLVCUSTOMDRAW, "lItemlParam" ) ; Item param
              Local $iSubItem    = DllStructGetData( $tNMLVCUSTOMDRAW, "iSubItem"   )  ; Subitem index
              Local $uItemState  = DllStructGetData( $tNMLVCUSTOMDRAW, "uItemState" )  ; Item state
              If $lItemlParam Then ; Marked row
                If $aMarkedCells[$lItemlParam-1][$iSubItem] Then ; Marked column
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )          ; Forecolor black
                  If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row
                    DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0x00FFFF )        ; Backcolor yellow, BGR
                  Else
                    DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xFFFF00 )        ; Backcolor cyan, BGR
                  EndIf
                Else ; Other columns
                  If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row
                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0xFFFFFF )        ; Forecolor white
                    DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 )        ; Backcolor dark blue, BGR
                  Else
                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )        ; Forecolor black
                    DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )        ; Backcolor white
                  EndIf
                EndIf
              Else ; Other rows
                If BitAnd( $uItemState, $CDIS_FOCUS ) Then ; Selected row
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0xFFFFFF )
                  DllStructSetData( $tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600 )
                Else
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrText",   0x000000 )
                  DllStructSetData( $tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF )
                EndIf
              EndIf
              Return $CDRF_NEWFONT                          ; $CDRF_NEWFONT must be returned after changing font or colors

          EndSwitch

      EndSwitch

  EndSwitch

  Return $GUI_RUNDEFMSG
EndFunc
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

×
×
  • Create New...