MrCreatoR Posted May 7, 2007 Posted May 7, 2007 Hi to all, Is it possible to "know" when user is clicked on the checkbox of item in list view? I need to check if user has just clicked (set or unset the checkbox), even if the item(s) are not selected, and i know that it is possible if you make checking all items in list view, and then compare them to previous created list (in array for example), but i need something more practical, and more reliable. Please, if someone can help me, i will appreciate it, i need it badly Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
PsaltyDS Posted May 7, 2007 Posted May 7, 2007 Can you post a minimal GUI script that shows what you want to read the event from? 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
MrCreatoR Posted May 7, 2007 Author Posted May 7, 2007 Sure, #include <GuiConstants.au3> Opt("GuiOnEventMode", 1) $GUI = GUICreate("Test") GUISetOnEvent(-3, "Quit") $ListView = GUICtrlCreateListView("Column1", 20, 40, 250, 250, -1, $LVS_EX_CHECKBOXES+$WS_EX_OVERLAPPEDWINDOW) For $i = 1 To 5 GUICtrlCreateListViewItem("Item" & $i, $ListView) Next GUISetState() While 1 $GetMouseInfo = GUIGetCursorInfo($GUI) If $GetMouseInfo[2] = 1 And $GetMouseInfo[4] = $ListView Then _ MsgBox(0, "", "Primary button was clicked on the list view (not on the item)" & @LF & _ "But i need to 'know' if i clicked on certain checkbox, and get his ID or somthing") Sleep(10) WEnd Func Quit() Exit EndFunc I usualy post with example, but had no realy ability to do that. I hope you can help me, thanks. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Zedna Posted May 7, 2007 Posted May 7, 2007 Look at my Email_zak project in my signature for example especially Func Oznaceni() and Func PoslatEmail() Resources UDF ResourcesEx UDF AutoIt Forum Search
PsaltyDS Posted May 7, 2007 Posted May 7, 2007 (edited) GuiCtrlListViewItem's do GuiCtrlSetOnEvent as well as any other control: #include <GuiConstants.au3> Opt("GuiOnEventMode", 1) $GUI = GUICreate("Test") GUISetOnEvent(-3, "Quit") $ListView = GUICtrlCreateListView("Column1", 20, 40, 250, 250, -1, $LVS_EX_CHECKBOXES + $WS_EX_OVERLAPPEDWINDOW) Dim $avLVItems[5] For $i = 0 To 4 $avLVItems[$i] = GUICtrlCreateListViewItem("Item" & $i, $ListView) GUICtrlSetOnEvent(-1, "_LVHit") Next GUISetState() While 1 Sleep(20) WEnd Func Quit() Exit EndFunc ;==>Quit Func _LVHit() For $i = 0 To 4 If @GUI_CtrlId = $avLVItems[$i] Then MsgBox(64, "Test", "_LVHit() received checkbox no. " & $i & ", and @GUI_CTRLID = " & @GUI_CtrlId) ExitLoop EndIf Next EndFunc ;==>_LVHit Edited May 7, 2007 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
MrCreatoR Posted May 7, 2007 Author Posted May 7, 2007 Thank you guys, but this method i am using so far (i mentioned this in the first post)...And my app is working with files, when user uncheck the checkbox, the file must be renamed, and when the checkbox is checked, file must be renamed back - but also before renaming, program "must look" if such file not exists on the disk (in the specific directory), but i can not check all the files, they may be to many (over 100), and this is take a long time (reading name of the file in list view item, creating array etc)... hey, the user just clicked on the checkbox, hi/shee have to wait so long to see any results? no, i don't think so....I need some advanced method of checking events of clicked checkbox (and only checkbox, not when the item selected).Thanks again guys, for trying to help, realy.P.SI am still hope that this issue (my problem) have practical sollution, thanks. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
PsaltyDS Posted May 7, 2007 Posted May 7, 2007 (edited) Huh...??? I didn't get any of that from your original post. Can you clarify what it is you think will take so long? One hundred FileExists() checks in a For/Next loop takes 15 to 17 milliseconds: ; Test FileExists() speed $Time = TimerInit() For $n = 1 To 100 $sFile = "C:\Temp\Test" & $n & ".txt" If FileExists($sFile) Then MsgBox(64, "Surprise!", "File acutally exists: " & $sFile) Next MsgBox(64, "Done", "Finished in " & Round(TimerDiff($Time), 1) & "msec.") Edited May 7, 2007 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
MrCreatoR Posted May 8, 2007 Author Posted May 8, 2007 I didn't get any of that from your original postI wrote this:i know that it is possible if you make checking all items in list viewAnd i not need "checking all items", just checking the one that checkbox was seted/unsetted for it.....Can you clarify what it is you think will take so long? One hundred FileExists() checks in a For/Next loop takes 15 to 17 milliseconds:Just checking if files exists yes, this not take so long, but as i sas, it's not only fileexists checking, it's also find the text of list view items to get file name, and also i have images on each item, so i need to change the image for every item that his checkbox was seted/unseted. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
randallc Posted May 8, 2007 Posted May 8, 2007 (edited) hi, [** this is redundant except as an option; see post 5 and 10 as @PsaltyDS says!!] You don't need to check the file exists unless the checkbox has changed, do you? Perhaps [after any primary down click] loop through just the visible controls on the listview, and check if their checkbox status has changed; only reset those/ the one that have/ has changed? _GUICtrlListViewGetTopIndex _GUICtrlListViewGetCounterPage _GUICtrlListViewGetCheckedState You would need to keep track of their current status in an array and check against that? Best, randall [** this is redundant except as an option; see post 5 and 10 as @PsaltyDS says!!] Edited May 8, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
PsaltyDS Posted May 8, 2007 Posted May 8, 2007 The code I included in Post #5 gives the exact control ID of the control that was clicked, given by AutoIt as @GUI_CtrlId because GuiOnEventMode was enabled and GuiCtrlSetOnEvent was done on each LV item as it was added. The control ID given is that of the list view item, not the parent list view. So I thought that part was solved. What did I miss? 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
MrCreatoR Posted May 10, 2007 Author Posted May 10, 2007 Thanks to all guys, realy, i appreciate all the atempts to help me...I realy was looking for a way to check this "directly", just like you check if some button was clicked.When you check the events of every item (this is also not 100%, because the item creation is limited for 4000 items, then you need to insert them, but then the events wont work with inserted items... and so owne), then also "counted" the selection (when you click on the item, not on the chekbox), so you can not realy "tell" if this is checkbox, or the item selection. For example, when i want to check if the litst view have any selected item (by trying to get the text of selected item), and if it is not selected, then this was checkbox clicked, but what if another item is selected, and user click on diferend item checkbox?Thanks to all again, i will have to be complete with what i have (and this is not a litle).P.SBut if somone will find the solution for this, pleas let me know (even by PM), thanks. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
eltorro Posted May 10, 2007 Posted May 10, 2007 See _GUICtrlListViewGetCheckedState in the help file. Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code
MrCreatoR Posted May 10, 2007 Author Posted May 10, 2007 (edited) eltorroSee _GUICtrlListViewGetCheckedState in the help file.Thanks, but i aweare about these functions (and use them ). Edited May 10, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
randallc Posted May 10, 2007 Posted May 10, 2007 (edited) Hi,See my previous post then; I seee your problem with the 4000 item limit;To prove it is possible; scroll to 4200 in this example [works for me][it uses my GUILV UDF, but you could do it without by keeping an array or string of current checked states and using it to compare;]#include "_GuiCtrlListViewUDF1.au3" Opt("GuiOnEventMode", 1) $GUI = GUICreate("Test") GUISetOnEvent(-3, "Quit") _GUISetCheckBoxesPresent (1);****************************** $ListView = _GUICtrlCreateListView("Column1", 20, 40, 250, 250, -1, $LVS_EX_CHECKBOXES+$WS_EX_OVERLAPPEDWINDOW) For $i = 1 To 4200 _GUICtrlCreateListViewItem("Item" & $i, $ListView) Next _GUICtrlListViewHideColumn($listview,1) _GUICtrlListViewSetColumnWidth($listview,0,$LVSCW_AUTOSIZE) GUISetState() While 1 $GetMouseInfo = GUIGetCursorInfo($GUI) If $GetMouseInfo[2] = 1 And $GetMouseInfo[4] = $ListView Then _ MsgBox(0, "", "Item of $LVcheckclicked=" & @LF & __GUICtrlListViewGetItemText($listview, _GUICtrlListViewGetCurCheckClick ( $ListView ))) Sleep(10) WEnd func _GUICtrlListViewGetCurCheckClick ( $h_listview ) $_GUICtrlListViewGetBottomIndex=_GUICtrlListViewGetTopIndex($ListView)+_GUICtrlListViewGetCounterPage($ListView) $_GUICtrlListViewGetBottomIndex=_iif($_GUICtrlListViewGetBottomIndex>$i_LISTVIEWNumItemsView,$i_LISTVIEWNumItemsView,$_GUICtrlListViewGetBottomIndex) for $i= _GUICtrlListViewGetTopIndex($ListView)+1 to $_GUICtrlListViewGetBottomIndex if StringRight($ar_LISTVIEWArray[$i],1)<>_GUICtrlListViewGetCheckedState($ListView,$i-1) then ExitLoop Next if $i>$_GUICtrlListViewGetBottomIndex then return -1 $ar_LISTVIEWArray[$i] = StringTrimRight($ar_LISTVIEWArray[$i], 1) & _GUICtrlListViewGetCheckedState($ListView,$i-1) return $i-1 endfunc Func Quit() Exit EndFuncBest, randallGUI ListView sort[EDIT -shortened a little;...] Edited May 10, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
eltorro Posted May 10, 2007 Posted May 10, 2007 Ok. I believe this code will do what you want. expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) Global Const $LVN_FIRST = -100 Global Const $LVN_ITEMCHANGED = ($LVN_FIRST - 1) Global $LVCLICKEDITEM[4]=[-1,-1] Global $LVITEMCK[2]=[-1,0] Opt("GUIOnEventMode", 1) $GUI = GUICreate("lvCheckTest", 633, 447, 196, 117) GuiSetOnEvent(-3,"ExitFunc") $ListView = GUICtrlCreateListView("Some kind of list", 5, 10, 620, 390) GUICtrlSetOnEvent(-1, "ListViewClick") GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, 0x101E, 0, 610) ;Create a Thousand Items For $x = 0 to 1000 GUICtrlCreateListViewItem("Checked LvItem #"&$x,$ListView) GUISetOnEvent(-1,"ListViewClick") Next $Status1 = GUICtrlCreateLabel("", 0, 428, 315, 17, $SS_SUNKEN) $Status2 = GUICtrlCreateLabel("", 318, 428, 313, 17, $SS_SUNKEN) GUISetState(@SW_SHOW) ;Start WndProc handler GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 Sleep(100) WEnd Func ListViewClick() ConsoleWrite("ListViewClick"&@LF) EndFunc Func _ListViewCheckedEvent() ConsoleWrite("ListViewCheckedEvent"&@LF) Local $state = _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]) ConsoleWrite(StringFormat("Item:%d Checked State is %d"&@LF,$LVCLICKEDITEM[0],$state)) GUICtrlSetData($Status1,StringFormat("Item:%d Checked State is %d"&@LF,$LVCLICKEDITEM[0],$state)) GuiCtrlSetData($Status2,"Checked Event = True") EndFunc Func _ListViewItemClick() ConsoleWrite("ListViewItemClick"&@LF) Local $state = _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]) GUICtrlSetData($Status1,StringFormat("Item:%d Checked State is %d"&@LF,$LVCLICKEDITEM[0],$state)) GuiCtrlSetData($Status2,"Checked Event = False") EndFunc Func ExitFunc() Exit EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $from, $pressed,$event, $retval = $GUI_RUNDEFMSG ;, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then $tagNMHDR =0 Return EndIf ;$from = DllStructGetData($tagNMHDR, 1);not used $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ;<<<<<<this happens before the item changes state $LVCLICKEDITEM = _LVGetInfo($lParam) ; get the Item clicked $LVITEMCK[0]= $LVCLICKEDITEM[0] ; retain the item $LVITEMCK[1]= _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]); retain the state Case $event = $NM_DBLCLK ;<<<<<<this happens before the item changes state $LVCLICKEDITEM = _LVGetInfo($lParam) ; get the Item clicked $LVITEMCK[0]= $LVCLICKEDITEM[0] ; retain the item $LVITEMCK[1]= _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]); retain the state Case $event = $LVN_ITEMCHANGED ;<<<<<<this happens after the item changes state ;make sure the item is still the same $LVCLICKEDITEM = _LVGetInfo($lParam) If $LVCLICKEDITEM[0] = $LVITEMCK[0] Then ;yes _ListViewCheckedEvent() ; event handler for item checked $LVITEMCK[0]=-1 ; reset $LVITEMCK[1]=-1 ; reset Else _ListViewItemClick() ; default action. EndIf EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 Return $retval EndFunc ;==>WM_Notify_Events Func _LVGetInfo($lParam) Local $aClicked[2] Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam) $aClicked[0] = DllStructGetData($tagNMITEMACTIVATE, 4) $aClicked[1] = DllStructGetData($tagNMITEMACTIVATE, 5) if $aClicked[1] < -1 then $aClicked[1] = -1 if $aClicked[0] < -1 then $aClicked[0] = -1 if $aClicked[1] > _GUICtrlListViewGetSubItemsCount($ListView) then $aClicked[1] = -1 if $aClicked[0] > _GUICtrlListViewGetItemCount($ListView) then $aClicked[0] = -1 $tagNMITEMACTIVATE = 0 Return $aClicked EndFunc Whenever a ListView Item is checked, the Function _ListViewCheckedEvent() is called otherwise _ListViewItemClick() is called. The Array, $LVCLICKEDITEM, contains the row in element 0 and the column in element 1. Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code
MrCreatoR Posted May 10, 2007 Author Posted May 10, 2007 Wow! thanks eltorro and randallc, this almoust what i need... but still there one problem - ho to get now the id of clicked checkbox?I need also to set diferend images - for seted checkboxes one image, for unseted, another. And for this i need the ID of clicked item, i wrote this function for that, but it's make "flicking" the list view and somtimes take to long:expandcollapse popupFunc _GUICtrlListViewGetItemID($ListView, $Index=-1, $ReturnType=0) Local $OldSelStatesArr = _GUICtrlListViewGetSelectedIndices($ListView, 1) If Not IsArray($OldSelStatesArr) And $Index <> -2 Then Return -1 If $ReturnType = 1 Then Local $RetItemID[1] Else Local $RetItemID EndIf _GUICtrlListViewSetItemSelState($ListView, -1, 0) If $Index = -1 Or $Index = -2 Then Local $For = 1 Local $Ubound = UBound($OldSelStatesArr)-1 If $Index = -2 Then $For = 0 $Ubound = _GUICtrlListViewGetItemCount($ListView)-1 EndIf For $a = $For To $Ubound $CurrentIndex = $a If $Index = -1 Then $CurrentIndex = $OldSelStatesArr[$a] _GUICtrlListViewSetItemSelState($ListView, $CurrentIndex, 1) If $ReturnType = 1 Then ReDim $RetItemID[UBound($RetItemID)+1] $RetItemID[UBound($RetItemID)-1] = GUICtrlRead($ListView) Else $RetItemID &= GUICtrlRead($ListView) & "|" EndIf _GUICtrlListViewSetItemSelState($ListView, -1, 0) Next If $ReturnType = 1 Then $RetItemID[0] = UBound($RetItemID)-1 Else _GUICtrlListViewSetItemSelState($ListView, $Index, 1) $RetItemID = GUICtrlRead($ListView) EndIf If StringRight($RetItemID, 1) = "|" Then $RetItemID = StringTrimRight($RetItemID, 1) If IsArray($OldSelStatesArr) Then For $i = 1 To UBound($OldSelStatesArr)-1 _GUICtrlListViewSetItemSelState($ListView, $OldSelStatesArr[$i]) Next Else _GUICtrlListViewSetItemSelState($ListView, -1, 0) EndIf Return $RetItemID EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
eltorro Posted May 10, 2007 Posted May 10, 2007 (edited) Wow! thanks eltorro and randallc, this almoust what i need... but still there one problem - ho to get now the id of clicked checkbox? Create your ListViewItems in an array, then the Item number will correspond to the element number of the array which holds the CtrlId. expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> Global Const $WM_NOTIFY = 0x004E Global Const $NM_FIRST = 0 Global Const $NM_CLICK = ($NM_FIRST - 2) Global Const $NM_DBLCLK = ($NM_FIRST - 3) Global Const $LVN_FIRST = -100 Global Const $LVN_ITEMCHANGED = ($LVN_FIRST - 1) Global $LVCLICKEDITEM[4]=[-1,-1] Global $LVITEMCK[2]=[-1,0] ;********************************* Global $lvitems[100] ;********************************* Opt("GUIOnEventMode", 1) $GUI = GUICreate("lvCheckTest", 633, 447, 196, 117) GuiSetOnEvent(-3,"ExitFunc") $ListView = GUICtrlCreateListView("Some kind of list", 5, 10, 620, 390) GUICtrlSetOnEvent(-1, "ListViewClick") GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_CHECKBOXES, $LVS_EX_CHECKBOXES) GUICtrlSendMsg($ListView, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES) GUICtrlSendMsg($ListView, 0x101E, 0, 610) ;Create a some items For $x = 0 to 10 $lvitems[$x] =GUICtrlCreateListViewItem("Checked LvItem #"&$x,$ListView) Next $Status1 = GUICtrlCreateLabel("", 0, 428, 315, 17, $SS_SUNKEN) $Status2 = GUICtrlCreateLabel("", 318, 428, 313, 17, $SS_SUNKEN) GUISetState(@SW_SHOW) ;Start WndProc handler GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") While 1 Sleep(100) WEnd Func ListViewClick() ConsoleWrite("ListViewClick"&@LF) EndFunc Func _ListViewCheckedEvent() ConsoleWrite("ListViewCheckedEvent"&@LF) Local $state = _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]) ConsoleWrite(StringFormat("Item:%d Checked State is %d"&@LF,$LVCLICKEDITEM[0],$state)) GUICtrlSetData($Status1,StringFormat("Item:%d Checked State is %d CtrlId:%d"&@LF,$LVCLICKEDITEM[0],$state,$lvitems[$LVCLICKEDITEM[0]])) GuiCtrlSetData($Status2,"Checked Event = True") EndFunc Func _ListViewItemClick() ConsoleWrite("ListViewItemClick"&@LF) Local $state = _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]) GUICtrlSetData($Status1,StringFormat("Item:%d Checked State is %d CtrlId:%d"&@LF,$LVCLICKEDITEM[0],$state,$lvitems[$LVCLICKEDITEM[0]])) GuiCtrlSetData($Status2,"Checked Event = False") EndFunc Func ExitFunc() Exit EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $from, $pressed,$event, $retval = $GUI_RUNDEFMSG ;, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam);NMHDR (hwndFrom, idFrom, code) If @error Then $tagNMHDR =0 Return EndIf ;$from = DllStructGetData($tagNMHDR, 1);not used $event = DllStructGetData($tagNMHDR, 3) Select Case $wParam = $ListView Select Case $event = $NM_CLICK ;<<<<<<this happens before the item changes state $LVCLICKEDITEM = _LVGetInfo($lParam) ; get the Item clicked $LVITEMCK[0]= $LVCLICKEDITEM[0] ; retain the item $LVITEMCK[1]= _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]); retain the state Case $event = $NM_DBLCLK ;<<<<<<this happens before the item changes state $LVCLICKEDITEM = _LVGetInfo($lParam) ; get the Item clicked $LVITEMCK[0]= $LVCLICKEDITEM[0] ; retain the item $LVITEMCK[1]= _GUICtrlListViewGetCheckedState($ListView,$LVCLICKEDITEM[0]); retain the state Case $event = $LVN_ITEMCHANGED ;<<<<<<this happens after the item changes state ;make sure the item is still the same $LVCLICKEDITEM = _LVGetInfo($lParam) If $LVCLICKEDITEM[0] = $LVITEMCK[0] Then ;yes _ListViewCheckedEvent() ; event handler for item checked $LVITEMCK[0]=-1 ; reset $LVITEMCK[1]=-1 ; reset Else _ListViewItemClick() ; default action. EndIf EndSelect EndSelect $tagNMHDR = 0 $event = 0 $lParam = 0 Return $retval EndFunc ;==>WM_Notify_Events Func _LVGetInfo($lParam) Local $aClicked[2] Local $tagNMITEMACTIVATE = DllStructCreate("int;int;int;int;int;int;int;int;int", $lParam) $aClicked[0] = DllStructGetData($tagNMITEMACTIVATE, 4) $aClicked[1] = DllStructGetData($tagNMITEMACTIVATE, 5) if $aClicked[1] < -1 then $aClicked[1] = -1 if $aClicked[0] < -1 then $aClicked[0] = -1 if $aClicked[1] > _GUICtrlListViewGetSubItemsCount($ListView) then $aClicked[1] = -1 if $aClicked[0] > _GUICtrlListViewGetItemCount($ListView) then $aClicked[0] = -1 $tagNMITEMACTIVATE = 0 Return $aClicked EndFuncoÝ÷ Ú«¨µéÚoÝ÷ Øç¢ÛkÊZr)àjëh×6GuiSetState(@SW_LOCK)oÝ÷ Ù·¢·²¢ë¶Ø^f zÄázwV®¶sdwV6WE7FFR5uõTäÄô4²when finished. Edited May 11, 2007 by eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code
eltorro Posted May 10, 2007 Posted May 10, 2007 (edited) This is really overkill. I mean unless you need to know if another column is clicked, you could just use the code that PsaltyDS posted in post #5 If you need to have a dynamically expanding array, then thats easy to work out. Edited May 10, 2007 by eltorro Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code
randallc Posted May 11, 2007 Posted May 11, 2007 (edited) I need also to set diferend images - for seted checkboxes one image, for unseted, another. And for this i need the ID of clicked itemI don't see why you need the "ID" of the Checkbox'd LVitem (if it even has one!) My understanding is that LV items after 4096 or whatever do not have a control, so no ID!? [EDIT] - changed my comment; see next post; I don't think you can set an image after the limit! Can you show a script again? Edited May 11, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
randallc Posted May 11, 2007 Posted May 11, 2007 (edited) I don't see why you need the "ID" of the Checkbox'd LVitem (if it even has one!) My understanding is that LV items after 4096 or whatever do not have a control, so no ID!? [EDIT] - changed my comment; see next post; I don't think you can set an image after the limit! Can you show a script again?Hi, I don't think you can set an image after the limit! [they all seem to stay as the LV default image] Can anyone show how ? Best, randall - so you may as well stick to the post #5 method which works very well! [or use my method to find the listview item number, and then only change the text - [ as a workaround - you could 1. Find first unchecked item with a default icon 2. swap that item to the end 3. swap current clicked item to that item; so you can change that image!]] Edited May 11, 2007 by randallc ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
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