JujuLand Posted April 5, 2012 Share Posted April 5, 2012 Hi, I haven't found any solution on french forums and hope you have one. I have a GUICtrlTreeViewItem created by the _GUICtrlTreeView_InsertItem() function. It works, but this udf function returns the handle, and I found no way to keep the control ID that I need to check the item. Is there a way to keep it, or a way to check the item using handle ? Thanks A+ Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2012 Moderators Share Posted April 5, 2012 JujuLand,If you use the UDF function to create the TreeViewItem, then you need to use the other UDF functions to interact with it. Just use the handle you get as a return on creation to identify the item.The ControlID returned by the native AutoIt function (GUICtrlCreateTreeViewItem) is actually the index of the control in the internal Autoit control array - if you use the UDF to create the Item, there will be no entry in the array and so a ControlID makes no sense.Perhaps if you posted a small script to show the exact problem you are having we could offer some more help. A bientot, 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...
JujuLand Posted April 5, 2012 Author Share Posted April 5, 2012 (edited) Thanks for the answer. Well, I need the control ID to check the item with the function GUICrtlStatus(), so if there is no function to set it with the handle, I will must use another way. For now, I only see one other way to insert an item (and keep the ID), but a bit complicated. Add an item with GUICtrlCreateTreeViewItem (at the end of the TreeView) And then in a for next boucle, beginning with the last item-1, copy the content to the next item , and set correctly the status, till the item where I want to insert the new item. Have you a better way ? Here is a short part of code how I'm doing for now (and missing) : $rgItem=SearchExtRange($extNew,0) if $rgItem=-1 Then $sp1 = StringLeft($string,10-StringLen($extNew)) & "|" $sp2 = StringLeft($string,35-StringLen("Win2Tux.file")) & "|" $sp3 = StringLeft($string,23) $item= StringLower($extNew) & $sp1 & "Win2Tux.file" & $sp2 & $sp3 $rgItem=SearchPosInExt($extNew) ; return the range where the new item must be inserted (after this range) msgbox(0,"pos",$rgItem) $handle=_GUICtrlTreeView_InsertItem($extensionView,$item,0,$extArray[$rgItem][4]) ; $nbExt+=1 ReDim $extArray[$nbExt+1][5] for $rg=$nbExt To $rgItem+1 for $col=0 to 5 $extArray[$rg][$col] = $extArray[$rg-1][$col] Next Next $extArray[$rgItem][0] =$extNew $extArray[$rgItem][1] ="Win2Tux.file" $extArray[$rgItem][2] ="" $extArray[$rgItem][3] =$handle ; <<< I need here to keep the controlID $extArray[$rgItem][4] =$handle GUICtrlSetState($extArray[$rgItem][3], $GUI_CHECKED) ; <<< for now, it can't work $nbW2T+=1 GUICtrlSetData($W2Tnumber,$nbW2T) Cancel0() _WinAPI_RedrawWindow($MyGUI, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW)) Else msgbox(0,$txt120,$txt121 & $extNew & $txt122) EndIf Thanks A+ Edited April 5, 2012 by JujuLand Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2012 Moderators Share Posted April 5, 2012 JujuLand, I need the control ID to check the item with the function GUICrtlStatusWhat function is that? Is it a UDF? If so where is the code because it is not one of the standard ones. Looking at that code (which makes little sense out of context) I see you are trying to use GUICtrlSetState($extArray[$rgItem][3], $GUI_CHECKED) to check an item. As I explained above, if the item is created with the UDF function, you cannot use the native Autoit functions to interact with it as you do not have a ControlID, only a handle. But the UDF _GUICtrlTreeView_SetChecked function is designed to check/uncheck items created by the UDF, so try using that instead. 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...
JujuLand Posted April 5, 2012 Author Share Posted April 5, 2012 (edited) You're right, it was a typo. It ought to be GUICrtlSetStatus() instead of GUICrtlStatus(). In conclusion, it's better to use generic functions for control creation, as we keep controlID and we can found handle. For deletion, UDF works without problem. I have modified the code to use generic functions: if $rgItem=-1 Then $sp1 = StringLeft($string,10-StringLen($extNew)) & "|" $sp2 = StringLeft($string,35-StringLen("Win2Tux.file")) & "|" $sp3 = StringLeft($string,23) $item= StringLower($extNew) & $sp1 & "Win2Tux.file" & $sp2 & $sp3 $rgItem=SearchPosInExt($extNew) $value=GUICtrlRead($ExtArray[$nbExt-1][3],1) $controlID=GUICtrlCreateTreeViewItem(GUICtrlRead($ExtArray[$nbExt-1][3],1),$extensionView) $handle=GUICtrlGetHandle($controlID) GUICtrlSetState($controlID,GUICtrlRead($ExtArray[$nbExt-1][3])) $nbExt+=1 ReDim $extArray[$nbExt+1][5] $extArray[$nbExt][3]=$controlID $extArray[$nbExt][4]=$handle GUICtrlSetOnEvent($ExtArray[$nbExt][3], "extension") for $rg=$nbExt -1 To $rgItem+2 step -1 for $col=0 to 3 $extArray[$rg][$col] = $extArray[$rg-1][$col] Next GUICtrlSetData($extArray[$rg+1][ 3],GUICtrlRead($extArray[$rg][3],1)) GUICtrlSetState($extArray[$rg+1][ 3],GUICtrlRead($extArray[$rg][3])) Next GUICtrlSetData($extArray[$rgItem+1][ 3],GUICtrlRead($extArray[$rgItem][3],1)) $extArray[$rgItem+1][0] =$extNew $extArray[$rgItem+1][1] ="Win2Tux.file" $extArray[$rgItem+1][2] =$controlID GUICtrlSetData($extArray[$rgItem+1][ 3],$item) GUICtrlSetState($extArray[$rgItem+1][3], $GUI_CHECKED) $nbW2T+=1 GUICtrlSetData($W2Tnumber,$nbW2T) Cancel0() _WinAPI_RedrawWindow($MyGUI, "", "", BitOR($RDW_INVALIDATE, $RDW_UPDATENOW)) Else msgbox(0,$txt120,$txt121 & $extNew & $txt122) EndIf Thanks for the help A+ Edited April 5, 2012 by JujuLand Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2012 Moderators Share Posted April 5, 2012 JujuLand, Il n'y a pas de quoi. 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...
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