Seite 1 von 1

Schneller Ersatz(?) für das explorergadget(Windows Api only)

Verfasst: 13.09.2004 22:51
von Rings
updated on 14.9.2004

Code: Alles auswählen

;Alternative (Fast) Directory Lister 
; Purebasic 3.91, Windows only 
; done on september,12,2004 
; part of a fast mp3-player 
; by Siegfried Rings 
; Feel free to spread :) 

SearchPath.s="C:\" 

#txt_Directory = 2 
#LST_DIRECTORY = 3 
#txt_Directory2=4 
#B1=5
#B2=6
#txt_3=7

hWndMain = OpenWindow(0, 100, 200, 400, 400, #PB_Window_SystemMenu, "DirectoryList API") 
CreateGadgetList(hWndMain) 
TextGadget(#txt_Directory, 10,10,350,20,"") 
TextGadget(#txt_Directory2, 10,30,350,20,"") 

ButtonGadget(#B1,360,1,40,20,"UP")
ButtonGadget(#B2,360,25,40,20,"DN")
TextGadget(#txt_3, 360,50,40,20,"") 


lv=ListViewGadget(#LST_DIRECTORY ,10,70,380,320,#LBS_SORT );| #LBS_MULTIPLESEL |#LBS_NOINTEGRALHEIGHT | #LBS_HASSTRINGS) 
result=DlgDirList_(hWndMain, SearchPath.s, #LST_DIRECTORY, 2, #DDL_DRIVES |#DDL_DIRECTORY |#DDL_READWRITE ) 
AddKeyboardShortcut(0,#PB_Shortcut_Return  ,1) 

Repeat 
  event = WaitWindowEvent() 
  evt=EventType() 
  If evt=#PB_EventType_LeftClick        
   Select EventGadgetID()
   Case #b1
    SetGadgetState(#LST_DIRECTORY ,GetGadgetState(#LST_DIRECTORY )-1)
    SetGadgetText(#txt_3,Str(GetGadgetState(#LST_DIRECTORY )) )
   Case #b2 
    SetGadgetState(#LST_DIRECTORY ,GetGadgetState(#LST_DIRECTORY )+1)
    SetGadgetText(#txt_3,Str(GetGadgetState(#LST_DIRECTORY )) )
   EndSelect
  
  EndIf
  If evt=#PB_EventType_LeftDoubleClick        
   Select EventGadgetID()
   Case #LST_DIRECTORY 
    P=1 
   EndSelect
  EndIf 
  If event = #PB_Event_Menu 
   evm=EventMenuID()        
   If evm=1 
    p=1 
   EndIf 
  EndIf 
If P=1 

  ;If EventGadgetID()=#LST_DIRECTORY 
      Entry.s=GetGadgetText(#LST_DIRECTORY) 
      If Left(Entry.s,1)="[" 
       Entry.s=Right(Entry.s,Len(Entry.s)-1) 
       Entry.s=Left(Entry.s,Len(Entry.s)-1) 
       If Left(Entry.s,1)="-" 
        Entry.s=Right(Entry.s,Len(Entry.s)-1) 
       EndIf 
       If Right(Entry.s,1)="-" 
        Entry.s=Left(Entry.s,Len(Entry.s)-1)+":\" 
       EndIf 
       SearchPath.s=Entry.s 
       Debug Entry.s 
       result=DlgDirList_(hWndMain, SearchPath.s, #LST_DIRECTORY, 2, #DDL_DRIVES |#DDL_DIRECTORY |#DDL_READWRITE ) 
      EndIf 
      SetGadgetText(#txt_Directory2,Entry.s) 
    ;EndIf 
  P=0 
EndIf 
Until event = #PB_Event_CloseWindow