Jump to content

Refresh ListView coloring issue after values changed


Go to solution Solved by DavProg,

Recommended Posts

Hi everyone,

I'm a newbie on this forum, so please be considerate. Thank you. I've been reading a lot on it, though, and am very grateful for the many useful tips/snippets found.

I've been developing an AutoIT script that handles Excel data to be inserted in SAP. In between, there is a GUI that, among others, uses a ListView. In the ListView the data is colored green if the value in BCE/RRN is identical to UpValue, but red if it is not. Upon double-clicking in BCE/RRN certain values get copied into UpValue. This means the value in BCE/RRN and UpValue becomes identical, so the color of the row should turn green... it does not however, and I know it will not by itself, and I have been experimenting with _GUICtrlListView_RedrawItems as well as with $CDDS_POSTPAINT and co, but to no avail. I prefer not the use a virtual listview or overly stuffed UDF's as that is beyond the scope of what I want to reach. I have also noticed the coloring flickers and the colors disappear (turn white) when clicking on a button (functionality removed), so I guess I may have an ordering problem in my code.

I would be very happy if someone could have a look at my code and maybe point out where the error/solution could be. Most likely in the "Region ### _COLOR_ARRAY() function" and/or the "Region ### WM_NOTIFY function"

Thanks in advance.

Davy

Partial script, stripped of all unnecessary parts :

; Standard includes

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <ColorConstants.au3>
#include <GuiListView.au3>
#include <GuiRichEdit.au3>

#Region ### FED categories ###

Const $sFED1 = "FED1"
Const $sFED2 = "FED2"
Const $sFED3 = "FED3"
Const $sFED4 = "FED4"
Const $sFED5 = "FED5"
Const $sFED6 = "FED6"
Const $sFED7 = "FED7"

#EndRegion ### FED categories ###

Global $g_hListView                                                ; Global handler for ListView for the comparison pane

; Create the GUI

Global $hPaneGUI                                                ; GUI handler for the pane window
Local $hWidth = 1340, $hHeight = 600                            ; Initial window size
$hPaneGUI = GUICreate("Client Validation", $hWidth, $hHeight, -1, -1, -1)

; 1. BCE/RRN INFO WINDOW

; Determine positions, width and height of Info window
Local $iX_Info = 2
Local $iY_Info = 2
Local $iInfo_Wd = Int(($hWidth / 2) - 4)
Local $iInfo_Ht = $hHeight - 4

; Create BCE/RRN Info window
Global $hInfo = _GUICtrlRichEdit_Create($hPaneGUI, "", $iX_Info, $iY_Info, $iInfo_Wd, $iInfo_Ht, BitOR($ES_MULTILINE, $ES_READONLY, $WS_VSCROLL))
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")                         ; Register WM_NOTIFY function for Windows Message ID $WM_NOTIFY to open URLS
_GUICtrlRichEdit_SetEventMask($hInfo, $ENM_LINK)                ; Look for notification of link clicks
_GUICtrlRichEdit_AutoDetectURL($hInfo, True)                    ; Enable automatic detection of URLS

; 2. LISTVIEW WINDOW

; Determine positions, width and height of ListView window
Local $iX_LV = Int(($hWidth / 2) + 2)
Local $iY_LV = 2
Local $iLV_Wd = Int(($hWidth / 2) - 4)
Local $iLV_Ht = Int((($hHeight / 3) * 2) - 22)

; Create the ListView window
Global $g_hListView = _GUICtrlListView_Create($hPaneGUI, "", $iX_LV, $iY_LV, $iLV_Wd, $iLV_Ht)
_GUICtrlListView_SetExtendedListViewStyle($g_hListView, BitOR($LVS_EX_BORDERSELECT, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_ONECLICKACTIVATE, $LVS_EX_TWOCLICKACTIVATE))
_GUICtrlListView_SetItemPosition($g_hListView, 0, $iX_LV, $iY_LV)

; Determine width and positions of the array columns
Local $iColumn_Wd = Int($iLV_Wd / 4)
$iX_Column_1 = $iX_LV
$iX_Column_2 = $iX_LV + $iColumn_Wd
$iX_Column_3 = $iX_LV + ($iColumn_Wd * 2)
$iX_Column_4 = $iX_LV + ($iColumn_Wd * 3)

; Add columns
Global $hColumn_1 = _GUICtrlListView_InsertColumn($g_hListView, 0, "Label", $iColumn_Wd)
Global $hColumn_2 = _GUICtrlListView_InsertColumn($g_hListView, 1, "UpValue", $iColumn_Wd)
Global $hColumn_3 = _GUICtrlListView_InsertColumn($g_hListView, 2, "BCE/RRB", $iColumn_Wd)
Global $hColumn_4 = _GUICtrlListView_InsertColumn($g_hListView, 3, "Excel", $iColumn_Wd)

; Set array limit
_GUICtrlListView_SetItemCount($g_hListView, 16)

; 3. BUTTONS

; Determine positions, width and height of 3 buttons
Local $Xi_Button_1 = Int(($hWidth / 2) + 7)
Local $iX_Button_2 = Int(($hWidth / 2) + 92)
Local $iX_Button_3 = Int(($hWidth / 2) + 177)
Local $iY_Button = Int((($hHeight / 3) * 2) - 15)
Local $iButton_Ht = 30
Local $iButton_Wd = 80

; Create 3 buttons
Global $hButton_1_Validate = GUICtrlCreateButton("Validate", $Xi_Button_1, $iY_Button, $iButton_Wd, $iButton_Ht)     ; Validate the data in the UpValue part of the comparison pane
GUICtrlSetResizing($hButton_1_Validate, $GUI_DOCKAUTO)
Global $hButton_2_Reset = GUICtrlCreateButton("Reset", $iX_Button_2, $iY_Button, $iButton_Wd, $iButton_Ht)            ; Reset the data in the UpValue part of the comparison pane
GUICtrlSetResizing($hButton_2_Reset, $GUI_DOCKAUTO)
Global $hButton_3_Refresh = GUICtrlCreateButton("Refresh", $iX_Button_3, $iY_Button, $iButton_Wd, $iButton_Ht)            ; Reset the data in the UpValue part of the comparison pane
GUICtrlSetResizing($hButton_3_Refresh, $GUI_DOCKAUTO)

; 4. EDIT SECTION

; Determine positions, width and height of the Edit section
Local $iX_Edit = Int(($hWidth / 2) + 2)
Local $iY_Edit = Int((($hHeight / 3) * 2) + 20)
Local $iEdit_Wd = Int(($hWidth / 2) - 6)
Local $iEdit_Ht = Int((($hHeight / 3) * 1) - 24)

; Create the Edit section
Local $hEdit = GUICtrlCreateEdit("", $iX_Edit, $iY_Edit, $iEdit_Wd, $iEdit_Ht)
GUICtrlSetResizing($hEdit, $GUI_DOCKAUTO)

; Fill the array for the ListView with data based on the IDType

; TEST DATA*******************************************************

Global $sIDTypeFromExcel = "Person"
; Global $sIDTypeFromExcel = "Company_BCE"
; Global $sIDTypeFromExcel = "Company_ESTA"

Global $userLanguage = "NL"
; Global $userLanguage = "FR"

Global $sFed
Global $sFirstName
Global $sLastName
Global $sCompanyName
Global $sBCEFromExcel
Global $sEstaFromExcel
Global $sRRNFromExcel
Global $sLangFromExcel
Global $sNameFromExcel
Global $sLegalFormFromExcel
Global $sVATFromExcel
Global $sStreetFromExcel
Global $sHouseFromExcel
Global $sAptFromExcel
Global $sPostcodeFromExcel
Global $sCityFromExcel
Global $sCountryFromExcel
Global $sSearchFromExcel
Global $sIBANFromExcel
Global $sBICFromExcel
Global $sBankKeyFromExcel
Global $sBankCountryFromExcel
Global $sContactFirstNameFromExcel
Global $sContactLastNameFromExcel
Global $sContactEmailFromExcel

Global $sStatusFromJson = ""
Global $sFedFromJson = ""
Global $sRRNFromJson = ""
Global $sFirstNameFromJson = ""
Global $sLastNameFromJson = ""
Global $sStreetFromJson = ""
Global $sHouseFromJson = ""
Global $sAptFromJson = ""
Global $sPostcodeFromJson = ""
Global $sCityFromJson = ""
Global $sBCEFromJson = ""
Global $sCompanyNameFromJson = ""
Global $sLegalFormFromJson = ""
Global $sVATFromJson = ""
Global $sEstaFromJson = ""

If $sIDTypeFromExcel = "Person" Then
    $sFed = "Fed3"
    $sLangFromExcel = "FR"
    $sRRNFromExcel = "88081100000"
    $sFirstName = "Christel"
    $sLastName = "Test"
    $sStreetFromExcel = "Rue du Loin"
    $sHouseFromExcel = "10"
    $sAptFromExcel = "1"
    $sPostcodeFromExcel = "4200"
    $sCityFromExcel = "Seraing"
    $sCountryFromExcel = "BE"
    $sIBANFromExcel = ""
    $sBICFromExcel = ""
    $sStatusFromJson = "Levend"
    $sFedFromJson = ""
    $sRRNFromJson = "88081100000"
    $sFirstNameFromJson = "Christel Alison Hubert"
    $sLastNameFromJson = "Test"
    $sStreetFromJson = "Rue des Prez"
    $sHouseFromJson = "22"
    $sAptFromJson = ""
    $sPostcodeFromJson = "4500"
    $sCityFromJson = "Huy"
ElseIf $sIDTypeFromExcel = "Company_BCE" Or $sIDTypeFromExcel = "Company_ESTA" Then
    $sFed = "Fed1"
    $sLangFromExcel = "NL"
    $sBCEFromExcel = "0000033333"
    $sCompanyName = "OFFICE VAN ADVOCATEN"
    $sLegalFormFromExcel = "Commanditaire vennootschap"
    $sVATFromExcel = "BE0000033333"
    $sEstaFromExcel = "2222002222"
    $sStreetFromExcel = "Dorpstraat"
    $sHouseFromExcel = "10"
    $sAptFromExcel = ""
    $sPostcodeFromExcel = "2800"
    $sCityFromExcel = "Mechelen"
    $sCountryFromExcel = "BE"
    $sIBANFromExcel = "BE11166622233344"
    $sBICFromExcel = "BBRUBEBB"
    $sStatusFromJson = "Actief"
    $sFedFromJson = "Rechtspersoon"
    $sBCEFromJson = "0000033333"
    $sCompanyNameFromJson = "ADJUDENTEA"
    $sLegalFormFromJson = "CommV"
    $sVATFromJson = "Sinds 1 januari 2019"
    $sEstaFromJson = "22220022221"
    $sStreetFromJson = "Dorpstraat"
    $sHouseFromJson = "15"
    $sAptFromJson = ""
    $sPostcodeFromJson = "2800"
    $sCityFromJson = "Mechelen"
EndIf

; END TEST DATA*****************************************************

Select

    Case $sIDTypeFromExcel = "Person"

        ; Items to be added as an array to the ListView in case of a physical person
        Local $aItems[14][4]                                    ; Create an array with 14 rows and 4 columns

        ; First column of array: labels

        $aItems[0][0] = "Status"
        $aItems[1][0] = "fedGroup"
        $aItems[2][0] = "supplierLang"
        $aItems[3][0] = "rnNumber"
        $aItems[4][0] = "firstName"
        $aItems[5][0] = "name"
        $aItems[6][0] = "streetName"
        $aItems[7][0] = "houseNumber"
        $aItems[8][0] = "boxNumber"
        $aItems[9][0] = "postalCode"
        $aItems[10][0] = "city"
        $aItems[11][0] = "country"
        $aItems[12][0] = "bankAccount"
        $aItems[13][0] = "bic"

        ; Second column of array: UpValue                   ; Data chosen from RRN/BCE data and Excel file to be copied back to Excel and to SAP

        $aItems[0][1] = "Data received"
        $aItems[1][1] = $sFed
        $aItems[2][1] = $sLangFromExcel
        $aItems[3][1] = $sRRNFromExcel
        $aItems[4][1] = $sFirstName
        $aItems[5][1] = $sLastName
        $aItems[6][1] = $sStreetFromExcel
        $aItems[7][1] = $sHouseFromExcel
        $aItems[8][1] = $sAptFromExcel
        $aItems[9][1] = $sPostcodeFromExcel
        $aItems[10][1] = $sCityFromExcel
        $aItems[11][1] = $sCountryFromExcel
        $aItems[12][1] = $sIBANFromExcel
        $aItems[13][1] = $sBICFromExcel

        ; Third column of array: RRN data

        $aItems[0][2] = $sStatusFromJson
        $aItems[1][2] = ""
        $aItems[2][2] = ""
        $aItems[3][2] = $sRRNFromJson
        $aItems[4][2] = $sFirstNameFromJson
        $aItems[5][2] = $sLastNameFromJson
        $aItems[6][2] = $sStreetFromJson
        $aItems[7][2] = $sHouseFromJson
        $aItems[8][2] = ""
        $aItems[9][2] = $sPostcodeFromJson
        $aItems[10][2] = $sCityFromJson
        $aItems[11][2] = ""
        $aItems[12][2] = ""
        $aItems[13][2] = ""

        ; Fourth column of array: Excel data

        $aItems[0][3] = "Data received"
        $aItems[1][3] = $sFed
        $aItems[2][3] = $sLangFromExcel
        $aItems[3][3] = $sRRNFromExcel
        $aItems[4][3] = $sFirstName
        $aItems[5][3] = $sLastName
        $aItems[6][3] = $sStreetFromExcel
        $aItems[7][3] = $sHouseFromExcel
        $aItems[8][3] = $sAptFromExcel
        $aItems[9][3] = $sPostcodeFromExcel
        $aItems[10][3] = $sCityFromExcel
        $aItems[11][3] = $sCountryFromExcel
        $aItems[12][3] = $sIBANFromExcel
        $aItems[13][3] = $sBICFromExcel

    Case $sIDTypeFromExcel = "Company_BCE" Or $sIDTypeFromExcel = "Company_ESTA"

        ; Items to be added as an array to the ListView in case of a legal person
        Local $aItems[16][4]                                    ; Create an array with 16 rows and 4 columns

        ; First column of array: labels
        $aItems[0][0] = "Status"
        $aItems[1][0] = "fedGroup"
        $aItems[2][0] = "supplierLang"
        $aItems[3][0] = "bceNumber"
        $aItems[4][0] = "companyName"
        $aItems[5][0] = "legalForm"
        $aItems[6][0] = "vatNumber"
        $aItems[7][0] = "estaNumber"
        $aItems[8][0] = "streetName"
        $aItems[9][0] = "houseNumber"
        $aItems[10][0] = "boxNumber"
        $aItems[11][0] = "postalCode"
        $aItems[12][0] = "city"
        $aItems[13][0] = "country"
        $aItems[14][0] = "bankAccount"
        $aItems[15][0] = "bic"

        ; Second column of array: UpValue                   ; Data chosen from RRN/BCE data and Excel file to be copied back to Excel and to SAP

        $aItems[0][1] = "Data received"
        $aItems[1][1] = $sFed
        $aItems[2][1] = $sLangFromExcel
        $aItems[3][1] = $sBCEFromExcel
        $aItems[4][1] = $sCompanyName
        $aItems[5][1] = $sLegalFormFromExcel
        $aItems[6][1] = $sVATFromExcel
        $aItems[7][1] = $sEstaFromExcel
        $aItems[8][1] = $sStreetFromExcel
        $aItems[9][1] = $sHouseFromExcel
        $aItems[10][1] = $sAptFromExcel
        $aItems[11][1] = $sPostcodeFromExcel
        $aItems[12][1] = $sCityFromExcel
        $aItems[13][1] = $sCountryFromExcel
        $aItems[14][1] = $sIBANFromExcel
        $aItems[15][1] = $sBICFromExcel

        ; Third column of array: BCE data

        $aItems[0][2] = $sStatusFromJson
        $aItems[1][2] = $sFedFromJson
        $aItems[2][2] = ""
        $aItems[3][2] = $sBCEFromJson
        $aItems[4][2] = $sCompanyNameFromJson
        $aItems[5][2] = $sLegalFormFromJson
        $aItems[6][2] = $sVATFromJson
        $aItems[7][2] = $sEstaFromJson
        $aItems[8][2] = $sStreetFromJson
        $aItems[9][2] = $sHouseFromJson
        $aItems[10][2] = $sAptFromJson
        $aItems[11][2] = $sPostcodeFromJson
        $aItems[12][2] = $sCityFromJson
        $aItems[13][2] = ""
        $aItems[14][2] = ""
        $aItems[15][2] = ""

        ; Fourth column of array: Excel data

        $aItems[0][3] = "Data received"
        $aItems[1][3] = $sFed
        $aItems[2][3] = $sLangFromExcel
        $aItems[3][3] = $sBCEFromExcel
        $aItems[4][3] = $sCompanyName
        $aItems[5][3] = $sLegalFormFromExcel
        $aItems[6][3] = $sVATFromExcel
        $aItems[7][3] = $sEstaFromExcel
        $aItems[8][3] = $sStreetFromExcel
        $aItems[9][3] = $sHouseFromExcel
        $aItems[10][3] = $sAptFromExcel
        $aItems[11][3] = $sPostcodeFromExcel
        $aItems[12][3] = $sCityFromExcel
        $aItems[13][3] = $sCountryFromExcel
        $aItems[14][3] = $sIBANFromExcel
        $aItems[15][3] = $sBICFromExcel

EndSelect

; Show the GUI
GUISetState()

#Region ### _COLOR_ARRAY() Function for coloring subitems ###

Func _COLOR_ARRAY()

    ; All colors in BGR

    Global $iWhite = 0xFFFFFF, $iRed = 0x674EFF, $iGreen = 0x32CD32, $iGray = 0xC0C0C0

    ; Color array

    $iRows = UBound($aItems)
    $iCols = UBound($aItems, 2)
    Global $aColors[$iRows][$iCols]

    ; Fill color array

    For $i = 0 To $iRows - 1

        ; Fill the whole array with the color white (i.e. make everything visible)

        For $j = 1 To $iCols - 1
            $aColors[$i][$j] = $iWhite
        Next

        ; Fill the left column, i.e. Label column, with the color gray

        $aColors[$i][0] = $iGray

    Next

    ; Fill the first row, i.e. Status, with the color green if alive or active, else color red

    For $j = 1 To $iCols - 1

        If StringInStr($aItems[0][2], "Levend") Or StringInStr($aItems[0][2], "Vivant") Or StringInStr($aItems[0][2], "Actief") Or StringInStr($aItems[0][2], "Actif") = Not 0 Then
            $aColors[0][$j] = $iGreen
        Else
            $aColors[0][$j] = $iRed
        EndIf

    Next

    ; Fill rows 5 through 11, with the color green if value in BCE/RRN is identical to UpValue, else color red

    For $j = 1 To $iCols - 1

        For $i = 3 To 10

            $aColors[$i][$j] = StringCompare($aItems[$i][1], $aItems[$i][2], 1) = Not 0 ? $iRed : $iGreen

        Next

    Next

EndFunc   ;==>_COLOR_ARRAY

#EndRegion ### _COLOR_ARRAY() Function for coloring subitems ###

_COLOR_ARRAY()

; Add the Array to the ListView

_GUICtrlListView_AddArray($g_hListView, $aItems)
; _WRITEMESSAGETOLOG("GUI Functions - Create Pane GUI - Array added to ListView." & " | " & @ScriptLineNumber)


#Region ### WM_NOTIFY function for click handling ###

Global $iDoubleClickSpeed = DllCall('user32.dll', 'uint', 'GetDoubleClickTime')[0]        ; Variable to check the clickspeed and determine a doubleclick

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)                    ; Windows Control: sent by a common control to its parent window when an event has occurred (https://docs.microsoft.com/en-us/windows/win32/controls/wm-notify)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tEnLink, $iCpMin, $iCpMax, $tMsgFilter, $tInfo
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)                ; Contains information about a notification message (https://docs.microsoft.com/en-us/windows/win32/api/richedit/ns-richedit-nmhdr)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))        ; A window handle to the control sending the message
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")                ; An identifier of the control sending the message
    $iCode = DllStructGetData($tNMHDR, "Code")                    ; A notification code

    Switch $hWndFrom                                            ; Check which window sends the message

        Case $hInfo                                                ; Message from the Info Pane

            Select

                Case $iCode = $EN_LINK                            ; When a URL gets clicked
                    $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam)
                    If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then
                        $tEnLink = DllStructCreate($tagENLINK, $lParam)
                        $iCpMin = DllStructGetData($tEnLink, "cpMin")
                        $iCpMax = DllStructGetData($tEnLink, "cpMax")
                        $sGetLink = _GUICtrlRichEdit_GetTextInRange($hInfo, $iCpMin, $iCpMax)    ; Get the URL
                        $sCreateParameter = $sGetLink & " --new-tab"    ; Make sure the URL will open in a new tab
                        ShellExecute("chrome.exe", $sCreateParameter)    ; Open the URL in Google Chrome
                        ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - Link " & $sGetLink & " clicked" & " | " & @ScriptLineNumber)
                    EndIf

            EndSelect

        Case $g_hListView                                        ; Message from the ListView in the comparison pane

            Switch $iCode                                        ; When an Item/Subitem gets clicked in the ListView

                Case $NM_CLICK                                  ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    Global $iIndex = DllStructGetData($tInfo, "Index")
                    Global $iSubItem = DllStructGetData($tInfo, "SubItem")
                    AdlibRegister('LeftClickEvent', $iDoubleClickSpeed)     ; Verify it was not a double-click event, if not go to the Function 'LeftClickEvent'
                    ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent" & " | " & @ScriptLineNumber)

                Case $NM_DBLCLK                                  ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    Global $iIndex = DllStructGetData($tInfo, "Index")
                    Global $iSubItem = DllStructGetData($tInfo, "SubItem")
                    DoubleLeftClickEvent()                        ; Go to the Function 'DoubleLeftClickEvent'
                    ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent" & " | " & @ScriptLineNumber)

                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   ;==>WM_NOTIFY

Func LeftClickEvent()                                            ; Interpret a single click with the left mouse button on an Item/Subitem
    AdlibUnRegister('LeftClickEvent')
    Local $sItemSingleClicked = ""
    $sItemSingleClicked = _GUICtrlListView_GetItemText($g_hListView, $iIndex, $iSubItem)    ; Get the text of what was clicked on

    Switch $iSubItem                                            ; Action based on a column

        Case 0
            ; Do nothing in 1st column
            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

        Case 1

            ; Select the indexes from the ListView based on the IDType

            Select

                Case $sIDTypeFromExcel = "Person"                ; If the ID Type is a physical person (smaller array with data)

                    Switch $iIndex                                ; Action based on a row

                        Case 0
                            ; Do nothing for 1st row
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 1
                            ; Select a FED category
                            SelectFedCategory()                    ; Go to the Function 'SelectFedCategory' (drop down choice)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 2 To 10
                            ; Allow edit data from rows 2 to 10 in separate window
                            EditSecondColumn($sItemSingleClicked)    ; Go to the Function 'EditSecondColumn' (open input box to edit the text)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 11 To 13
                            ; Do nothing for last 3 rows
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                    EndSwitch

                Case $sIDTypeFromExcel = "Company_BCE" Or $sIDTypeFromExcel = "Company_ESTA"    ; If the ID Type is a company (larger array with data)

                    Switch $iIndex                                ; Action based on a row

                        Case 0
                            ; Do nothing for first 3 rows
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 1
                            ; Select a FED category
                            SelectFedCategory()                    ; Go to the Function 'SelectFedCategory' (dropdown list)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 2 To 12
                            ; Allow edit data from rows 2 to 12 in separate window
                            EditSecondColumn($sItemSingleClicked)    ; Go to the Function 'EditSecondColumn' (open input box to edit the text)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 13 To 15
                            ; Do nothing for last 3 rows
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                    EndSwitch

            EndSelect

        Case 2
            ; Do nothing in 3rd column
            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

        Case 3
            ; Do nothing in 4th column
            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - LeftClickEvent on " & $sItemSingleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

    EndSwitch

EndFunc   ;==>LeftClickEvent

Func SelectFedCategory()                                        ; Select a FED category

    ; Create a GUI with various controls.
    Local $hFEDGUI = GUICreate("FED category", 300, 50)

    ; Create a combobox control.
    Local $idComboBox = GUICtrlCreateCombo("", 10, 10, 250, 20)

    ; Switch languages to Add items to the combobox in the form of a dropdown list

    Switch $userLanguage
        Case "NL"
            GUICtrlSetData($idComboBox, "FED1 - Onderworpen Belgische BTW|FED2 - Onderworpen Buitenlandse BTW|FED3 - Natuurlijke persoon in België" & _
                    "|FED4 - Natuurlijke persoon in buitenland|FED5 - Dienstverlener zonder BTW|FED6 - Federale administratie" & _
                    "|FED7 - Andere overheidsdienst", "FED1 - Onderworpen Belgische BTW")
        Case "FR"
            GUICtrlSetData($idComboBox, "FED1 - Asujetti à la TVA belge|FED2 - Asujetti à la TVA étrangère|FED3 - Pers. Physique Résidente" & _
                    "|FED4 - Pers. Physique Non-résidente|FED5 - Prestataire services sans TVA|FED6 - Administration Fédérale (PCG)" & _
                    "|FED7 - Autre Admin. Publique", "FED1 - Asujetti à la TVA belge")
    EndSwitch

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hFEDGUI)

    If @error = 0 Then                                            ; Disable and subsequently re-enable the combobox if the window freezes
        WinSetState("FED category", "", @SW_DISABLE)
        Sleep(250)
        WinSetState("FED category", "", @SW_ENABLE)
    EndIf

    Local $sComboRead = ""                                        ; Variable to read the user's choice from the combobox

    While 1                                                        ; Endless loop until the user exits the combobox or makes a choice

        Switch GUIGetMsg()                                        ; Use simple parameter () to interpret the variable

            Case $GUI_EVENT_CLOSE                                ; If we get the CLOSE message from $hFEDGUI
                ExitLoop                                        ; Exit the loop and thus exit the program

            Case $idComboBox                                    ; Combobox to display a dropdown list with FED choices
                $sFed = ""                                        ; Reset the $sFed variable that was previously used to add a tentative FED category
                $sComboRead = GUICtrlRead($idComboBox)            ; Read the user's choice
                ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - SelectFedCategory - Selected " & $sComboRead & " | " & @ScriptLineNumber)

                ; Switch languages to read the combobox

                Switch $userLanguage
                    Case "NL"
                        Switch $sComboRead
                            Case "FED1 - Onderworpen Belgische BTW"
                                _GUICtrlListView_SetItem($g_hListView, "FED1", $iIndex, $iSubItem)
                                $sFed = $sFED1
                            Case "FED2 - Onderworpen Buitenlandse BTW"
                                _GUICtrlListView_SetItem($g_hListView, "FED2", $iIndex, $iSubItem)
                                $sFed = $sFED2
                            Case "FED3 - Natuurlijke persoon in België"
                                _GUICtrlListView_SetItem($g_hListView, "FED3", $iIndex, $iSubItem)
                                $sFed = $sFED3
                            Case "FED4 - Natuurlijke persoon in buitenland"
                                _GUICtrlListView_SetItem($g_hListView, "FED4", $iIndex, $iSubItem)
                                $sFed = $sFED4
                            Case "FED5 - Dienstverlener zonder BTW"
                                _GUICtrlListView_SetItem($g_hListView, "FED5", $iIndex, $iSubItem)
                                $sFed = $sFED5
                            Case "FED6 - Federale administratie"
                                _GUICtrlListView_SetItem($g_hListView, "FED6", $iIndex, $iSubItem)
                                $sFed = $sFED6
                            Case "FED7 - Andere overheidsdienst"
                                _GUICtrlListView_SetItem($g_hListView, "FED7", $iIndex, $iSubItem)
                                $sFed = $sFED7
                        EndSwitch
                    Case "FR"
                        Switch $sComboRead
                            Case "FED1 - Asujetti à la TVA belge"
                                _GUICtrlListView_SetItem($g_hListView, "FED1", $iIndex, $iSubItem)
                                $sFed = $sFED1
                            Case "FED2 - Asujetti à la TVA étrangère"
                                _GUICtrlListView_SetItem($g_hListView, "FED2", $iIndex, $iSubItem)
                                $sFed = $sFED2
                            Case "FED3 - Pers. Physique Résidente"
                                _GUICtrlListView_SetItem($g_hListView, "FED3", $iIndex, $iSubItem)
                                $sFed = $sFED3
                            Case "FED4 - Pers. Physique Non-résidente"
                                _GUICtrlListView_SetItem($g_hListView, "FED4", $iIndex, $iSubItem)
                                $sFed = $sFED4
                            Case "FED5 - Prestataire services sans TVA"
                                _GUICtrlListView_SetItem($g_hListView, "FED5", $iIndex, $iSubItem)
                                $sFed = $sFED5
                            Case "FED6 - Administration Fédérale (PCG)"
                                _GUICtrlListView_SetItem($g_hListView, "FED6", $iIndex, $iSubItem)
                                $sFed = $sFED6
                            Case "FED7 - Autre Admin. Publique"
                                _GUICtrlListView_SetItem($g_hListView, "FED7", $iIndex, $iSubItem)
                                $sFed = $sFED7
                        EndSwitch

                EndSwitch

                ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - SelectFedCategory - FED set to: " & $sFed & " | " & @ScriptLineNumber)

                ExitLoop

        EndSwitch

    WEnd

    ; Delete the FED selection GUI and all controls.
    GUIDelete($hFEDGUI)

EndFunc   ;==>SelectFedCategory

Func EditSecondColumn(ByRef $sItemClicked)                        ; Open an input box to edit the text that was clicked on in the 2nd column

    Global $sEditedSubItem = ""                                    ; Variable to store the edited text

    $sEditedSubItem = InputBox("Edit", "Manual Edit", $sItemClicked, "", 300, 130)    ; Show input box with the text that was clicked on in the 2nd column
    ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - EditSecondColumn - Text for manual editing: " & $sItemClicked & " | " & @ScriptLineNumber)

    If @error = 1 Then                                            ; If the cancel button is pressed

        ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - EditSecondColumn - Editing cancelled" & " | " & @ScriptLineNumber)
        _GUICtrlListView_SetItem($g_hListView, $sItemClicked, $iIndex, $iSubItem)        ; Put the original text back in the ListView

    ElseIf @error = 0 Then                                        ; If OK was pressed

        If StringCompare($sEditedSubItem, $sItemClicked, $STR_CASESENSE) = Not 0 Then   ; If the text was changed (Case sensitive)

            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - EditSecondColumn - Text changed to: " & $sEditedSubItem & " | " & @ScriptLineNumber)
            _GUICtrlListView_SetItem($g_hListView, $sEditedSubItem, $iIndex, $iSubItem) ; Put the variable in the ListView

        Else                                                    ; If the text remained unchanged

            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - EditSecondColumn - Text left unchanged: " & $sItemClicked & " | " & @ScriptLineNumber)
            _GUICtrlListView_SetItem($g_hListView, $sItemClicked, $iIndex, $iSubItem)    ; Put the original text back in the ListView

        EndIf

    EndIf

EndFunc   ;==>EditSecondColumn

Func DoubleLeftClickEvent()                                        ; Interpret a double click with the left mouse button on an Item/Subitem
    AdlibUnRegister('LeftClickEvent')
    Local $sItemDoubleClicked = ""
    $sItemDoubleClicked = _GUICtrlListView_GetItemText($g_hListView, $iIndex, $iSubItem)    ; Get the text of what was clicked on

    Switch $iSubItem                                            ; Action based on a column

        Case 0
            ; Do nothing in 1st column
            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

        Case 1
            ; Do nothing in 2nd column
            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

        Case 2

            ; Select the indexes from the ListView based on the IDType

            Select

                Case $sIDTypeFromExcel = "Person"                ; If the ID Type is a physical person (smaller array with data)

                    Switch $iIndex                                ; Action based on a row

                        Case 0 To 2
                            ; Do nothing for first 3 rows
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 3 To 10
                            ; Copy from 3rd column to 2nd column
                            _GUICtrlListView_SetItem($g_hListView, $sItemDoubleClicked, $iIndex, $iSubItem - 1)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - " & $sItemDoubleClicked & " copied from column: " & $iSubItem & " to: " & $iSubItem - 1 & " | " & @ScriptLineNumber)

                        Case 11 To 13
                            ; Do nothing for last 3 rows
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                    EndSwitch

                Case $sIDTypeFromExcel = "Company_BCE" Or $sIDTypeFromExcel = "Company_ESTA"    ; If the ID Type is a company (larger array with data)

                    Switch $iIndex                                ; Action based on a row

                        Case 0 To 2
                            ; Do nothing for first 3 rows
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                        Case 3 To 5
                            ; Copy from 3rd column to 2nd column
                            _GUICtrlListView_SetItem($g_hListView, $sItemDoubleClicked, $iIndex, $iSubItem - 1)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - " & $sItemDoubleClicked & " copied from column: " & $iSubItem & " to: " & $iSubItem - 1 & " | " & @ScriptLineNumber)

                        Case 6
                            ; Set VAT number if exists in BCE
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                            Local $sVATSubItem = ""
                            $sVATSubItem = $sItemDoubleClicked

                            If $sVATSubItem = "" Then            ; If nothing is mentioned under VAT at BCE remove VAT
                                _GUICtrlListView_SetItem($g_hListView, $sVATSubItem, $iIndex, $iSubItem - 1)
                                ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - VAT removed" & " | " & @ScriptLineNumber)
                            Else                                ; If VAT 'since...' is mentioned under VAT at BCE add VAT based on BCE number + 'BE'
                                $sVATSubItem = "BE" & $sBCEFromExcel
                                _GUICtrlListView_SetItem($g_hListView, $sVATSubItem, $iIndex, $iSubItem - 1)
                                ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - VAT added: " & $sVATSubItem & " | " & @ScriptLineNumber)
                            EndIf

                        Case 7 To 12
                            ; Copy from 3rd column to 2nd column
                            _GUICtrlListView_SetItem($g_hListView, $sItemDoubleClicked, $iIndex, $iSubItem - 1)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - " & $sItemDoubleClicked & " copied from column: " & $iSubItem & " to: " & $iSubItem - 1 & " | " & @ScriptLineNumber)

                        Case 13 To 15
                            ; Do nothing for last 3 rows
                            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)

                    EndSwitch

            EndSelect

        Case 3
            ; Copy from 4th column to 2nd column
            _GUICtrlListView_SetItem($g_hListView, $sItemDoubleClicked, $iIndex, $iSubItem - 2)
            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent on " & $sItemDoubleClicked & " column: " & $iSubItem & " row: " & $iIndex & " | " & @ScriptLineNumber)
            ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - " & $sItemDoubleClicked & " copied from column: " & $iSubItem & " to: " & $iSubItem - 2 & " | " & @ScriptLineNumber)

    EndSwitch

EndFunc   ;==>DoubleLeftClickEvent

#EndRegion ### WM_NOTIFY function for click handling ###

While 1
    $idMsg = GUIGetMsg()
    Select
        Case $idMsg = $GUI_EVENT_CLOSE
            MsgBox($MB_SYSTEMMODAL, "", "Dialog was closed")
            ExitLoop
        Case $idMsg = $hButton_1_Validate
            MsgBox($MB_SYSTEMMODAL, "", "Validate pressed", 2)
        Case $idMsg = $hButton_2_Reset
            MsgBox($MB_SYSTEMMODAL, "", "Reset pressed", 2)
        Case $idMsg = $hButton_3_Refresh
            MsgBox($MB_SYSTEMMODAL, "", "Refresh pressed", 2)
    EndSelect
WEnd

 

Link to comment
Share on other sites

1 hour ago, DavProg said:

Partial script, stripped of all unnecessary parts

Sorry to say but there is a lot of unnecessary parts in your code.  It would greatly help us if you could reduce it to its very strict minimum (should be about 40-50 lines of code).  You could use this example to start with and to show us your issue.

Link to comment
Share on other sites

The problem with red/green subitems is trivial. The listview background colors in $aColors are not updated when the listview subitem texts are updated.

Link to comment
Share on other sites

10 hours ago, LarsJ said:

The problem with red/green subitems is trivial. The listview background colors in $aColors are not updated when the listview subitem texts are updated.

Hi Lars, thanks for mentionning that. Having looked at your ListView UDF's, I can say you're an expert in this matter and I greatly appreciate your input. The UDF's are over my head, though, at this point. I've been using AutoIT for only a few months and I try to keep things as simple as possible.

I have been trying to figure out at what point and in which way I should be doing updates of the coloring. I've been inserting the _COLOR_ARRAY function at different stages, adding Redraw with Winapi, but I don't seem to capture exactly when and where it should happen.

Link to comment
Share on other sites

Test initially with simple code like this:

Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
  $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
  Global $iIndex = DllStructGetData($tInfo, "Index")
  Global $iSubItem = DllStructGetData($tInfo, "SubItem")
  DoubleLeftClickEvent() ; Go to the Function 'DoubleLeftClickEvent'
  $aColors[$iIndex][1] = $iGreen
  $aColors[$iIndex][2] = $iGreen
  $aColors[$iIndex][3] = $iGreen

Then try to find out why the _COLOR_ARRAY() function does not work automatically. It's connected to $aItems array. When arrays are used in this way, they must be updated when the listview subitem texts are updated.

Link to comment
Share on other sites

57 minutes ago, LarsJ said:

Test initially with simple code like this:

Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
  $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
  Global $iIndex = DllStructGetData($tInfo, "Index")
  Global $iSubItem = DllStructGetData($tInfo, "SubItem")
  DoubleLeftClickEvent() ; Go to the Function 'DoubleLeftClickEvent'
  $aColors[$iIndex][1] = $iGreen
  $aColors[$iIndex][2] = $iGreen
  $aColors[$iIndex][3] = $iGreen

Then try to find out why the _COLOR_ARRAY() function does not work automatically. It's connected to $aItems array. When arrays are used in this way, they must be updated when the listview subitem texts are updated.

Thanks Lars, I'll check that out tomorrow. Had been adding a lot of SAP related script today (quite tough when you hit unexpected character limitations in filters).

I tried adding coloring indications to $NM_DBLCLK before, but not in the way you suggest. Quite interesting. But yes, because I use gets and sets for the subitem texts I may have an issue at that level.

Link to comment
Share on other sites

  • Solution
On 7/7/2022 at 4:42 PM, LarsJ said:

Test initially with simple code like this:

Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
  $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
  Global $iIndex = DllStructGetData($tInfo, "Index")
  Global $iSubItem = DllStructGetData($tInfo, "SubItem")
  DoubleLeftClickEvent() ; Go to the Function 'DoubleLeftClickEvent'
  $aColors[$iIndex][1] = $iGreen
  $aColors[$iIndex][2] = $iGreen
  $aColors[$iIndex][3] = $iGreen

Then try to find out why the _COLOR_ARRAY() function does not work automatically. It's connected to $aItems array. When arrays are used in this way, they must be updated when the listview subitem texts are updated.

Taking into account @LarsJ suggestion about inserting color changes at the level of $NM_DBLCLK and using  _GUICtrlListView_GetItemText() to compare the contents of the changed ListView (since the actual array doesn't change, so comparing the $iIndex/$iSubitem values of $aItems didn't show any changes), delivered a pretty simple solution that works to set the colors after a change with double-click.

Case $NM_DBLCLK                                  ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                    Global $iIndex = DllStructGetData($tInfo, "Index")
                    Global $iSubItem = DllStructGetData($tInfo, "SubItem")
                    DoubleLeftClickEvent()                        ; Go to the Function 'DoubleLeftClickEvent'
                    ; _WRITEMESSAGETOLOG("GUI Functions - WM_NOTIFY - DoubleLeftClickEvent" & " | " & @ScriptLineNumber)

                    $sUpValue = StringStripWS(_GUICtrlListView_GetItemText($g_hListView, $iIndex, 1), 1+2+4)
                    $sBCE_RRN = StringStripWS(_GUICtrlListView_GetItemText($g_hListView, $iIndex, 2), 1+2+4)

                    If StringCompare($sUpValue, $sBCE_RRN, 1) = 0 Then
                        $aColors[$iIndex][1] = $iGreen
                        $aColors[$iIndex][2] = $iGreen
                        $aColors[$iIndex][3] = $iGreen
                    Else
                        $aColors[$iIndex][1] = $iRed
                        $aColors[$iIndex][2] = $iRed
                        $aColors[$iIndex][3] = $iRed
                    EndIf

Thanks again @LarsJ for the practical suggestion.

The full version I'll be implementing will of course use Selects and Switches to make precise comparisons/choices possible.

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