Da ich mir am Samstag die Hand gebrochen habe, kann ich nur noch mit einer Hand schreiben , deswegen veröffentliche ich den Code so wie er jetzt ist... da ich atm nicht daran arbeiten kann, und ich sowieso keine Lösung für mein Problem finde.
Und hier mein Gui Code , vieleicht zu gebrauchen ....
Code: Alles auswählen
Enumeration
#Main
EndEnumeration
;- Gadget Constants
;
Enumeration
#Frame3D_1
#Editor_0
#Tree_1
#ProgressBar_0
#Text_0
#Frame3D_2
#Text_1
#Text_2
#Text_3
#String_0
#Button_0
#CheckBox_0
#CheckBox_1
#Frame3D_3
#Button_1
#Text_5
#String_1
#Button_2
#Text_6
EndEnumeration
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Calibri", 10)
Global FontID2
FontID2 = LoadFont(2, "Calibri", 11)
Global FontID3
FontID3 = LoadFont(3, "Calibri", 8)
Procedure Open_Main()
If OpenWindow(#Main, 5, 5, 900, 680, "X360´s Search Faktory", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar)
Frame3DGadget(#Frame3D_1, 350, 100, 700, 610, "Editor")
SetGadgetFont(#Frame3D_1, FontID2)
EditorGadget(#Editor_0, 360, 120, 680, 580)
SetGadgetFont(#Editor_0, FontID1)
SetGadgetText(#Editor_0, "X360´s Search Factory")
TreeGadget(#Tree_1, 10, 160, 330, 550, #PB_Tree_AlwaysShowSelection | #PB_Tree_NoButtons)
SetGadgetFont(#Tree_1, FontID1)
ProgressBarGadget(#ProgressBar_0, 10, 130, 330, 12, 0, 10)
TextGadget(#Text_0, 10, 110, 330, 20, "Status : ")
Frame3DGadget(#Frame3D_2, 600, 10, 450, 90, "Datei Info")
TextGadget(#Text_1, 610, 30, 430, 20, "Treffer: ")
TextGadget(#Text_2, 610, 50, 430, 15, "Pfad: ")
TextGadget(#Text_3, 610, 70, 430, 25, "Gefunden in Zeile: ")
StringGadget(#String_1, 20, 50, 150, 20, "")
ButtonGadget(#Button_0, 430, 70, 150, 20, "Komplett durchsuchung")
CheckBoxGadget(#CheckBox_0, 20, 75, 100, 20, "Unterordner ")
CheckBoxGadget(#CheckBox_1, 120, 75, 200, 20, "Ausnahmen Liste beachten")
Frame3DGadget(#Frame3D_3, 10, 10, 580, 90, "Such-Einstellung")
ButtonGadget(#Button_1, 450, 40, 130, 20, "Durchsuchen")
TextGadget(#Text_5, 20, 30, 50, 20, "Suchwort:")
StringGadget(#String_0, 190, 50, 130, 20, "C:")
ButtonGadget(#Button_2, 330, 50, 30, 20, "...")
TextGadget(#Text_6, 190, 30, 70, 20, "Such Ordner")
SetGadgetState(#CheckBox_0, 1)
SetGadgetState(#CheckBox_1, 1)
SetGadgetFont(#Text_0, FontID3)
SetGadgetFont(#Text_1, FontID1)
SetGadgetFont(#Text_2, FontID1)
SetGadgetFont(#Text_3, FontID3)
SetGadgetFont(#Text_5, FontID1)
SetGadgetFont(#Text_6, FontID1)
SetGadgetFont(#String_0, FontID1)
SetGadgetFont(#String_1, FontID1)
SetGadgetFont(#Frame3D_2, FontID2)
SetGadgetFont(#Frame3D_3, FontID2)
SetGadgetFont(#CheckBox_0, FontID1)
SetGadgetFont(#CheckBox_1, FontID1)
SetGadgetFont(#Button_1, FontID1)
SetGadgetFont(#Button_0, FontID1)
SetGadgetFont(#Button_2, FontID1)
EndIf
EndProcedure
Procedure RefreshMainWindow(Width.l, Height.l)
If Width>899 And height>600
If width<900
ResizeGadget(#Tree_1, 10, #PB_Ignore, Width-490, Height-250)
ResizeGadget(#ProgressBar_0, #PB_Ignore, #PB_Ignore, Width-490, #PB_Ignore)
EndIf
ResizeGadget(#Tree_1, 10, #PB_Ignore, #PB_Ignore, Height-180)
ResizeGadget(#Editor_0, 380, #PB_Ignore, Width-430, Height-140)
ResizeGadget(#Frame3D_1, 370, #PB_Ignore, Width-410, Height-110)
ResizeGadget(#Text_1, #PB_Ignore, #PB_Ignore, Width-660, #PB_Ignore)
ResizeGadget(#Text_2, #PB_Ignore, #PB_Ignore, Width-660, #PB_Ignore)
ResizeGadget(#Text_3, #PB_Ignore, #PB_Ignore, Width-660, #PB_Ignore)
ResizeGadget(#Frame3D_2, #PB_Ignore, #PB_Ignore, Width-640, #PB_Ignore)
ResizeWindow(#Main, #PB_Ignore, #PB_Ignore, Width, Height)
Else
ResizeWindow(#Main, #PB_Ignore, #PB_Ignore, 801, 681)
EndIf
EndProcedure
Global Pattern.b
Global Zeile.l
NewList Suche.s()
Procedure GetSize(s)
Shared Suchordner$, Size, done, exam
done = 0
exam = ExamineDirectory(#PB_Any, SuchOrdner$, "*.*")
SetGadgetText(#Text_0, "Status: Ermittle Gesamt Größe")
While NextDirectoryEntry(exam)
If DirectoryEntryType(exam) = #PB_DirectoryEntry_File
size + FileSize(SuchOrdner$ + DirectoryEntryName(exam))
SetGadgetText(#Text_0, "Status: Ermittle Gesamt Größe -- " + StrD(((size/1024)/1024), 2) + "Mb")
EndIf
Wend
done = 1
EndProcedure
Procedure Findwort(Para)
Shared Suche(), Anzahl.l
Shared Suchordner$, Suchwort$, Binar, Unterordner, Size, done
If Not Pattern$
Pattern$ = "*.*"
EndIf
If Right(SuchOrdner$, 1)<>"\"
SuchOrdner$ + "\"
EndIf
exam = ExamineDirectory(#PB_Any, SuchOrdner$, "*.*")
If Exam
While NextDirectoryEntry(exam)
d$ = DirectoryEntryName(exam)
If DirectoryEntryType(exam) = #PB_DirectoryEntry_File
sized + FileSize(SuchOrdner$ + d$)
If done = 1
Prozent$ = StrD(((sizeD/1024))/((size/1024)/100), 2)
If Prozent$ = "100.00"
SetGadgetText(#Text_0, "Status : 100% | " + StrD(Size/1024/1024, 2) + "Mb Durchsucht - Warte auf Fertigstellung")
Else
SetGadgetText(#Text_0, "Status : " + Prozent$ + "% | " + StrD(((sizeD/1024)/1024), 2) + "Mb von " + StrD(((size/1024)/1024), 2) + "Mb Durchsucht")
EndIf
SetGadgetState(#ProgressBar_0, Val(Str(((sizeD/1024))/((size/1024)/100))))
EndIf
Pattern.b = 1
If Binar = 1
If ReadFile(2, "ausnahmen.txt")
While Eof(2) = 0
If GetExtensionPart(d$) = ReadString(2)
Pattern.b = 0
EndIf
Wend
EndIf
EndIf
If ReadFile(0, SuchOrdner$ + d$) And Pattern.b = 1
While Eof(0) = 0
Zeile$ = ReadString(0)
Zeile.l + 1
Anfang.l = FindString(Zeile$, Suchwort$, 0)
If Anfang.l
Datei$ = d$
nichtvorhanden = 0
For i = 0 To CountGadgetItems(#Tree_1)
If GetGadgetItemText(#Tree_1, i) = Suchordner$ + Datei$
nichtvorhanden = 1
treeanzahl + 1
SetGadgetItemText(#Tree_1, i, Suchordner$ + Datei$);+Str(treeanzahl))
EndIf
Next
If nichtvorhanden = 0
AddGadgetItem(#Tree_1, -1, Suchordner$ + Datei$)
EndIf
AddElement(Suche())
Suche() = Suchordner$ + Datei$
AddElement(Suche())
Suche() = Str(Zeile.l)
AddElement(Suche())
Suche() = Str(Anfang.l)
Anzahl.l + 1
EndIf
Wend
If d$<>"." And d$<>".."
If Unterordner = 1
;und ab hier gehts nicht mehr ,,,,,
; SuchOrdner$ + d$
; CreateThread(@Findwort(),1)
EndIf
EndIf
Zeile.l = 0
CloseFile(0)
EndIf
EndIf
Wend
FinishDirectory(exam)
EndIf
DisableGadget(#Button_2, 0)
DisableGadget(#Button_1, 0)
DisableGadget(#Button_0, 0)
DisableGadget(#Tree_1, 0)
DisableGadget(#String_0, 0)
DisableGadget(#String_1, 0)
DisableGadget(#CheckBox_0, 0)
DisableGadget(#CheckBox_1, 0)
EndProcedure
Procedure DateiLesen(datei)
AllocateMemory(1000000)
Shared startlese
*Datei$ = GetGadgetItemText(#Tree_1, GetGadgetState(#Tree_1))
If ReadFile(1, *Datei$)
While Eof(1) = 0
AddGadgetItem(#Editor_0, -1, ReadString(1))
Wend
CloseFile(1)
EndIf
EndProcedure
Open_Main()
Width = 800
Height = 640
Repeat
Event = WaitWindowEvent(50)
If WindowHeight(0)<>Height Or WindowWidth(0)<>Width
Width = WindowWidth(0)
Height = WindowHeight(0)
RefreshMainWindow(Width, Height)
EndIf
If Event = #PB_Event_CloseWindow
exit = 1
EndIf
If event = #PB_Event_Gadget
Select EventGadget()
Case #Tree_1
If EventType() = #PB_EventType_LeftClick
Datei$ = GetGadgetItemText(#Tree_1, GetGadgetState(#Tree_1))
SetGadgetText(#Text_2, "Pfad:" + Datei$)
If ReadFile(1, Datei$)
While Eof(1) = 0
zeile + 1
anfang$ = Str(FindString(ReadString(1), GetGadgetText(#String_1), 0))
If Not anfang$ = "0"
zeile$ = zeile$ + Str(zeile) + " | "
treffer + 1
anfang$ = ""
EndIf
Wend
CloseFile(1)
SetGadgetText(#Text_3, "Gefunden in Zeile : " + Mid(zeile$, 0, Len(zeile$)-2))
SetGadgetText(#Text_1, "Treffer : " + Str(Treffer))
zeile = 0
zeile$ = ""
treffer = 0
EndIf
nexte = 0
EndIf
If EventType() = #PB_EventType_LeftDoubleClick
ClearGadgetItems(#Editor_0)
Datei$ = GetGadgetItemText(#Tree_1, GetGadgetState(#Tree_1))
CreateThread(@DateiLesen(), 2)
EndIf
Case #Button_0
ClearGadgetItems(#Tree_1)
Suchordner$ = "C:\"
SuchWort$ = GetGadgetText(#String_1)
Binar = GetGadgetState(#CheckBox_1)
Unterordner = 1
DisableGadget(#Button_1, 1)
DisableGadget(#Button_0, 1)
DisableGadget(#Button_2, 1)
DisableGadget(#Tree_1, 1)
DisableGadget(#String_0, 1)
DisableGadget(#String_1, 1)
DisableGadget(#CheckBox_0, 1)
DisableGadget(#CheckBox_1, 1)
size = 0
CreateThread(@GetSize(), 3)
CreateThread(@Findwort(), 1)
Case #Button_1
ClearGadgetItems(#Tree_1)
SuchOrdner$ = GetGadgetText(#String_0)
SuchWort$ = GetGadgetText(#String_1)
Binar = GetGadgetState(#CheckBox_1)
Unterordner = GetGadgetState(#CheckBox_0)
DisableGadget(#Button_1, 1)
DisableGadget(#Button_0, 1)
DisableGadget(#Button_2, 1)
DisableGadget(#Tree_1, 1)
DisableGadget(#String_0, 1)
DisableGadget(#String_1, 1)
DisableGadget(#CheckBox_0, 1)
DisableGadget(#CheckBox_1, 1)
size = 0
CreateThread(@GetSize(), 3)
CreateThread(@Findwort(), 1)
Case #Button_2
SetGadgetText(#String_0, PathRequester("Bitte den Pfad angeben indem Gesucht werden soll", ProgramFilename()))
EndSelect
EndIf
Until exit = 1