aseitz Posted April 12, 2018 Share Posted April 12, 2018 (edited) I have a list view and using to build a Windows Profile management tool. I am trying to detect when a check is placed in it so that I can highlight the row with a color, and preform the reverse when that is un-checked. Here is what I have so far for the list view portion of the code: expandcollapse popup; ########################################################################### ; Step 7: Display and manage the GUI ; ########################################################################## ; GUI - Create Window and add first row with column names. GUICreate("Profile Tool", $Width , $Height, -1, -1, -1, $WS_MAXIMIZEBOX) $ListView = GUICtrlCreateListView(" # |Profile Name |Last Modified | Profile Size | Profile Type |File Path |Registry Path", 10, 10, $Width - 10, $Height - 100, -1, $LVS_EX_CHECKBOXES) _GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) GUISetState(@SW_SHOW) ; GUI - Create a line item for each profiles registry For $i = 1 To $ProfileRegistry[0] Step 1 $ListBox = GUICtrlCreateListViewItem(" " & $i & "|" & $ProfileNames[$i] & "|" & $ProfileDates[$i] & "|" & $ProfileSizes[$i] & "|" & $ProfileTypes[$i] & "|" & $ProfilePaths[$i] & "|" & $ProfileRegistry[$i], $ListView) Next ;Button 1: Deselect All $DeselectAll_Button = GUICtrlCreateButton("Desect All", 10, 690, 100, 25) ; Button 2: Select All $SelectAll_Button = GUICtrlCreateButton("Select All", 130, 690, 100, 25) ; Button 3: Select All Students $SelectStudents_Button = GUICtrlCreateButton("Select All Students", 250, 690, 100, 25) ; Button 4: Select Old Students $SelectOldStudents_Button = GUICtrlCreateButton("Select Older Students", 420, 690, 100, 25) GUISetState() Do $msg = GUIGetMsg() Select Case $msg = $DeselectAll_Button For $i = 0 To $ProfileRegistry[0] _GUICtrlListView_SetItemChecked($ListView, $i, False) GUICtrlSetColor($ListView, 0x000000) ;Normal color GUISetState() Next Case $msg = $SelectAll_Button For $i = 0 To $ProfileRegistry[0] _GUICtrlListView_SetItemChecked($ListView, $i, True) GUICtrlSetColor($ListView, 0xff0000) ;Selected Color GUISetState() Next Case $msg = $SelectStudents_Button For $i = 0 To $ProfileRegistry[0] If $ProfileTypes[$i] = "Student" Then GUICtrlSetColor($ListView, 0xff0000) ;Selected Color _GUICtrlListView_SetItemChecked($ListView, $i - 1, True) EndIf GUISetState() Next Case $msg = $ListView MsgBox(0, "listview", "clicked=" & GUICtrlGetState($ListView), 2) EndSelect Until $msg = $GUI_EVENT_CLOSE EXIT Thanks in advance! Edited April 12, 2018 by aseitz Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 12, 2018 Moderators Share Posted April 12, 2018 aseitz, The only way I know how to detect a ListView checkbox being actioned is to look for the $TVN_SELCHANGEDA or $TVN_SELCHANGEDW message within a WM_NOTIFY and then check the current state of the checkbox against what is was before (I use an array to hold the current checkbox states). Look in my ChooseFileFolder UDF (the link is in my sig) for some sample code. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
aseitz Posted April 12, 2018 Author Share Posted April 12, 2018 1 minute ago, Melba23 said: aseitz, The only way I know how to detect a ListView checkbox being actioned is to look for the $TVN_SELCHANGEDA or $TVN_SELCHANGEDW message within a WM_NOTIFY and then check the current state of the checkbox against what is was before (I use an array to hold the current checkbox states). Look in my ChooseFileFolder UDF (the link is in my sig) for some sample code. M23 Thank you! I will a give that a go. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now