Jump to content

Listview Checkbox doesn't update


Echbiahn
 Share

Recommended Posts

I'm writing a custom script to help compile data together for monitoring customer databases. On the listview control, I'm trying to use the checkbox feature to allow for ignoring alerts from specific databases. For some reason, the code recognizes the checkboxes in a certain state and execute the code as expected, except they never update the state of the checkbox to the other state (unchecked) or vice versa. I'm using a modified WM_NOTIFY function, could that be the reason it's not recognizing when I call _GUICtrlListView_SetItemChecked, or am I just doing something completely wrong in my code? Code and picture example below...

 

Picture

 

Func LVControl($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo, $CurrentIgnoreList
    $hWndListView = $ListView
    If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $SelectedIndex = DllStructGetData($tInfo, "Index")
                    ConsoleWrite("-->Index:" & @TAB & $SelectedIndex & @LF)
                    If $SelectedIndex = -1 Then ContinueCase
                    ;    <add key="NCPDPIgnoreList" value="3684366,5725342,1485122,1484663,2519152,1406138,1044243,0139469,4613039,0357168,5126760,2784177,2784165,5132181"/>
                    ;Get checked state of selected index
                    If _GUICtrlListView_GetItemChecked($ListView, $SelectedIndex) = True Then
                        ;It is checked, uncheck the box
                        _GUICtrlListView_SetItemChecked($ListView, $SelectedIndex, False)
                        ;remove from ignore list
                        $CurrentIgnoreList = _GetIgnoreList()
                        For $q = 1 To $CurrentIgnoreList[0]
                            If $CurrentIgnoreList[$q] = $dbArray[$SelectedIndex][3] Then
                                _ArrayDelete($CurrentIgnoreList, $q)
                                $NewString = '    <add key="NCPDPIgnoreList" value="'
                                For $z = 1 To UBound($CurrentIgnoreList) - 1
                                    $NewString = $NewString & $CurrentIgnoreList[$z] & ','
                                Next
                                $NewString = StringTrimRight($NewString, 1) & '"/>'
                                _FileWriteToLine(IniRead($Ini, "SET", "SSDBMonitor", "\\10.1.1.96\c$\Program Files (x86)\RNA\SSDBMonitor") & "\SSDBMonitor.exe.config", 13, $NewString, True)
                                ExitLoop
                            EndIf
                        Next
                    Else ;False
                        ;It is unchecked, check the box
                        _GUICtrlListView_SetItemChecked($ListView, $SelectedIndex, True)
                        ;add it to the ignore list
                        $CurrentIgnoreList = _GetIgnoreList()
                        $NewString = '    <add key="NCPDPIgnoreList" value="'
                        For $q = 1 To $CurrentIgnoreList[0]
                            $NewString = $NewString & $CurrentIgnoreList[$q] & ','
                        Next
                        $NewString = $NewString & $dbArray[$SelectedIndex][3] & '"/>'
                        _FileWriteToLine(IniRead($Ini, "SET", "SSDBMonitor", "\\10.1.1.96\c$\Program Files (x86)\RNA\SSDBMonitor") & "\SSDBMonitor.exe.config", 13, $NewString, True)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

 

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