Hallo Leute,
ich hab noch nicht soviel Erfahrung in autoit und jetzt ein Problem bei dem ich nicht mehr weiterkomme.
Ich will Treeviews in Tabs erstellen. Die Treeviews allerdings sollen unabhängig voneinander sein. Mein Problem ist nun, dass wenn ich eine neuen Tab(Konfiguration) erstelle(im Menü File->new Config), die Treeview aus der vorherigen Konfiguration übernommen wird. Wenn ich einen neuen Ordner hinzufüge, wird er auch bei allen anderen Tabs übernommen. Ich möchte aber für jeden Tab unabhängige Treeviews.
Ich hoffe ihr habt mein Problem verstanden.
Hier mein Code:
[autoit]
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <TreeViewConstants.au3>
#include <StaticConstants.au3>
#include <GuiTreeView.au3>
#include <File.au3>
#include <GuiTab.au3>
Opt("GUIOnEventMode", 1)
Opt("GUIResizeMode", 1)
Local $pathtosource=""
Local $mainwindow
Local $filemenu
Local $treeFolder ;parent in treeview
Local $treeview[10] ;handle for treeview start element
Local $n_config=0 ;number of configs
Local $tab
Local $tabi[10]
Local $addFolderButton[10]
$mainwindow =GUICreate("Tester",640,480,(@DesktopWidth - 640)/2, (@DesktopHeight - 480)/2)
[/autoit][autoit][/autoit][autoit];create menu
$filemenu = GUICtrlCreateMenu("&File")
$configitem = GUICtrlCreateMenuItem("new Config", $filemenu)
GUICtrlSetOnEvent($configitem,"CreateConfig")
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
;create
$tab=_GUICtrlTab_Create($mainwindow,0,0,640,480)
GUISetState(@SW_SHOW)
[/autoit][autoit][/autoit][autoit]While 1
Sleep(10) ; Idle around
WEnd
#cs ###################################ParseFilesForTreeview #######################################################
[/autoit][autoit][/autoit][autoit]input: folder where your targetfiles are
function : looks for c- and h- files and creates a parent - treeview item for the path and a - child item for each files
#ce ;##################################ParseFilesForTreeview #######################################################
[/autoit][autoit][/autoit][autoit]Func ParseFilesForTreeview($folder)
[/autoit][autoit][/autoit][autoit]$current_tab=_GUICtrlTab_GetCurSel($tab)
[/autoit][autoit][/autoit][autoit]_GUICtrlTreeView_BeginUpdate($treeview[$current_tab])
[/autoit][autoit][/autoit][autoit]$treeFolder=_GUICtrlTreeView_Add($treeview[$current_tab],0,$folder)
[/autoit][autoit][/autoit][autoit]$cFiles=_FileListToArray($folder,"*.c")
if @error<>4 then ;files found
for $i=1 to $cFiles[0]
$controllID=_GUICtrlTreeView_AddChild($treeview[$current_tab],$treeFolder,$cFiles[$i])
Next
EndIf
$hFiles=_FileListToArray($folder,"*.h")
if @error<>4 then ; files found
for $i=1 to $hFiles[0]
$controllID=_GUICtrlTreeView_AddChild($treeview[$current_tab],$treeFolder,$hFiles[$i])
Next
EndIf
_GUICtrlTreeView_EndUpdate($treeview[$current_tab])
EndFunc
[/autoit][autoit][/autoit][autoit][/autoit][autoit]#cs ################################### CreateConfig #######################################################
[/autoit][autoit][/autoit][autoit]function : create config and tab window
[/autoit][autoit][/autoit][autoit]#ce ;################################## CreateConfig end ###################################################
[/autoit][autoit][/autoit][autoit]Func CreateConfig()
$tabi[$n_config]=_GUICtrlTab_InsertItem($tab,$n_config,"Config"& $n_config)
;GUICtrlSetState($tabi[$n_config],$GUI_FOCUS)
$treeview[$n_config]=_GUICtrlTreeView_Create($tab,6,30,280,400,BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE)
$addFolderButton=GUICtrlCreateButton("Add Folder",6,440,280,20)
GUICtrlSetOnEvent($addFolderButton, "AddFolder")
$n_config = $n_config + 1;
EndFunc
#cs ###################################### AddFolder #######################################################
[/autoit][autoit][/autoit][autoit]function : create config and tab window
[/autoit][autoit][/autoit][autoit]#ce ;##################################### AddFolder end ###################################################
[/autoit][autoit][/autoit][autoit][/autoit][autoit]Func AddFolder()
$folder = FileSelectFolder("Choose folder ...",$pathtosource)
if @error==1 Then
Return
EndIf
ParseFilesForTreeview($folder)
EndFunc
Func CLOSEClicked()
Exit
EndFunc
Grüße
Fuxxx