UDF > GUI > GuiTreeView >


_GUICtrlTreeView_GetParentParam

Obtient l'ID/Param de contrôle du parent d'un noeud

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

Paramètres

$hWnd ID/handle du contrôle
$hItem [optionnel] ID/Param du noeud

Valeur de retour

Succès: Retourne le param de contrôle du noeud parent.
Échec: Retourne 0.

Exemples

Exemple 1

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example_Internal()

Func Example_Internal()
    Local $idItem, $idChild, $idTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    GUICreate("TreeView Get Parent Param", 400, 300)

    $idTreeView = GUICtrlCreateTreeView(2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($idTreeView)
    For $x = 0 To 20
        $idItem = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $x), $idTreeView)
        For $y = 0 To 2
            $idChild = GUICtrlCreateTreeViewItem(StringFormat("[%02d] New Item", $y), $idItem)
        Next
    Next
    _GUICtrlTreeView_EndUpdate($idTreeView)

    _GUICtrlTreeView_SelectItem($idTreeView, $idChild)
    MsgBox($MB_SYSTEMMODAL, "Information", "Parent Param/ID: " & _GUICtrlTreeView_GetParentParam($idTreeView, $idChild)) ; même que controlID

    ; Boucle jusqu'à ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_Internal


Exemple 2

#include <GUIConstantsEx.au3>
#include <GuiTreeView.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example_External()

Func Example_External()
    Local $hGUI, $hItem, $hChild, $iParam = 1, $hTreeView
    Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)

    $hGUI = GUICreate("(UDF Created) TreeView Get Parent Param", 400, 300)

    $hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
    GUISetState(@SW_SHOW)

    _GUICtrlTreeView_BeginUpdate($hTreeView)
    For $x = 0 To 20
        $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", $y))
            _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))

    ; Boucle jusqu'à ce que l'utilisateur quitte.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example_External