#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Global $sIniFile = @ScriptDir & '\test.ini'
$aParams = IniReadSection($sIniFile, "Arhives")
Global $iTotalParams = UBound($aParams)-1
Global $Progs[$iTotalParams + 1]
$aParams2 = IniReadSection($sIniFile, "Test")
Global $iTotalParams2 = UBound($aParams2)-1
Global $Progs2[$iTotalParams2 + 1]
Dim $a_hItem[$iTotalParams + 1][$iTotalParams2 + 3] = [[$iTotalParams , $iTotalParams2]]
$iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, _
$TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
$hGUI = GUICreate('Test', 400, 300, -1, -1, -1, $WS_CLIPCHILDREN)
$nButton = GUICtrlCreateButton('Click me', 150, 260, 100, 30)
$hTreeView = _GUICtrlTreeView_Create($hGUI, 2, 2, 396, 250, $iStyle, $WS_EX_CLIENTEDGE)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
_GUICtrlTreeView_BeginUpdate($hTreeView)
For $i = 1 To $iTotalParams
$aData = IniRead($sIniFile, "Arhives", "Arhives" & $i, "")
$a_hItem[$i][0] = _GUICtrlTreeView_Add($hTreeView, 0, $aData)
For $j = 1 To $iTotalParams2
$parse = StringRegExp(IniRead($sIniFile,"Test","test"&$j,"<de.exe><INI file ?><0>"),"<(.*?)>",3)
If $parse[3] = $aData Then
$a_hItem[$i][$j] = _GUICtrlTreeView_AddChild($hTreeView, $a_hItem[$i][0], $parse[1])
Else
ExitLoop
EndIf
Next
$a_hItem[$i][$a_hItem[0][1] + 2] = True
Next
_GUICtrlTreeView_EndUpdate($hTreeView)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $nButton
$iCount = 0
Dim $aData[1][2]
For $i = 1 To $a_hItem[0][0]
For $j = 1 To $a_hItem[0][1]
If $a_hItem[$i][$j] Then
If _GUICtrlTreeView_GetChecked($hTreeView, $a_hItem[$i][$j]) Then
$iCount += 1
ReDim $aData[$iCount + 1][2]
$aData[$iCount][0] = _GUICtrlTreeView_GetText($hTreeView, $a_hItem[$i][0])
$aData[$iCount][1] = _GUICtrlTreeView_GetText($hTreeView, $a_hItem[$i][$j])
EndIf
EndIf
Next
Next
If $iCount Then
$aData[0][0] = $iCount
_ArrayDisplay($aData)
;здесь делайте с отмеченными Item то, что Вам надо.
Else
MsgBox(16, 'Error', 'Нет отмеченных')
EndIf
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview, $fChecked
$hWndTreeview = $hTreeView
If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, 'hWndFrom'))
$iCode = DllStructGetData($tNMHDR, 'Code')
Switch $hWndFrom
Case $hWndTreeview
Switch $iCode
Case $NM_CUSTOMDRAW
For $i = 1 To $a_hItem[0][0]
$a_hItem[$i][$a_hItem[0][1] + 2] = _GUICtrlTreeView_GetChecked($hWndFrom, $a_hItem[$i][0])
If $a_hItem[$i][$a_hItem[0][1] + 1] <> $a_hItem[$i][$a_hItem[0][1] + 2] Then
$a_hItem[$i][$a_hItem[0][1] + 1] = $a_hItem[$i][$a_hItem[0][1] + 2]
For $j = 1 To $a_hItem[0][1]
If $a_hItem[$i][$j] Then
_GUICtrlTreeView_SetChecked($hWndFrom, $a_hItem[$i][$j], $a_hItem[$i][$a_hItem[0][1] + 1])
EndIf
Next
EndIf
Next
Return 0
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY