Function Reference


_GUICtrlTreeView_GetParentParam

Retrieve the parent control ID/Param of item

#include <GuiTreeView.au3>
_GUICtrlTreeView_GetParentParam ( $hWnd [, $hItem = Null] )

Parameters

$hWnd Control ID/Handle to the control
$hItem [optional] item ID/Param

Return Value

Success: the parent control param.
Failure: 0.

Example

Example 1

#AutoIt3Wrapper_UseX64=n
#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

; Warning do not use _GUICtrlTreeView_SetItemParam() on items created with GUICtrlCreateTreeViewItem
; Param is the controlID for items created with the built-in function

Example_Internal()

Func Example_Internal()
        GUICreate("TreeView Get Parent Param (v" & @AutoItVersion & ")", 400, 300)

        Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
        Local $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
        GUISetState(@SW_SHOW)

        ; Set ANSI format
;~     _GUICtrlTreeView_SetUnicodeFormat($idTreeView, False)

        _GUICtrlTreeView_BeginUpdate($idTreeView)
        Local $idItem, $idChild, $iYItem = 0, $idFirstItem = 0
        For $x = 0 To 10
                $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
                If $idFirstItem = 0 Then $idFirstItem = $idItem
                $iYItem += 1
                For $y = 0 To 2
                        $idChild = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $iYItem), $idItem)
                        $iYItem += 1
                Next
        Next
        _GUICtrlTreeView_EndUpdate($idTreeView)

        _GUICtrlTreeView_SelectItem($idTreeView, $idChild)
        MsgBox($MB_SYSTEMMODAL, "Information", "Parent Param/ID: " & _GUICtrlTreeView_GetParentParam($idTreeView, $idChild) - $idFirstItem) ; same as controlID

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>Example_Internal

Example 2

#AutoIt3Wrapper_UseX64=Y
#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example_External()

Func Example_External()
        Local $hGUI = GUICreate("(UDF Created) TreeView Get Parent Param (v" & @AutoItVersion & ")", 400, 300)

        Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
        Local $hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
        GUISetState(@SW_SHOW)

        ; Set ANSI format
;~     _GUICtrlTreeView_SetUnicodeFormat($hTreeView, False)

        _GUICtrlTreeView_BeginUpdate($hTreeView)
        Local $hItem, $hChild, $iParam = 0
        For $x = 0 To 10
                $hItem = _GUICtrlTreeView_Add($hTreeView, 0, StringFormat("[%02d] New Item", $x))
                _GUICtrlTreeView_SetItemParam($hTreeView, $hItem, $iParam)
                $iParam += 1
                For $y = 0 To 2
                        $hChild = _GUICtrlTreeView_AddChild($hTreeView, $hItem, StringFormat("[%02d] New Item", $iParam))
                        _GUICtrlTreeView_SetItemParam($hTreeView, $hChild, $iParam)
                        $iParam += 1
                Next
        Next
        _GUICtrlTreeView_EndUpdate($hTreeView)

        _GUICtrlTreeView_SelectItem($hTreeView, $hChild)
        MsgBox($MB_SYSTEMMODAL, "Information", "Parent Param: " & _GUICtrlTreeView_GetParentParam($hTreeView, $hChild))

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>Example_External