kgreer Posted January 15, 2013 Share Posted January 15, 2013 I am writing a script to dynamically create a TreeView control with checkboxes from a INI file containing a list of items. I do not see a function to get the items selected from the treeview. I might be overcomplicating this, but is there an example on how to get the selected items from the treeview? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 15, 2013 Moderators Share Posted January 15, 2013 kgreer,Loop through the items by index (remember they are 0-based) and use _GUICtrlTreeView_GetChecked to see which ones are checked. 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...
kgreer Posted January 15, 2013 Author Share Posted January 15, 2013 Thanks! However I'm missing something. Here is what I'm working with. Once I figure out the functions I will modify this to my needs. I'm not getting a True prompt for the 3rd checked item and instead of 4 msg boxes, there is 5 in the loop. What am I missing? #RequireAdmin #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <GuiTreeView.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) Local $iTreeView_2 = GUICtrlCreateTreeView(30, 30, 200, 160, $TVS_CHECKBOXES) GUICtrlCreateTreeViewItem("TreeView", $iTreeView_2) GUICtrlCreateTreeViewItem("With", $iTreeView_2) GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $iTreeView_2) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateTreeViewItem("Style", $iTreeView_2) $count = _GUICtrlTreeView_GetCount($iTreeView_2) for $i=1 to $count msgbox(0,"ischecked",_GUICtrlTreeView_GetChecked($iTreeView_2,$i)) Next While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 15, 2013 Moderators Share Posted January 15, 2013 kgreer,The Help file says you need to pass the handle of the TreeViewItem to that function - so we need to collect them as the items are created:#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Global $aItems[4] $Form1 = GUICreate("Form1", 500, 500) GUISetState(@SW_SHOW) Local $iTreeView_2 = GUICtrlCreateTreeView(30, 30, 200, 160, $TVS_CHECKBOXES) $aItems[0] = GUICtrlGetHandle(GUICtrlCreateTreeViewItem("TreeView", $iTreeView_2)) $aItems[1] = GUICtrlGetHandle(GUICtrlCreateTreeViewItem("With", $iTreeView_2)) $aItems[2] = GUICtrlGetHandle(GUICtrlCreateTreeViewItem("TVS_CHECKBOXES", $iTreeView_2)) _GUICtrlTreeView_SetChecked($iTreeView_2, $aItems[2]) $aItems[3] = GUICtrlGetHandle(GUICtrlCreateTreeViewItem("Style", $iTreeView_2)) $cButton = GUICtrlCreateButton("Read", 10, 450, 80, 30) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cButton $count = _GUICtrlTreeView_GetCount($iTreeView_2) For $i = 0 To $count - 1 MsgBox(0, "ischecked", $i & " = " & _GUICtrlTreeView_GetChecked($iTreeView_2, $aItems[$i])) Next EndSwitch WEndAll clear? 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...
kgreer Posted January 15, 2013 Author Share Posted January 15, 2013 Ahh I see. Thanks. You got me a jump start. I'll work on my project and chime in again if I need help. Thanks! Link to comment Share on other sites More sharing options...
spudw2k Posted January 15, 2013 Share Posted January 15, 2013 This post might give you some ideas too. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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