Seite 1 von 1

ExamineDirectory problem

Verfasst: 07.05.2009 15:27
von Silencedoogle
Hallo,
PB 4.20 oder 4.30


ich hab ein problem ... und zwar ist die Combobox nicht sortiert gefüllt.
#CB_SORT funzt nicht ... wie kann man das schnell und einfach lösen??


;laufwerk D: hat sagen wa ma 100 Ordner des Bespielt types : xxxx_xxx
Directory.s = "D:\"

If ExamineDirectory(999, Directory.s, "????_???")
While NextDirectoryEntry(999)

;eintrag in combobox hinzufügen
AddGadgetItem(59, -1, DirectoryEntryName(999))

Wend
FinishDirectory(999)
EndIf

Verfasst: 07.05.2009 15:49
von ts-soft

Code: Alles auswählen

OpenWindow(0, #PB_Ignore, #PB_Ignore, 220, 100, "void", #PB_Window_SystemMenu)

ComboBoxGadget(0, 10, 10, 200, 20)

NewList files.s()
NewList dirs.s()

If ExamineDirectory(0, "c:\", "")
  While NextDirectoryEntry(0)
    If DirectoryEntryType(0) = #PB_DirectoryEntry_File
      AddElement(files())
      files() = DirectoryEntryName(0)
    Else
      If DirectoryEntryName(0) <> "." And DirectoryEntryName(0) <> ".."
        AddElement(dirs())
        dirs() = DirectoryEntryName(0)       
      EndIf
    EndIf    
  Wend
  FinishDirectory(0)
  
  SortList(dirs(), #PB_Sort_Ascending | #PB_Sort_NoCase)
  SortList(files(), #PB_Sort_Ascending | #PB_Sort_NoCase)
  
  ForEach dirs()
    AddGadgetItem(0, -1, dirs())
  Next
  ForEach files()
    AddGadgetItem(0, -1, files())
  Next
  SetGadgetState(0, 0)
EndIf

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Verfasst: 08.05.2009 07:12
von Silencedoogle
Danke Ts-Soft,

hatte es auch mit nem array probiert und hat natürlich auch funktioniert.

deine list is einfach schöner ...

is schade das man die combobox nicht direkt sortieren kann ... das ging doch ma.

naja auf jedenfall danke danke ...

bis denne ...

Re: ExamineDirectory problem

Verfasst: 08.05.2009 07:26
von Little John
Silencedoogle hat geschrieben:#CB_SORT funzt nicht
---------------------------
PureBasic
---------------------------
Zeile 1: Konstante nicht gefunden: #CB_SORT.
---------------------------
Hast Du mal #CBS_SORT probiert?
Das geht aber wohl nicht mit den nativen PB-Befehlen, sondern nur mit Windows API-Funktionen.

Gruß, Little John

PS: Code hier im Forum bitte immer in [ code ] und [ /code ] Tags einschließen, damit er besser lesbar ist (so wie bei ts-soft).

Verfasst: 08.05.2009 14:56
von Fluid Byte
#CBS_SORT funktioniert nur in Verbindung mit #CB_ADDSTRING:

Code: Alles auswählen

OpenWindow(0, 0,0,220,100,"void",#PB_Window_SystemMenu | 1)
ComboBoxGadget(0,10,10,200,20,#CBS_SORT)

ExamineDirectory(0,"C:\","*.*")
While NextDirectoryEntry(0)
    If DirectoryEntryType(0) = #PB_DirectoryEntry_Directory
    	SendMessage_(GadgetID(0),#CB_ADDSTRING,0,DirectoryEntryName(0))
    EndIf
Wend
FinishDirectory(0)

SetGadgetState(0,0)

While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend