so jetz, getestet, funktioniert aber nur zum Teil.
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=D:\zzz_icons\084232291438415db59af68a2ba283441ca9324a.ico
#AutoIt3Wrapper_Outfile=DPO_x86.exe
#AutoIt3Wrapper_Outfile_x64=DPO_x64.exe
#AutoIt3Wrapper_UseX64=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GUIImageList.au3>
#include <GUITreeView.au3>
#include <GUIToolBar.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WinAPIEx.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <array.au3>
Global $sRoot = @ScriptDir & "\Projekte\"
Global $hForm, $hTreeView, $hImageList, $hItem, $hNext, $hSelect = 0, $hInput, $Input, $Dummy1, $Dummy2, $Edit1, $hToolBar
Global $X, $Y, $sPath
Global Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idHelp
Global $obj_get, $GUI_ActiveX = 0
Global $ary[0]
Global $foundAry[0]
$hForm = GUICreate("Digitaler Projektordner", @DesktopWidth - 10, @DesktopHeight - 100, 1, 1)
$Input = GUICtrlCreateInput("", 20, 44, @DesktopWidth - 100, 21)
$hInput = GUICtrlGetHandle(-1)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetState(-1, $GUI_HIDE)
$import_file = GUICtrlCreateButton("Datei importieren", 200, 15, 150, 25)
$import_folder = GUICtrlCreateButton("Ordner importieren", 200, 45, 150, 25)
$lblSearch = GUICtrlCreateLabel("", 605, 15, 200, 20)
$inSearch = GUICtrlCreateInput("", 400, 15, 200, 20)
$btSearch = GUICtrlCreateButton("Suchen", 400, 45, 200, 20)
$btReset = GUICtrlCreateButton("Reset", 400, 75, 200, 20)
$open = GUICtrlCreateButton("Bearbeiten", 20, 15, 150, 25)
$load_new = GUICtrlCreateButton("Neu Laden", 20, 45, 150, 25)
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS) ;, $TVS_CHECKBOXES)
$idTreeView = GUICtrlCreateTreeView(20, 258, 508, @DesktopHeight - 500, $iStyle, $WS_EX_CLIENTEDGE)
$hTreeView = GUICtrlGetHandle($idTreeView)
$Dummy1 = GUICtrlCreateDummy()
$Dummy2 = GUICtrlCreateDummy()
If _WinAPI_GetVersion() >= '6.0' Then
_WinAPI_SetWindowTheme($hTreeView, 'Explorer')
EndIf
$hImageList = _GUIImageList_Create(16, 16, 5, 1)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 3)
_GUIImageList_AddIcon($hImageList, @SystemDir & '\shell32.dll', 4)
_GUICtrlTreeView_SetNormalImageList($hTreeView, $hImageList)
$sRoot = StringRegExpReplace($sRoot, '\\+\Z', '')
$sPath = StringRegExpReplace($sRoot, '^.*\\', '')
If StringInStr($sPath, ':') Then
$sRoot &= '\'
$sPath &= '\'
EndIf
_TVUpdate($hTreeView, _GUICtrlTreeView_AddChild($hTreeView, 0, $sPath, 0, 0))
GUIRegisterMsg($WM_NOTIFY, 'WM_NOTIFY')
GUISetState()
_GUICtrlTreeView_Expand($hTreeView)
_GUICtrlTreeView_EnsureVisible($hTreeView, 0)
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
$oPDF = ""
$GUIActiveX = ""
Exit
Case $btSearch
$foundall = 0
_searchInTreeViewStart($hTreeView, GUICtrlRead($inSearch))
_WinAPI_RedrawWindow($hTreeView)
;~ GUICtrlSetState($btSearch, $GUI_DISABLE)
GUICtrlSetData($lblSearch, $foundall)
Case $btReset
GUICtrlSetData($lblSearch, "")
GUICtrlSetData($inSearch, "")
_GUICtrlTreeView_DeleteAll($hTreeView)
_TVUpdate($hTreeView, _GUICtrlTreeView_AddChild($hTreeView, 0, $sPath, 0, 0))
_GUICtrlTreeView_Expand($hTreeView)
_GUICtrlTreeView_EnsureVisible($hTreeView, 0)
;~ GUICtrlSetState($btSearch, $GUI_ENABLE)
Case $load_new
ShellExecute(@ScriptFullPath)
Exit
Case $open
If $sPath <> $sRoot Then ShellExecute('"' & $sPath & '"')
Case $import_file
$hItem = GUICtrlRead($Dummy2)
$sPath = _TVGetPath($hTreeView, $hItem, $sRoot)
import($sPath, "file")
Case $import_folder
$hItem = GUICtrlRead($Dummy2)
$sPath = _TVGetPath($hTreeView, $hItem, $sRoot)
import($sPath, "dir")
Case $Dummy1 ; Update
GUISetCursor(1, 1)
$hItem = _GUICtrlTreeView_GetFirstChild($hTreeView, GUICtrlRead($Dummy1))
If $hItem Then
While $hItem
$hNext = _GUICtrlTreeView_GetNextSibling($hTreeView, $hItem)
If Not _TVUpdate($hTreeView, $hItem) Then
_GUICtrlTreeView_Delete($hTreeView, $hItem)
EndIf
$hItem = $hNext
WEnd
_WinAPI_RedrawWindow($hTreeView)
EndIf
GUISetCursor(2, 0)
Case $Dummy2 ; Show File
$hItem = GUICtrlRead($Dummy2)
$sPath = _TVGetPath($hTreeView, $hItem, $sRoot)
$obj_get = StringSplit($sPath, "\")
$obj_get = $obj_get[$obj_get[0]]
GUICtrlDelete($GUI_ActiveX)
objopen($obj_get, $sPath)
EndSwitch
WEnd
Func _TVGetPath($hTV, $hItem, $sRoot)
Local $Path = StringRegExpReplace(_GUICtrlTreeView_GetTree($hTV, $hItem), '([|]+)|(\\[|])', '\\')
If Not $Path Then
Return ''
EndIf
If Not StringInStr($Path, ':') Then
Return StringRegExpReplace($sRoot, '(\\[^\\]*(\\|)+)\Z', '\\') & $Path
EndIf
Return $Path
EndFunc ;==>_TVGetPath
Func _TVSetPath($hTV, $hItem, $sRoot)
GUICtrlSetData($Input, _WinAPI_PathCompactPath($hInput, _TVGetPath($hTV, $hItem, $sRoot), 554))
$hSelect = $hItem
EndFunc ;==>_TVSetPath
Func _TVUpdate($hTV, $hItem)
Local $hImageList = _SendMessage($hTV, $TVM_GETIMAGELIST)
Local $Path = StringRegExpReplace(_TVGetPath($hTV, $hItem, $sRoot), '\\+\Z', '')
Local $hSearch, $hIcon, $Index, $File
$hSearch = FileFindFirstFile($Path & '\*')
If $hSearch = -1 Then
If Not @error Then
If Not FileExists($Path) Then
Return 0
EndIf
EndIf
Else
While 1
$File = FileFindNextFile($hSearch)
If @error Then
ExitLoop
EndIf
If @extended Then
_GUICtrlTreeView_AddChild($hTV, $hItem, $File, 0, 0)
EndIf
WEnd
FileClose($hSearch)
EndIf
$hSearch = FileFindFirstFile($Path & '\*.*')
If $hSearch = -1 Then
Else
While 1
$File = FileFindNextFile($hSearch)
If @error Then
ExitLoop
EndIf
If Not @extended Then
$hIcon = _WinAPI_ShellExtractAssociatedIcon($Path & '\' & $File, 1)
$Index = _GUIImageList_ReplaceIcon($hImageList, -1, $hIcon)
_GUICtrlTreeView_AddChild($hTV, $hItem, $File, $Index, $Index)
_WinAPI_DestroyIcon($hIcon)
EndIf
WEnd
FileClose($hSearch)
EndIf
Return 1
EndFunc ;==>_TVUpdate
Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
Local $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $lParam)
Local $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
Local $iState = DllStructGetData($tNMTREEVIEW, 'NewState')
Local $hTV = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
Local $ID = DllStructGetData($tNMTREEVIEW, 'Code')
Local $tTVHTI, $tPoint
Switch $hTV
Case $hTreeView
Switch $ID
Case $TVN_ITEMEXPANDEDW
If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
_GUICtrlTreeView_Delete($hTV, $hItem)
If BitAND($iState, $TVIS_SELECTED) Then
_TVSetPath($hTV, _GUICtrlTreeView_GetSelection($hTV), $sRoot)
EndIf
Else
If Not BitAND($iState, $TVIS_EXPANDED) Then
_GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 0)
_GUICtrlTreeView_SetImageIndex($hTV, $hItem, 0)
Else
_GUICtrlTreeView_SetSelectedImageIndex($hTV, $hItem, 1)
_GUICtrlTreeView_SetImageIndex($hTV, $hItem, 1)
If Not _GUICtrlTreeView_GetItemParam($hTV, $hItem) Then
_GUICtrlTreeView_SetItemParam($hTV, $hItem, 0x7FFFFFFF)
GUICtrlSendToDummy($Dummy1, $hItem)
EndIf
EndIf
EndIf
Case $TVN_SELCHANGEDW
If BitAND($iState, $TVIS_SELECTED) Then
If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
_GUICtrlTreeView_Delete($hTV, $hItem)
$hItem = _GUICtrlTreeView_GetSelection($hTV)
EndIf
If $hItem <> $hSelect Then
_TVSetPath($hTV, $hItem, $sRoot)
EndIf
EndIf
Case $NM_RCLICK
$tPoint = _WinAPI_GetMousePos(1, $hTV)
$tTVHTI = _GUICtrlTreeView_HitTestEx($hTV, DllStructGetData($tPoint, 1), DllStructGetData($tPoint, 2))
$hItem = DllStructGetData($tTVHTI, 'Item')
If BitAND(DllStructGetData($tTVHTI, 'Flags'), $TVHT_ONITEM) Then
_GUICtrlTreeView_SelectItem($hTreeView, $hItem)
If Not FileExists(_TVGetPath($hTV, $hItem, $sRoot)) Then
_GUICtrlTreeView_Delete($hTV, $hItem)
$hItem = _GUICtrlTreeView_GetSelection($hTV)
Else
GUICtrlSendToDummy($Dummy2, $hItem)
EndIf
If $hItem <> $hSelect Then
_TVSetPath($hTV, $hItem, $sRoot)
EndIf
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func objopen($obj, $obj_path)
If StringInStr($obj, ".pdf") Then
$oPDF = ObjCreate("AcroPDF.PDF.1")
$GUI_ActiveX = GUICtrlCreateObj($oPDF, 556, 85, @DesktopWidth - 556 - 20, @DesktopHeight - 195)
$oPDF.src = $obj_path
ElseIf StringInStr($obj, ".bmp") Or StringInStr($obj, ".jpg") Then
_GDIPlus_Startup()
Local $IMG_pic = _GDIPlus_ImageLoadFromFile($obj_path)
Local $W_pic = _GDIPlus_ImageGetWidth($IMG_pic)
Local $H_pic = _GDIPlus_ImageGetHeight($IMG_pic)
_GDIPlus_ImageDispose($IMG_pic)
If $W_pic <= @DesktopWidth - 556 - 20 And $H_pic <= @DesktopHeight - 195 Then
$GUI_ActiveX = GUICtrlCreatePic($obj_path, 556, 85, $W_pic, $H_pic)
Else
$GUI_ActiveX = GUICtrlCreatePic($obj_path, 556, 85, @DesktopWidth - 556 - 20, @DesktopHeight - 195)
EndIf
ElseIf StringInStr($obj, ".txt") Or StringInStr($obj, ".doc") Or StringInStr($obj, ".ini") Then
Dim $obj_ary
$GUI_ActiveX = GUICtrlCreateEdit("", 556, 85, @DesktopWidth - 556 - 20, @DesktopHeight - 195)
_FileReadToArray($sPath, $obj_ary)
For $i = 1 To $obj_ary[0]
GUICtrlSetData($GUI_ActiveX, GUICtrlRead($GUI_ActiveX) & @CRLF & $obj_ary[$i])
Next
EndIf
EndFunc ;==>objopen
Func import($sPath, $proj)
Local $iPath, $files
If $proj = "file" Then
If StringInStr(StringRight($sPath, 5), ".") Then
$sPath = StringSplit($sPath, "\")
For $i = 1 To $sPath[0] - 1
$iPath &= $sPath[$i] & "\"
Next
Else
$iPath = $sPath & "\"
EndIf
Local $sMessage = "Strg oder Shift halten, um mehrere Dateien auszuwählen."
Local $sFileOpenDialog = FileOpenDialog($sMessage, @DesktopDir & "\", "All (*.*)", $FD_FILEMUSTEXIST + $FD_MULTISELECT)
If @error Then
MsgBox(64, "", "Keine Datei(en) ausgewählt.")
FileChangeDir(@DesktopDir)
Else
$files = $sFileOpenDialog
FileChangeDir(@DesktopDir)
If StringInStr($files, "|") Then
$files = StringSplit($sFileOpenDialog, "|")
For $i = 2 To $files[0]
FileCopy($files[1] & "\" & $files[$i], $iPath & $files[$i])
Next
Else
$files = StringSplit($files, "\")
Local $dPath
For $i = 1 To $files[0] - 1
$dPath &= $files[$i] & "\"
Next
FileCopy($dPath & $files[$files[0]], $iPath & $files[$files[0]])
EndIf
EndIf
ElseIf $proj = "dir" Then
Local $sMessage = "Ordner auswählen"
Local $sFileSelectFolder = FileSelectFolder($sMessage, "")
If @error Then
MsgBox(64, "", "Kein Ordner ausgewählt.")
Else
If StringInStr(StringRight($sPath, 5), ".") Then
$sPath = StringSplit($sPath, "\")
For $i = 1 To $sPath[0] - 1
$iPath &= $sPath[$i] & "\"
Next
Else
$iPath = $sPath & "\"
EndIf
$iPath = StringTrimRight($iPath, 1)
Local $last = StringSplit($sFileSelectFolder, "\")
$last = $last[$last[0]]
RunWait(@ComSpec & " /c " & "xcopy " & '"' & $sFileSelectFolder & '"' & ' "' & $iPath & "\" & $last & '\"' & " /E /C")
EndIf
EndIf
EndFunc ;==>import
Func _searchInTreeViewStart($Treeview, $text)
_GUICtrlTreeView_BeginUpdate($Treeview)
$item = _GUICtrlTreeView_GetFirstItem($Treeview)
While $item <> 0
If _searchInTreeViewMatches($Treeview, $item, $text) Then
_GUICtrlTreeView_SetItemFound($Treeview, $item)
Else
_GUICtrlTreeView_ResetItemFound($Treeview, $item)
EndIf
If _searchInTreeView($Treeview, $text, $item) Then
_GUICtrlTreeView_Expand($Treeview, $item, True)
Else
_GUICtrlTreeView_Expand($Treeview, $item, False)
EndIf
$item = _GUICtrlTreeView_GetNext($Treeview, $item)
WEnd
_GUICtrlTreeView_EndUpdate($Treeview)
EndFunc ;==>_searchInTreeViewStart
Func _searchInTreeView($Treeview, $text, $item)
$founded = False
$child = _GUICtrlTreeView_GetFirstChild($Treeview, $item)
$count = 0
While $child <> 0
$count += 1
If _searchInTreeView($Treeview, $text, $child) Then
$founded = True
_GUICtrlTreeView_Expand($Treeview, $child, True)
Else
_GUICtrlTreeView_Expand($Treeview, $child, False)
EndIf
If _searchInTreeViewMatches($Treeview, $child, $text) Then
$founded = True
_ArrayAdd($foundAry, $child)
EndIf
$child = _GUICtrlTreeView_GetNextChild($Treeview, $child)
WEnd
$foundall += $count
Return $founded
EndFunc ;==>_searchInTreeView
Func _searchInTreeViewMatches($Treeview, $item, $text)
Return StringInStr(_GUICtrlTreeView_GetText($Treeview, $item), $text)
EndFunc ;==>_searchInTreeViewMatches
Func _GUICtrlTreeView_SetItemFound($Treeview, $item)
;FARBIG
_GUICtrlTreeView_SetBkColor($item, "0x40e0d0")
EndFunc ;==>_GUICtrlTreeView_SetItemFound
Func _GUICtrlTreeView_ResetItemFound($Treeview, $item)
;FARBIG ZURÜCKSETZEN
_GUICtrlTreeView_SetBkColor($item, "0x000000")
EndFunc ;==>_GUICtrlTreeView_ResetItemFound
Alles anzeigen
Im Treeview eine Datei auswählen und mit Rechtsklick dann auf der rechten Seite anzeigen lassen (warum Rechts- und nicht Linksklick, weiss ich nicht - funktioniert nur mit PDF, TXT, BMP usw...), Buttons oben müssten klar sein.
Suchen funktioniert zum Teil, läd aber auch irgendwie nur einen Bruchteil der ganzen Dateien im $root-Ordner.