Jump to content

Recommended Posts

Posted (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 by nend
Posted (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 by spudw2k
Posted
  On 6/30/2016 at 2:45 PM, 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 )

 

Expand  

Thank for your anwser but I don't have a clue how to implement this?

Posted (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?

  On 6/30/2016 at 1:37 PM, nend said:

expand all parent but not the childeren?

Expand  

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 by spudw2k
Posted (edited)
  On 6/30/2016 at 4: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")

 

Expand  

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.

Knipsel.JPG

I Hoop you have a idea how to do that.

Edited by nend
  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

Posted
  On 7/2/2016 at 7:22 AM, 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

Expand  

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.

  • Moderators
Posted

nend,

  Quote

every day I learn something new

Expand  

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

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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:

  Reveal hidden contents

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...