Redemption Posted September 20, 2012 Share Posted September 20, 2012 Hello all, For one year i seek on internet a method of checkall-uncheckall on a treeviewlist, i never found. So finaly i decided to develop a function for that. That code it is un complete example For integrate at your treeview, you must copy Dim $checkverif[1][2], the 2 functions, the variable $declared. And call the functions CheckAll_UncheckALL_Declaration before the "while 1" and CheckAll_UncheckALL_Execution inside the "While 1" CheckAll_UncheckALL_Declaration(treeview_name) CheckAll_UncheckALL_Execution(treeview_name, array_declaration) expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiTreeView.au3> #include <WindowsConstants.au3> Dim $checkverif[1][2] Func CheckAll_UncheckALL_Declaration($tree) ;Create variables of verification state ;--------------------------------------------------- $firstvisible = _GUICtrlTreeView_GetFirstVisible($tree) ;Get ID of the first visible element $countverif = 0 if _GUICtrlTreeView_GetChildren($tree, $firstvisible) Then ;if the fisrt visible element has children $checkverif[$countverif][0] = $firstvisible ;Get ID of fisrt visible element $checkverif[$countverif][1] = False $countverif = $countverif + 2 ReDim $checkverif[$countverif][2] ;Resize the array $countverif = $countverif - 1 ;replacing the read array cursor EndIf ;this part make the same things but for other parents $getnext = _GUICtrlTreeView_GetNext($tree, $firstvisible) While $getnext <> 0 if _GUICtrlTreeView_GetChildren($tree, $getnext) Then $checkverif[$countverif][0] = $getnext $checkverif[$countverif][1] = False $countverif = $countverif + 2 ReDim $checkverif[$countverif][2] $countverif = $countverif - 1 EndIf $getnext = _GUICtrlTreeView_GetNext($tree, $getnext) WEnd _ArrayDelete($checkverif, $countverif) ;delete the last row because empty Return $checkverif EndFuncFunc CheckAll_UncheckALL_Execution($tree, $checkverif) $countverif = UBound($checkverif)-1 For $i = 0 to $countverif Step 1 $state = _GUICtrlTreeView_GetChecked($tree, $checkverif[$i][0]) ;Get state of the parent if $state <> $checkverif[$i][1] Then $checkverif[$i][1] = _GUICtrlTreeView_GetChecked($tree, $checkverif[$i][0]) $firstchild = _GUICtrlTreeView_GetFirstChild($tree, $checkverif[$i][0]) ;Get ID of the first child _GUICtrlTreeView_Expand($tree, $checkverif[$i][0]) ;Expand th parent _GUICtrlTreeView_SetChecked($tree, $firstchild, $state) ;Check or unchek according to the texte $child = _GUICtrlTreeView_GetNextSibling($tree, $firstchild) ;Get ID of next child while _GUICtrlTreeView_GetNextSibling($tree, $child) <> 0 ;While nextsibling don't return 0 _GUICtrlTreeView_SetChecked($tree, $child, $state) $child = _GUICtrlTreeView_GetNextSibling($tree, $child) WEnd _GUICtrlTreeView_SetChecked($tree, $child, $state) $checkverif[$i][1] = $state EndIf Next $declared = $checkverif Return $declared EndFunc Local $GUI, $hImage, $iImage, $hItem, $fDragging = False, $aDrag, $hTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES);~ Create dialog box $GUI = GUICreate("TreeView Create Drage Image", 400, 300) $hTreeView = GUICtrlGetHandle(GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)) _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 1 To Random(2, 10, 1) $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x)) For $y = 1 To Random(2, 10, 1) _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y)) Next Next _GUICtrlTreeView_EndUpdate($hTreeView)$declared = CheckAll_UncheckALL_Declaration($hTreeView) ;Call the function GUISetState() While 1 CheckAll_UncheckALL_Execution($hTreeView, $declared) ;Appel de la fonction $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd Link to comment Share on other sites More sharing options...
Kebarb Posted September 20, 2012 Share Posted September 20, 2012 Hello Redemption,fine script and thnaks for sharing! It will be usefull on some codes I`m working with.However I have found some little errors on that I have corrected.So in the following the fully functional script.Cheers, Kebarbexpandcollapse popup#include #include #include #include Dim $checkverif[1][2] Func CheckAll_UncheckALL_Declaration($tree) ;Create variables of verification state ;--------------------------------------------------- $firstvisible = _GUICtrlTreeView_GetFirstVisible($tree) ;Get ID of the first visible element $countverif = 0 if _GUICtrlTreeView_GetChildren($tree, $firstvisible) Then ;if the fisrt visible element has children $checkverif[$countverif][0] = $firstvisible ;Get ID of fisrt visible element $checkverif[$countverif][1] = False $countverif = $countverif + 2 ReDim $checkverif[$countverif][2] ;Resize the array $countverif = $countverif - 1 ;replacing the read array cursor EndIf ;this part make the same things but for other parents $getnext = _GUICtrlTreeView_GetNext($tree, $firstvisible) While $getnext <> 0 if _GUICtrlTreeView_GetChildren($tree, $getnext) Then $checkverif[$countverif][0] = $getnext $checkverif[$countverif][1] = False $countverif = $countverif + 2 ReDim $checkverif[$countverif][2] $countverif = $countverif - 1 EndIf $getnext = _GUICtrlTreeView_GetNext($tree, $getnext) WEnd _ArrayDelete($checkverif, $countverif) ;delete the last row because empty Return $checkverif EndFunc Func CheckAll_UncheckALL_Execution($tree, $checkverif) $countverif = UBound($checkverif)-1 For $i = 0 to $countverif Step 1 $state = _GUICtrlTreeView_GetChecked($tree, $checkverif[$i][0]) ;Get state of the parent if $state <> $checkverif[$i][1] Then $checkverif[$i][1] = _GUICtrlTreeView_GetChecked($tree, $checkverif[$i][0]) $firstchild = _GUICtrlTreeView_GetFirstChild($tree, $checkverif[$i][0]) ;Get ID of the first child _GUICtrlTreeView_Expand($tree, $checkverif[$i][0]) ;Expand th parent _GUICtrlTreeView_SetChecked($tree, $firstchild, $state) ;Check or unchek according to the texte $child = _GUICtrlTreeView_GetNextSibling($tree, $firstchild) ;Get ID of next child while _GUICtrlTreeView_GetNextSibling($tree, $child) <> 0 ;While nextsibling don't return 0 _GUICtrlTreeView_SetChecked($tree, $child, $state) $child = _GUICtrlTreeView_GetNextSibling($tree, $child) WEnd _GUICtrlTreeView_SetChecked($tree, $child, $state) $checkverif[$i][1] = $state EndIf Next $declared = $checkverif Return $declared EndFunc Local $GUI, $hImage, $iImage, $hItem, $fDragging = False, $aDrag, $hTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES);~ Create dialog box $GUI = GUICreate("TreeView Create Drage Image", 400, 300) $hTreeView = GUICtrlGetHandle(GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)) _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 1 To Random(2, 10, 1) $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x)) For $y = 1 To Random(2, 10, 1) _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y)) Next Next _GUICtrlTreeView_EndUpdate($hTreeView) $declared = CheckAll_UncheckALL_Declaration($hTreeView) ;Call the function GUISetState() While 1 CheckAll_UncheckALL_Execution($hTreeView, $declared) ;Appel de la fonction $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd Link to comment Share on other sites More sharing options...
guinness Posted September 20, 2012 Share Posted September 20, 2012 The Forum has lost the include files and does anyone use Tidy.exe? Or is it the Forum too? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Mechaflash Posted September 20, 2012 Share Posted September 20, 2012 does anyone use Tidy.exe? Or is it the Forum too?Forum. On edit it breaks some formatting =( Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
guinness Posted September 20, 2012 Share Posted September 20, 2012 (edited) Well I don't think they use Tidy or proper indentation as If is if in the examples above. To overcome this is pretty easy, just toggle the editing mode to plain (basic) text and voila it works. The button is located next to 'Remove Format' and 'Special BBCode.' Edited September 20, 2012 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Redemption Posted September 20, 2012 Author Share Posted September 20, 2012 (edited) Hello Redemption, fine script and thnaks for sharing! It will be usefull on some codes I`m working with. However I have found some little errors on that I have corrected. So in the following the fully functional script. Cheers, Kebarb expandcollapse popup#include #include #include #include Dim $checkverif[1][2] Func CheckAll_UncheckALL_Declaration($tree) ;Create variables of verification state ;--------------------------------------------------- $firstvisible = _GUICtrlTreeView_GetFirstVisible($tree) ;Get ID of the first visible element $countverif = 0 if _GUICtrlTreeView_GetChildren($tree, $firstvisible) Then ;if the fisrt visible element has children $checkverif[$countverif][0] = $firstvisible ;Get ID of fisrt visible element $checkverif[$countverif][1] = False $countverif = $countverif + 2 ReDim $checkverif[$countverif][2] ;Resize the array $countverif = $countverif - 1 ;replacing the read array cursor EndIf ;this part make the same things but for other parents $getnext = _GUICtrlTreeView_GetNext($tree, $firstvisible) While $getnext <> 0 if _GUICtrlTreeView_GetChildren($tree, $getnext) Then $checkverif[$countverif][0] = $getnext $checkverif[$countverif][1] = False $countverif = $countverif + 2 ReDim $checkverif[$countverif][2] $countverif = $countverif - 1 EndIf $getnext = _GUICtrlTreeView_GetNext($tree, $getnext) WEnd _ArrayDelete($checkverif, $countverif) ;delete the last row because empty Return $checkverif EndFunc Func CheckAll_UncheckALL_Execution($tree, $checkverif) $countverif = UBound($checkverif)-1 For $i = 0 to $countverif Step 1 $state = _GUICtrlTreeView_GetChecked($tree, $checkverif[$i][0]) ;Get state of the parent if $state <> $checkverif[$i][1] Then $checkverif[$i][1] = _GUICtrlTreeView_GetChecked($tree, $checkverif[$i][0]) $firstchild = _GUICtrlTreeView_GetFirstChild($tree, $checkverif[$i][0]) ;Get ID of the first child _GUICtrlTreeView_Expand($tree, $checkverif[$i][0]) ;Expand th parent _GUICtrlTreeView_SetChecked($tree, $firstchild, $state) ;Check or unchek according to the texte $child = _GUICtrlTreeView_GetNextSibling($tree, $firstchild) ;Get ID of next child while _GUICtrlTreeView_GetNextSibling($tree, $child) <> 0 ;While nextsibling don't return 0 _GUICtrlTreeView_SetChecked($tree, $child, $state) $child = _GUICtrlTreeView_GetNextSibling($tree, $child) WEnd _GUICtrlTreeView_SetChecked($tree, $child, $state) $checkverif[$i][1] = $state EndIf Next $declared = $checkverif Return $declared EndFunc Local $GUI, $hImage, $iImage, $hItem, $fDragging = False, $aDrag, $hTreeView Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES);~ Create dialog box $GUI = GUICreate("TreeView Create Drage Image", 400, 300) $hTreeView = GUICtrlGetHandle(GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)) _GUICtrlTreeView_BeginUpdate($hTreeView) For $x = 1 To Random(2, 10, 1) $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x)) For $y = 1 To Random(2, 10, 1) _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Child", $y)) Next Next _GUICtrlTreeView_EndUpdate($hTreeView) $declared = CheckAll_UncheckALL_Declaration($hTreeView) ;Call the function GUISetState() While 1 CheckAll_UncheckALL_Execution($hTreeView, $declared) ;Appel de la fonction $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf WEnd Hello, thank you for reply, i saw your code and i don't find your correction. Give me the ligne please Edited September 20, 2012 by Redemption 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