WiSp Posted August 5, 2010 Posted August 5, 2010 (edited) What I'd like to do is if specified items are selected and then the check box on any one of the items is checked, check all unchecked items or uncheck all checked items. Hopefully that makes sense, attached is a sample mockup of the non-working code, AutoIT Version 3.3.6.1: How do I capture the event and make it cycle through all items to make it check or uncheck all selected items? The last multiselect topic I found are all from 2007 or earlier and I'm not sure if they apply anymore. Thanks in Advance for any help you can provide. #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Checkbox Test", 534, 173, 192, 114) $ListView1 = GUICtrlCreateListView("First Column|Second Column", 8, 8, 513, 153, BitOR($LVS_REPORT,$LVS_SHOWSELALWAYS), BitOR($WS_EX_CLIENTEDGE,$LVS_EX_GRIDLINES,$LVS_EX_CHECKBOXES,$LVS_EX_FULLROWSELECT)) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 200) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 300) $ListView1_0 = GUICtrlCreateListViewItem("First Row First Item|First Row Second Item", $ListView1) $ListView1_1 = GUICtrlCreateListViewItem("Seconds Row First Item|Second Row Second Item", $ListView1) $ListView1_2 = GUICtrlCreateListViewItem("Third Row First Item|Third Row Second Item", $ListView1) $ListView1_3 = GUICtrlCreateListViewItem("Fourth Row First Item|Fourth Row Second Item", $ListView1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited August 5, 2010 by WiSp
PsaltyDS Posted August 5, 2010 Posted August 5, 2010 (edited) Maybe like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Opt("GuiOnEventMode", 1) $Form1 = GUICreate("Checkbox Test", 600, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $iLVStyle = BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS) $iLVExtStyle = BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT) $ListView1 = GUICtrlCreateListView("First Column|Second Column", 10, 10, 470, 380, $iLVStyle, $iLVExtStyle) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 190) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 190) For $n = 0 To 9 GUICtrlCreateListViewItem("Row: " & $n & "; First Item|Row: " & $n & "; Second Item", $ListView1) Next GUICtrlCreateButton("Check Selected", 490, 20, 100, 30) GUICtrlSetOnEvent(-1, "_BtnHit") GUICtrlCreateButton("Clear Selected", 490, 70, 100, 30) GUICtrlSetOnEvent(-1, "_BtnHit") GUICtrlCreateButton("Select All", 490, 120, 100, 30) GUICtrlSetOnEvent(-1, "_BtnHit") GUICtrlCreateButton("Clear All", 490, 170, 100, 30) GUICtrlSetOnEvent(-1, "_BtnHit") GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func _BtnHit() Switch ControlGetText(@GUI_WinHandle, "", @GUI_CtrlHandle) Case "Check Selected" _LVChkBx(True, False) Case "Clear Selected" _LVChkBx(False, False) Case "Select All" _LVChkBx(True, True) Case "Clear All" _LVChkBx(False, True) EndSwitch EndFunc ;==>_BtnHit Func _LVChkBx($f_Check, $f_All) Local $hLV = ControlGetHandle($Form1, "", $ListView1) Local $iCnt If $f_All Then _GUICtrlListView_SetItemChecked($hLV, -1, $f_Check) Else $iCnt = ControlListView($Form1, "", $hLV, "GetItemCount") For $n = 0 To $iCnt - 1 If ControlListView($Form1, "", $hLV, "IsSelected", $n) Then _GUICtrlListView_SetItemChecked($hLV, $n, $f_Check) Next EndIf EndFunc ;==>_LVChkBx Func _Quit() Exit EndFunc ;==>_Quit In general, we don't recommend mixing the UDF control functions with the native AutoIt controls, but I don't think there is a way to work with an LV item checkbox without it. Edited August 5, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
WiSp Posted August 5, 2010 Author Posted August 5, 2010 Yeah I know it's messy but I really don't have a choice. Thanks for your sample code, I'll see if it integrates well with the rest of the program I'm working on, if not I hope you don't mind if I poke you again When I'm done with it I'll post it up in the Example scripts forum. It's a program that searches for and archives old files of a specified age but also does a bit of cost analysis on how much a OU is costing the agency by storing their files on main storage vs nearline. Will
WiSp Posted August 6, 2010 Author Posted August 6, 2010 (edited) PsaltyDS that worked like a charm, I integrated it into the script with no difficulty. Here's a screen cap of the application, it's got a bit more work to go but it's making progress. Thanks again! Will Edited August 6, 2010 by WiSp
zerrar Posted June 24, 2011 Posted June 24, 2011 Hi all, just to reopen this topic, I would like to ask whether in the example it is possible to add groups and how would that look like? Thanks!
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