nend Posted June 30, 2016 Share Posted June 30, 2016 (edited) Hoi Is it possible in a treeview to expand all parent but not the childeren? If I use "_GUICtrlTreeView_Expand" than it will expand all childeren as well. Thanks! Edited July 2, 2016 by nend Link to comment Share on other sites More sharing options...
spudw2k Posted June 30, 2016 Share Posted June 30, 2016 (edited) It will probably take a function with your own logic. Here are the funcs I would use to accomplish this: _GUICtrlTreeView_SetState ( $hWnd, $hItem [, $iState = 0 [, $bSetState = 0]] ) _GUICtrlTreeView_IsParent ( $hWnd, $hParent, $hItem ) _GUICtrlTreeView_Level ( $hWnd, $hItem ) _GUICtrlTreeView_GetNextSibling ( $hWnd, $hItem ) Edited June 30, 2016 by spudw2k 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...
nend Posted June 30, 2016 Author Share Posted June 30, 2016 45 minutes ago, spudw2k said: It will probably take a function with your own logic. Here are the funcs I would use to accomplish this: _GUICtrlTreeView_SetState ( $hWnd, $hItem [, $iState = 0 [, $bSetState = 0]] ) _GUICtrlTreeView_IsParent ( $hWnd, $hParent, $hItem ) _GUICtrlTreeView_Level ( $hWnd, $hItem ) _GUICtrlTreeView_GetNextSibling ( $hWnd, $hItem ) Thank for your anwser but I don't have a clue how to implement this? Link to comment Share on other sites More sharing options...
spudw2k Posted June 30, 2016 Share Posted June 30, 2016 (edited) Ok, I'll do what I can to help. Can you explain in more detail the behavior you want? Do you have a script/example with treeview in it to work with? 5 hours ago, nend said: expand all parent but not the childeren? What is the structure of the tree? Is there a single root or are there multiple parents at the root. How about a picture? Also, this command/func will allow you to expand a single item. _SendMessage(GUICtrlGetHandle($idTreeView), $TVM_EXPAND, $TVE_EXPAND, $hItem, 0, "wparam", "handle") Edited June 30, 2016 by spudw2k 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...
nend Posted July 2, 2016 Author Share Posted July 2, 2016 (edited) On 30-6-2016 at 6:15 PM, spudw2k said: Ok, I'll do what I can to help. Can you explain in more detail the behavior you want? Do you have a script/example with treeview in it to work with? What is the structure of the tree? Is there a single root or are there multiple parents at the root. How about a picture? Also, this command/func will allow you to expand a single item. _SendMessage(GUICtrlGetHandle($idTreeView), $TVM_EXPAND, $TVE_EXPAND, $hItem, 0, "wparam", "handle") It took some time but here I have a sample program. I've tryd your line of code above (_sendmessage) but no luck. #include <GuiTreeView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $SP_array[11], $C_array[11] $gui = GUICreate("Gui", 500, 465, -1, -1, -1);, $WS_EX_TOPMOST) $gui_treeView = GUICtrlCreateTreeView(10, 10, 480, 280, BitOr($TVS_HASBUTTONS, $TVS_DISABLEDRAGDROP, $TVS_HASLINES, $TVS_HASLINES, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES, $TVS_LINESATROOT)) $C_head_item = GUICtrlCreateTreeViewItem("Parent 1", $gui_treeView) $SP_head_item = GUICtrlCreateTreeViewItem("Parent 2", $gui_treeView) Local $SP_child = GUICtrlCreateTreeViewItem("Child", $SP_head_item) Local $C_child = GUICtrlCreateTreeViewItem("Child", $C_head_item) For $i=0 To 10 $SP_array[$i] = GUICtrlCreateTreeViewItem($i, $SP_child) $C_array[$i] = GUICtrlCreateTreeViewItem($i, $C_child) Next GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch Sleep(20) WEnd I want it to expand the Parent but not futher, See the screen shot below. I Hoop you have a idea how to do that. Edited July 2, 2016 by nend Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2016 Moderators Share Posted July 2, 2016 nend, Just loop through the top level items of the TreeView and send the message to each one found: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Local $SP_array[11], $C_array[11] $gui = GUICreate("Gui", 500, 465, -1, -1, -1);, $WS_EX_TOPMOST) $gui_treeView = GUICtrlCreateTreeView(10, 10, 480, 280, BitOr($TVS_HASBUTTONS, $TVS_DISABLEDRAGDROP, $TVS_HASLINES, $TVS_HASLINES, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES, $TVS_LINESATROOT)) $C_head_item = GUICtrlCreateTreeViewItem("Parent 1", $gui_treeView) $SP_head_item = GUICtrlCreateTreeViewItem("Parent 2", $gui_treeView) Local $SP_child = GUICtrlCreateTreeViewItem("Child", $SP_head_item) Local $C_child = GUICtrlCreateTreeViewItem("Child", $C_head_item) For $i=0 To 10 $SP_array[$i] = GUICtrlCreateTreeViewItem($i, $SP_child) $C_array[$i] = GUICtrlCreateTreeViewItem($i, $C_child) Next GUISetState() $hItem = _GUICtrlTreeView_GetFirstItem($gui_treeView) Do _SendMessage(GUICtrlGetHandle($gui_treeView), $TVM_EXPAND, $TVE_EXPAND, $hItem, 0, "wparam", "handle") $hItem = _GUICtrlTreeView_GetNextSibling($gui_treeView, $hItem) Until $hItem = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd And note you do not need a Sleep in a GUIGetMsg loop - as explained in the help file, the function has an automatic pause incorporated so as not to hog the CPU. 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...
nend Posted July 2, 2016 Author Share Posted July 2, 2016 1 hour ago, Melba23 said: nend, Just loop through the top level items of the TreeView and send the message to each one found: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Local $SP_array[11], $C_array[11] $gui = GUICreate("Gui", 500, 465, -1, -1, -1);, $WS_EX_TOPMOST) $gui_treeView = GUICtrlCreateTreeView(10, 10, 480, 280, BitOr($TVS_HASBUTTONS, $TVS_DISABLEDRAGDROP, $TVS_HASLINES, $TVS_HASLINES, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES, $TVS_LINESATROOT)) $C_head_item = GUICtrlCreateTreeViewItem("Parent 1", $gui_treeView) $SP_head_item = GUICtrlCreateTreeViewItem("Parent 2", $gui_treeView) Local $SP_child = GUICtrlCreateTreeViewItem("Child", $SP_head_item) Local $C_child = GUICtrlCreateTreeViewItem("Child", $C_head_item) For $i=0 To 10 $SP_array[$i] = GUICtrlCreateTreeViewItem($i, $SP_child) $C_array[$i] = GUICtrlCreateTreeViewItem($i, $C_child) Next GUISetState() $hItem = _GUICtrlTreeView_GetFirstItem($gui_treeView) Do _SendMessage(GUICtrlGetHandle($gui_treeView), $TVM_EXPAND, $TVE_EXPAND, $hItem, 0, "wparam", "handle") $hItem = _GUICtrlTreeView_GetNextSibling($gui_treeView, $hItem) Until $hItem = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd And note you do not need a Sleep in a GUIGetMsg loop - as explained in the help file, the function has an automatic pause incorporated so as not to hog the CPU. M23 You make it look so simple ;-) Thanks for the help! And the pause in a loop is something I didnt know that the software allready take care of that, every day I learn something new. Synapsee 1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 2, 2016 Moderators Share Posted July 2, 2016 nend, Quote every day I learn something new You are certainly not alone in that..... But when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders know what they wrote and it just pads the thread unnecessarily. 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...
nend Posted July 2, 2016 Author Share Posted July 2, 2016 @Melba23, I'll keep that in mind, thanks for the help! 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