ExamineDirectory problem

Für allgemeine Fragen zur Programmierung mit PureBasic.
Silencedoogle
Beiträge: 4
Registriert: 02.04.2009 11:41

ExamineDirectory problem

Beitrag 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
Lets Rock and Have fun
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag 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
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Silencedoogle
Beiträge: 4
Registriert: 02.04.2009 11:41

Beitrag 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 ...
Lets Rock and Have fun
Little John

Re: ExamineDirectory problem

Beitrag 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).
Benutzeravatar
Fluid Byte
Beiträge: 3110
Registriert: 27.09.2006 22:06
Wohnort: Berlin, Mitte

Beitrag 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
Windows 10 Pro, 64-Bit / Outtakes | Derek
Antworten