#include <GUIConstants.au3>
#include <GUITab.au3>
;~ $basedir = @DocumentsCommonDir & "\..\Start Menu\"
$basedir = "c:\"
GUICreate("title", 900, 600)
$tab = GUICtrlCreateTab(10, 50, 250, 400)
$gen_cat = Inspect($basedir, "*", 2) ; General categories (tabs)
$gen_cat = StringSplit($gen_cat, "|")
;~ Global $tab[$gen_cat[0] + 1], $tab_tv[$gen_cat[0] + 1], $tab_tv_cat[1], $tab_tv_item[1] ; what you had
Global $tab_item[$gen_cat[0] + 1], $tab_tv[$gen_cat[0] + 1], $tab_tv_cat[1], $tab_tv_item[1]
For $i = 1 To $gen_cat[0]
;~ $tab[$i] = GUICtrlCreateTabItem($gen_cat[$i]) ; what you had
$tab_item[$i] = GUICtrlCreateTabItem($gen_cat[$i])
$tab_tv[$i] = GUICtrlCreateTreeView(18, 80, 232, 360, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE)
$sub_cat = Inspect($basedir & "\" & $gen_cat[$i], "*", 2)
$sub_cat = StringSplit($sub_cat, "|")
For $x = 1 To $sub_cat[0]
ReDim $tab_tv_cat[$sub_cat[0] + 1]
$tab_tv_cat[$x] = GUICtrlCreateTreeViewItem($sub_cat[$x], $tab_tv[$i])
$sub_cat_item = Inspect($basedir & "\" & $gen_cat[$i] & "\" & $sub_cat[$x], "*.lnk", 1)
$sub_cat_item = StringSplit($sub_cat_item, "|")
For $y = 1 To $sub_cat_item[0]
ReDim $tab_tv_item[$sub_cat_item[0] + 1]
$sub_cat_item[$y] = StringTrimRight($sub_cat_item[$y], 4) ; Strip the ".lnk" extension from our treeview
$tab_tv_item[$y] = GUICtrlCreateTreeViewItem($sub_cat_item[$y], $tab_tv_cat[$x])
Next
Next
GUICtrlCreateTabItem("") ; end tabitem definition
Next
$button = GUICtrlCreateButton("Selected?", 300, 300)
GUISetState()
MsgBox(0, "", _GUICtrlTab_GetCurSel($tab))
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $button
$cur_tab = _GUICtrlTab_GetCurSel($tab)
MsgBox(0, "", $cur_tab)
EndSwitch
WEnd
; ===========>
Func Inspect($sPath, $sFilter = "*", $iFlag = 0)
Dim $sFileList
$hSearch = FileFindFirstFile($sPath & "\" & $sFilter)
If $hSearch = -1 Then Return SetError(4, 4, "")
While 1
$sFile = FileFindNextFile($hSearch)
If @error Then
SetError(0)
ExitLoop
EndIf
If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop
If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop
$sFileList = $sFileList & $sFile & "|"
WEnd
If StringRight($sFileList, 1) = "|" Then $sFileList = StringTrimRight($sFileList, 1)
FileClose($hSearch)
Return $sFileList
EndFunc ;==>Inspect