Page 1 sur 1

probleme avec la procedure CompresserArchive()

Publié : jeu. 23/août/2007 23:09
par SpaceMan
salut a tous je reviens avec le meme code sauf que cette fois j'ai un problème dans la procedure CompresserArchive()
cette procedure permet d'archiver tous les éléments sélectionnés dans la Explorerlist mais là ça rate quelques uns(surtout les fichiers)

Code : Tout sélectionner

;Auteur: SpaceMan 
;version: Démo 
;librairie utilisée: pureZip de (gnozal) 
;{- Enumerations 
;{ Windows 
Enumeration 
  #Window_0 
  #Window_2 
  #Progression 
EndEnumeration 
;} 
;{ Menu bars 
Enumeration 
  #Menu_Window_0 
EndEnumeration 
;{ Menu items 
Enumeration 
  #Menu_Window_0_0_ExtraireUneArchive 
  #Menu_Window_0_0_OuvrirUneArchive 
  #Menu_Window_0_1_TesterUneArchive 
  #Menu_Window_0_2_MotDePasse 
  #Menu_Window_0_3_Configuration 
  #Menu_Window_0_4_Quitter 
  #Menu_Window_0_5_Compresser 
  #Menu_Window_0_6_CompresserAvecPassword 
  #Menu_Window_0_7_Decompresser 
  #Menu_Window_0_8_SupprimerPassword 
  #Menu_Window_0_9_TutorialPCDEVZIP 
  #Menu_Window_0_10_Enregistrement 
  #Menu_Window_0_11_APropos 
EndEnumeration 
;} 
;{ Status bars 
Enumeration 
  #StatusBar_Window_0 
EndEnumeration 
;} 
;{ Gadgets 
Enumeration 
  #ExplorerComboGadget 
  #ExplorerList_1 
  #StatusBar 
  #compress 
  #decompress 
  #Text_10 
  #String_9 
  #Text_18 
  #String_17 
  #Button_12 
  #Frame3D_16 
  #Text_12 
  #ComboBox_13 
  #Text_14 
  #ComboBox_15 
  #Frame3DGadget_245 
  #TextGadget_244 
  #StringGadget_246 
  #TextGadget_243 
  #StringGadget_247 
  #CheckBoxGadget_242 
  #CheckBoxGadget_241 
  #ButtonGadget_240 
  #ButtonGadget_239 
  #Button_4 
  
EndEnumeration 
Global Disk$ 
Disk$ = "C:\" 
Global Window_0, ProgressBar_Compression, Text_FileProcessed, Text_1, ProgressBar_Progression 
Global nom_archive.s,destination$,pwd$,pwd2$, repfichier$ 
;} 

Procedure OpenWindow_Window_0() 
  If OpenWindow(#Window_0, 170, 90, 652, 470, "PC&DEV Compressor", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) 
   SmartWindowRefresh(#Window_0, 1) 
    CreateGadgetList(WindowID(#Window_0)) 
    If CreateMenu(#Menu_Window_0, WindowID(#Window_0)) 
      MenuTitle("Menu") 
      MenuItem(#Menu_Window_0_0_OuvrirUneArchive,"Ouvrir Archive") 
      MenuItem(#Menu_Window_0_0_ExtraireUneArchive, "Extraire Archive") 
      MenuItem(#Menu_Window_0_1_TesterUneArchive, "Tester Archive") 
      MenuItem(#Menu_Window_0_3_Configuration, "Configuration") 
      MenuBar() 
      MenuItem(#Menu_Window_0_4_Quitter, "Quitter") 
      MenuTitle("Commandes") 
      ;MenuItem(#Menu_Window_0_12_Compresser, "Compresser") 
      MenuItem(#Menu_Window_0_5_Compresser, "Compresser") 
      MenuItem(#Menu_Window_0_6_CompresserAvecPassword, "Compresser avec Password") 
      MenuBar() 
      MenuItem(#Menu_Window_0_7_Decompresser, "Décompresser") 
      MenuItem(#Menu_Window_0_8_SupprimerPassword, "Supprimer Password") 
      MenuTitle("Aide") 
      MenuItem(#Menu_Window_0_9_TutorialPCDEVZIP, "Tutorial(PC-DEV ZIP)") 
      MenuItem(#Menu_Window_0_10_Enregistrement, "Enregistrement") 
      MenuItem(#Menu_Window_0_11_APropos, "A Propos") 
      
      ExplorerComboGadget(#ExplorerComboGadget, 1, 02, 650, 200, Disk$, #PB_Explorer_Editable) 
      ExplorerListGadget(#ExplorerList_1, 0, 25, 651, 405, Disk$, #PB_Explorer_MultiSelect|#PB_Explorer_AutoSort|#PB_Explorer_AlwaysShowSelection|#PB_Explorer_FullRowSelect) 
      SetGadgetItemAttribute(#ExplorerList_1, 0,#PB_Explorer_ColumnWidth, 347) 
      ; Gadget Resizing 
      PureRESIZE_SetGadgetResize(#ExplorerList_1, 1, 1, 1, 1) 
      PureRESIZE_SetGadgetResize(#ExplorerComboGadget, 1, 1, 1, 1) 
      
    EndIf 
  EndIf 
EndProcedure 
  
  Procedure OpenWindow_Archive() 
  If OpenWindow(#Window_2, 587, 257, 353, 350, "Ajouter Archive", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered) 
   SmartWindowRefresh(#Window_2, 1) 
    StickyWindow(#Window_2, 1) 
     If CreateGadgetList(WindowID(#Window_2)) 
      TextGadget(#Text_10, 7, 21, 80, 15, "Nom de l'archive") 
      StringGadget(#String_9, 92, 16, 221, 20, "") 
      TextGadget(#Text_18, 8, 55, 65, 15, "Emplacement") 
      StringGadget(#String_17, 92, 50, 220, 20, "") 
      ButtonGadget(#Button_12, 318, 51, 25, 20, "...") 
  
      Frame3DGadget(#Frame3D_16, 10, 85, 330, 85, "Option de Compression") 
      TextGadget(#Text_12, 25, 105, 90, 15, "Format de l'archive") 
      ComboBoxGadget(#ComboBox_13, 220, 100, 105, 100):DisableGadget(#ComboBox_13,1) 
      AddGadgetItem(#ComboBox_13, 0, "Zip") 
      AddGadgetItem(#ComboBox_13, 1, "Arj") 
      AddGadgetItem(#ComboBox_13, 2, "Ace") 
      SetGadgetState(#ComboBox_13, 0) 
      
      TextGadget(#Text_14, 25, 135, 110, 15, "Type de compresssion") 
      ComboBoxGadget(#ComboBox_15, 220, 135, 105, 100):DisableGadget(#ComboBox_15,1) 
      AddGadgetItem(#ComboBox_15, 0, "Normal") 
      AddGadgetItem(#ComboBox_15, 1, "Deflate") 
      SetGadgetState(#ComboBox_15, 0) 
    
      Frame3DGadget(#Frame3DGadget_245, 10, 182, 330, 135, "Mot de  Passe") 
      TextGadget(#TextGadget_244, 20, 200, 118, 15, "Entrer le mot de passe") 
      StringGadget(#StringGadget_246, 165, 235, 160, 20, "", #PB_String_Password) 
      TextGadget(#TextGadget_243, 20, 240, 128, 15, "Confirmer le mot de passe") 
      StringGadget(#StringGadget_247, 165, 199, 160, 20, "", #PB_String_Password) 
      CheckBoxGadget(#CheckBoxGadget_242, 20, 269, 140, 15, "Afficher le mot de Passe") 
      CheckBoxGadget(#CheckBoxGadget_241, 20, 294, 180, 15, "Crypter le nom des fichiers"):DisableGadget(#CheckBoxGadget_241,1) 
      ButtonGadget(#ButtonGadget_240, 218, 324, 60, 20, "OK") 
      ButtonGadget(#ButtonGadget_239, 288, 325, 54, 19, "Annuler") 

    EndIf 
  EndIf 
EndProcedure 
  
 Procedure Open_Window() 
  Window_0 = OpenWindow(#PB_Any, 382, 285, 315, 128, "Compressor",#PB_Window_TitleBar | #PB_Window_ScreenCentered) 
  If Window_0 : StickyWindow(Window_0, 1) 
    If CreateGadgetList(WindowID(Window_0)) 
      ProgressBar_Compression = ProgressBarGadget(#PB_Any, 5, 25, 305, 20, 0, 100) 
      Text_FileProcessed = TextGadget(#PB_Any, 74, 4, 150, 15, "Extraction des fichiers...", #PB_Text_Center) 
      Text_1 = TextGadget(#PB_Any, 100, 58, 100, 15, "Progression...", #PB_Text_Center) 
      ProgressBar_Progression = ProgressBarGadget(#PB_Any, 5, 77, 305, 20, 0, 100) 
      ButtonGadget(#Button_4, 240, 106, 70, 18, "Annuler") 
    EndIf 
  EndIf 
EndProcedure 
  
Procedure Close_Window() 
  CloseWindow(Window_0) 
EndProcedure 
  
Procedure PureZIP_CallbackC(File.s, PerCent.f) 
 SetGadgetText(Text_FileProcessed, GetFilePart(File)) 
  SetGadgetState(ProgressBar_Compression, PerCent.f) 
 While WindowEvent() : Wend 
EndProcedure 

Procedure PureZIP_CallbackP(File.s, PerCent.f) 
  SetGadgetState(ProgressBar_Progression, PerCent.f) 
  While WindowEvent() : Wend 
EndProcedure 
; 
myFileinfo.PureZIP_FileInfo 
PureZIP_SetProgressionCallback(@PureZIP_CallbackP()) 
PureZIP_SetCompressionCallback(@PureZIP_CallbackC()) 
    
Procedure CompresserArchive() 
Protected i 
 If GetGadgetState(#ExplorerList_1) > -1 
    nom_archive$ = GetGadgetText(#String_9) 
    destination$ = GetGadgetText(#String_17) 
    If nom_archive$ And destination$ :CloseWindow(#Window_2) 
      For i = 0 To CountGadgetItems(#ExplorerList_1) - 1 
        If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Selected ;un élément est sélectionné et c'est ... 
         If GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_File ; ... un fichier 
         PureZIP_Archive_Create(destination$+nom_archive$, #APPEND_STATUS_CREATE) 
           Debug GetGadgetItemText(#ExplorerList_1, i, 0) + " est sélectionné et c'est un fichier" 
             PureZIP_AddFiles(destination$+nom_archive$,GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0), #PureZIP_StorePathRelative ,#PureZIP_NotRecursive) 
          
          ElseIf GetGadgetItemState(#ExplorerList_1, i) & #PB_Explorer_Directory ; ... un répertoire 
            Debug GetGadgetItemText(#ExplorerList_1, i, 0) + " est sélectionné et c'est un dossier" 
             PureZIP_AddFiles(destination$+nom_archive$,GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1, i, 0)+"\" + "*.*", #PureZIP_StorePathRelative ,#PureZIP_Recursive) 
             EndIf: EndIf 
           Next 
        Else 
      MessageRequester("Compressor","Véririfier le nom et la destination de l'archive !",#MB_ICONERROR) 
    EndIf 
  Else 
    MessageRequester("Compressor","Veuillez selectionnez les fichiers !",#MB_ICONERROR) 
  EndIf 
EndProcedure 

Procedure statusbar1() 
   Protected  Nombre_Elements 
       Nombre_Elements = CountGadgetItems(#ExplorerList_1) 
        
   If CreateStatusBar(#StatusBar_Window_0, WindowID(#Window_0)) 
        AddStatusBarField(175) 
        AddStatusBarField(480) 
      StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " "+"élément(s)") 
   EndIf 
EndProcedure 

OpenWindow_Window_0() 
statusbar1() 
Repeat 
  Select WaitWindowEvent() 
    
    ; /////////////////// 
    Case #PB_Event_Menu 
      Select EventMenu() 
        Case #Menu_Window_0_5_Compresser 
         If GetGadgetState(#ExplorerList_1) > -1 
            OpenWindow_Archive() : SetGadgetText(#String_9,"Archive.zip") 
          Else:MessageRequester("Compressor","Veuillez selectionnez les fichiers !",#MB_ICONERROR)  
          EndIf 
          
        Case #Menu_Window_0_7_Decompresser 
        Case #Menu_Window_0_0_ExtraireUneArchive 
        Case #Menu_Window_0_0_OuvrirUneArchive 
        Case #Menu_Window_0_1_TesterUneArchive 
        Case #Menu_Window_0_2_MotDePasse: 
        Case #Menu_Window_0_3_Configuration 
        Case #Menu_Window_0_4_Quitter:Break 
      EndSelect  
      
        ; ////////////////////// 
        Case #PB_Event_Gadget 
         EventGadget = EventGadget() 
         EventType = EventType() 
       Select EventGadget() 
        
        Case #ExplorerComboGadget 
          SetGadgetText(#ExplorerList_1, GetGadgetText(#ExplorerComboGadget)) 
          If  EventType() = #PB_EventType_Change 
         Nombre_Elements = CountGadgetItems(#ExplorerList_1) 
         StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " élément(s)") :EndIf 
        
        
        Case #ButtonGadget_239 
        CloseWindow(#Window_2) 
          
        Case #ButtonGadget_240 
        nom_archive$ = GetGadgetText(#String_9) 
          destination$ = GetGadgetText(#String_17) 
          pwd$ = GetGadgetText(#StringGadget_246) 
          pwd2$ = GetGadgetText(#StringGadget_246) 
          If  nom_archive$ <> "" And destination$ <> "" And pwd$ = pwd2$ And pwd$ = "" And pwd2$ = "" 
             SetWindowState(#Window_0,#PB_Window_Minimize) 
            Open_Window() 
            CompresserArchive():Close_Window() :SetWindowState(#Window_0,#PB_Window_Normal)            
             
          EndIf 
          
        Case #ExplorerList_1 
            If  EventType() = #PB_EventType_LeftDoubleClick 
            SetGadgetText(#ExplorerComboGadget,GetGadgetText(#ExplorerList_1)): EndIf 
            
            compteur_dossier=0 
            compteur_fichier=0 
            
            last_element=CountGadgetItems(#ExplorerList_1)-1 
            
            For position_element=0 To last_element 
              
              etat_gadget=GetGadgetItemState(#ExplorerList_1,position_element) 
              
              If etat_gadget & #PB_Explorer_Selected 
                If etat_gadget & #PB_Explorer_File 
                  compteur_fichier+1 
                Else 
                  If position_element=0 
                    If GetGadgetItemText(#ExplorerList_1,0,0)=".." ; Pour ne pas compter le .. comme dossier 
                     compteur_dossier-1 
                    EndIf 
                  EndIf 
                  
                  compteur_dossier+1 
                EndIf 
              EndIf 
              
            Next position_element 
                        
            StatusBarText(#StatusBar_Window_0,1, Str(compteur_dossier)+" dossier(s) "+Str(compteur_fichier)+" fichier(s)"+" sélectionné(s)")
            
      EndSelect 
      
      ; //////////////////////    
    Case #PB_Event_CloseWindow 
      EventWindow = EventWindow() 
      If EventWindow = #Window_0 
      Break 
      ElseIf EventWindow = #Window_2 
      CloseWindow(#Window_2) 
    EndIf 
  EndSelect 
ForEver 

Publié : sam. 25/août/2007 12:52
par SpaceMan
Bonjour à vous !
ben faut dire que j'ai pas pu dormir aujourd'hui car je me suis juré de trouver la solution et voilà c'est chose faite.

Code : Tout sélectionner

;Auteur: SpaceMan 
;version: Démo 
;User Lib: pureZip (gnozal)
;{- Enumerations 
;{ Windows 
Enumeration 
  #Window_0 
  #Window_2 
  #Progression 
EndEnumeration 
;} 
;{ Menu bars 
Enumeration 
  #Menu_Window_0 
EndEnumeration 
;{ Menu items 
Enumeration 
  #Menu_Window_0_0_ExtraireUneArchive 
  #Menu_Window_0_0_OuvrirUneArchive 
  #Menu_Window_0_1_TesterUneArchive 
  #Menu_Window_0_2_MotDePasse 
  #Menu_Window_0_3_Configuration 
  #Menu_Window_0_4_Quitter 
  #Menu_Window_0_5_Compresser 
  #Menu_Window_0_6_CompresserAvecPassword 
  #Menu_Window_0_7_Decompresser 
  #Menu_Window_0_8_SupprimerPassword 
  #Menu_Window_0_9_TutorialPCDEVZIP 
  #Menu_Window_0_10_Enregistrement 
  #Menu_Window_0_11_APropos 
EndEnumeration 
;} 
;{ Status bars 
Enumeration 
  #StatusBar_Window_0 
EndEnumeration 
;} 
;{ Gadgets 
Enumeration 
  #ExplorerComboGadget 
  #ExplorerList_1 
  #StatusBar 
  #compress 
  #decompress 
  #Text_10 
  #String_9 
  #Text_18 
  #String_17 
  #Button_12 
  #Frame3D_16 
  #Text_12 
  #ComboBox_13 
  #Text_14 
  #ComboBox_15 
  #Frame3DGadget_245 
  #TextGadget_244 
  #StringGadget_246 
  #TextGadget_243 
  #StringGadget_247 
  #CheckBoxGadget_242 
  #CheckBoxGadget_241 
  #ButtonGadget_240 
  #ButtonGadget_239 
  #ProgressionBar
  #ProgressionBar2
  #Txt1:#Txt2
  #BoutonAnnuler
EndEnumeration 

Global Disk$ 
Disk$ = "C:\" 
Global Window_0, ProgressBar_Compression, Text_FileProcessed, Text_1, ProgressBar_Progression, Bt_Annuler
Global nom_archive.s,destination$,pwd$,pwd2$, repfichier$, *ZoneMemoire
;} 

Procedure OpenWindow_Window_0() 
  If OpenWindow(#Window_0, 170, 90, 652, 470, "PC&DEV Compressor", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered) 
    SmartWindowRefresh(#Window_0, 1)
    CreateGadgetList(WindowID(#Window_0)) 
    If CreateMenu(#Menu_Window_0, WindowID(#Window_0)) 
      MenuTitle("Menu") 
      MenuItem(#Menu_Window_0_0_OuvrirUneArchive,"Open Archive") 
      MenuItem(#Menu_Window_0_0_ExtraireUneArchive, "Extract Files") 
      MenuItem(#Menu_Window_0_1_TesterUneArchive, "Test Archive") 
      MenuItem(#Menu_Window_0_3_Configuration, "Preferences") 
      MenuBar() 
      MenuItem(#Menu_Window_0_4_Quitter, "Quit") 
      MenuTitle("Commandes") 
      MenuItem(#Menu_Window_0_5_Compresser, "Add files to zip") 
      MenuItem(#Menu_Window_0_6_CompresserAvecPassword, "Add files to zip with Password") 
      MenuBar() 
      MenuItem(#Menu_Window_0_7_Decompresser, "Extract Files") 
      MenuItem(#Menu_Window_0_8_SupprimerPassword, "Remove Password") 
      MenuTitle("Help") 
      MenuItem(#Menu_Window_0_9_TutorialPCDEVZIP, "Help") 
      ;MenuItem(#Menu_Window_0_10_Enregistrement, "Enregistrement") 
      MenuItem(#Menu_Window_0_11_APropos, "About") 
      
      ExplorerComboGadget(#ExplorerComboGadget, 1, 02, 650, 200, Disk$, #PB_Explorer_Editable) 
      ExplorerListGadget(#ExplorerList_1, 0, 25, 651, 405, Disk$, #PB_Explorer_MultiSelect|#PB_Explorer_AutoSort|#PB_Explorer_AlwaysShowSelection|#PB_Explorer_FullRowSelect) 
      SetGadgetItemAttribute(#ExplorerList_1, 0,#PB_Explorer_ColumnWidth, 347) 
      ; Gadget Resizing 
      PureRESIZE_SetGadgetResize(#ExplorerList_1, 1, 1, 1, 1) 
      PureRESIZE_SetGadgetResize(#ExplorerComboGadget, 1, 1, 1, 1) 
      
    EndIf 
  EndIf 
EndProcedure 
  
Procedure OpenWindow_Archive() 
  If OpenWindow(#Window_2, 587, 257, 353, 350, "Add to Zip", #PB_Window_SystemMenu|#PB_Window_TitleBar|#PB_Window_ScreenCentered) 
    SmartWindowRefresh(#Window_2, 1) 
    StickyWindow(#Window_2, 1) 
    If CreateGadgetList(WindowID(#Window_2)) 
      TextGadget(#Text_10, 7, 21, 80, 15, "Archive name") 
      StringGadget(#String_9, 92, 16, 221, 20, "") 
      TextGadget(#Text_18, 8, 55, 65, 15, "Destination") 
      StringGadget(#String_17, 92, 50, 220, 20, "") 
      ButtonGadget(#Button_12, 318, 51, 25, 20, "...") 
      
      Frame3DGadget(#Frame3D_16, 10, 85, 330, 85, "Compression Options") 
      TextGadget(#Text_12, 25, 105, 90, 15, "Archive Format") 
      ComboBoxGadget(#ComboBox_13, 220, 100, 105, 100):DisableGadget(#ComboBox_13,1) 
      AddGadgetItem(#ComboBox_13, 0, "Zip") 
      AddGadgetItem(#ComboBox_13, 1, "Arj") 
      AddGadgetItem(#ComboBox_13, 2, "Ace") 
      SetGadgetState(#ComboBox_13, 0) 
      
      TextGadget(#Text_14, 25, 135, 110, 15, "Type of compresssion") 
      ComboBoxGadget(#ComboBox_15, 220, 135, 105, 100):DisableGadget(#ComboBox_15,1) 
      AddGadgetItem(#ComboBox_15, 0, "Normal") 
      AddGadgetItem(#ComboBox_15, 1, "Deflate") 
      SetGadgetState(#ComboBox_15, 0) 
      
      Frame3DGadget(#Frame3DGadget_245, 10, 182, 330, 135, "Password") 
      TextGadget(#TextGadget_244, 20, 200, 118, 15, "Enter Password") 
      StringGadget(#StringGadget_246, 165, 235, 160, 20, "", #PB_String_Password) 
      TextGadget(#TextGadget_243, 20, 240, 128, 15, "Confirm Password") 
      StringGadget(#StringGadget_247, 165, 199, 160, 20, "", #PB_String_Password) 
      CheckBoxGadget(#CheckBoxGadget_242, 20, 269, 140, 15, "Show Password") 
      CheckBoxGadget(#CheckBoxGadget_241, 20, 294, 180, 15, "Crypt files name"):DisableGadget(#CheckBoxGadget_241,1) 
      ButtonGadget(#ButtonGadget_240, 218, 324, 60, 20, "OK") 
      ButtonGadget(#ButtonGadget_239, 288, 325, 54, 19, "cancel") 
      
    EndIf 
  EndIf 
EndProcedure 
  
Procedure Add2ZIP(Path.s, SrcPart.s) 
  Protected dir.l, entry.s
  If Not Right(Path, 1) = "\" : Path+"\" : EndIf 
  If Not Right(SrcPart, 1) = "\" : SrcPart+"\" : EndIf 
  dir = ExamineDirectory(#PB_Any, Path, "") 
  If dir 
    While NextDirectoryEntry(dir) 
      entry = DirectoryEntryName(dir)  
      If entry = "." Or entry = ".." 
        Continue 
      ElseIf DirectoryEntryType(dir) = #PB_DirectoryEntry_File 
        PureZIP_Archive_Compress(RemoveString(Path+entry, SrcPart), #True) 
        Debug "ZIP: "+RemoveString(Path+entry, SrcPart)+" ("+Str(FileSize(Path+entry))+")" 
      Else 
        Add2ZIP(Path+entry+"\", SrcPart) 
      EndIf 
    Wend 
    FinishDirectory(dir) 
  EndIf 
EndProcedure

Procedure winprogress()
  If OpenWindow(#Progression, 399, 288, 202, 35, "Compression...", #PB_Window_TitleBar | #PB_Window_ScreenCentered|#PB_Window_BorderLess)
   StickyWindow(#Progression,1)
    If CreateGadgetList(WindowID(#Progression))
      TextGadget(#Txt2, 15, 10, 170, 15, "Archivage des fichiers en cours ...", #PB_Text_Center)
    EndIf
  EndIf
EndProcedure
  
Procedure CompresserArchive() 
  If GetGadgetState(#ExplorerList_1) > -1 
    nom_archive$ = PeekS(*ZoneMemoire) 
     Debug nom_archive$ 
    If nom_archive$ And destination$ 
      PureZIP_Archive_Create(destination$+nom_archive$, #APPEND_STATUS_CREATE)
      dernier_element=CountGadgetItems(#ExplorerList_1)-1 

      For position_element=0 To dernier_element 
        etat_gadget=GetGadgetItemState(#ExplorerList_1,position_element)  
        If etat_gadget & #PB_Explorer_Selected 
          If etat_gadget & #PB_Explorer_File
            SourceDir$ = GetGadgetText(#ExplorerList_1) + GetGadgetItemText(#ExplorerList_1,position_element, 0)
              PureZIP_Archive_Compress(SourceDir$,#False)
                ElseIf etat_gadget & #PB_Explorer_Directory ; ... un répertoire
              SourceDir$ = GetGadgetText(#ExplorerList_1)+ GetGadgetItemText(#ExplorerList_1,position_element, 0)
             SetCurrentDirectory_(@SourceDir$)
            Add2ZIP(SourceDir$, SourceDir$)
          EndIf 
        EndIf  
      
      Next   
      PureZIP_Archive_Close(): CloseWindow(#Progression)
    Else 
      MessageRequester("Compressor","Please check archive name and destination !",#MB_ICONERROR) 
    EndIf 
  Else 
    MessageRequester("Compressor","Please select files",#MB_ICONERROR) 
  EndIf
EndProcedure 


Procedure statusbar1() 
  Protected  Nombre_Elements 
  Nombre_Elements = CountGadgetItems(#ExplorerList_1) 
  
  If CreateStatusBar(#StatusBar_Window_0, WindowID(#Window_0)) 
    AddStatusBarField(175) 
    AddStatusBarField(480) 
    StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " "+"élément(s)") 
  EndIf
EndProcedure 

 
OpenWindow_Window_0() 
statusbar1() 
Repeat 
  Select WaitWindowEvent() 
    
    ; /////////////////// 
    Case #PB_Event_Menu 
      Select EventMenu() 
        Case #Menu_Window_0_5_Compresser 
          If GetGadgetState(#ExplorerList_1) > -1 
            OpenWindow_Archive() : SetGadgetText(#String_9,"Archive.zip") 
          Else:MessageRequester("Compressor","Please select files !",#MB_ICONERROR)  
          EndIf 
          
        Case #Menu_Window_0_7_Decompresser 
        Case #Menu_Window_0_0_ExtraireUneArchive
        Case #Menu_Window_0_0_OuvrirUneArchive 
        Case #Menu_Window_0_1_TesterUneArchive 
        Case #Menu_Window_0_2_MotDePasse: 
        Case #Menu_Window_0_3_Configuration
        Case #Menu_Window_0_4_Quitter:Break 
      EndSelect  
      
      ; //////////////////////
    Case #PB_Event_Gadget 
      EventGadget = EventGadget() 
      EventType = EventType() 
      Select EventGadget() 
        
        Case #ExplorerComboGadget 
          SetGadgetText(#ExplorerList_1, GetGadgetText(#ExplorerComboGadget)) 
          If  EventType() = #PB_EventType_Change 
            Nombre_Elements = CountGadgetItems(#ExplorerList_1) 
          StatusBarText(#StatusBar_Window_0,0, Str(Nombre_Elements) + " élément(s)") :EndIf 
          
          
        Case #ButtonGadget_239 
          CloseWindow(#Window_2) 
          
        Case #ButtonGadget_240 
          nom_archive$ = GetGadgetText(#String_9) 
          destination$ = GetGadgetText(#String_17) 
          pwd$ = GetGadgetText(#StringGadget_246) 
          pwd2$ = GetGadgetText(#StringGadget_246) 
          
          *ZoneMemoire = AllocateMemory(2500) 
          *Pointeur = *ZoneMemoire
          PokeS(*ZoneMemoire, nom_archive$)
           
       If  nom_archive$ <> "" And destination$ <> "" And pwd$ = pwd2$ And pwd$ = "" And pwd2$ = "" 
          CloseWindow(#Window_2): SetWindowState(#Window_0,#PB_Window_Minimize):winprogress()
           CompresserArchive():FreeMemory(*ZoneMemoire)
            SetWindowState(#Window_0,#PB_Window_Normal):CloseWindow(#Progression)
          EndIf 
          
        Case #ExplorerList_1 
          If  EventType() = #PB_EventType_LeftDoubleClick 
          SetGadgetText(#ExplorerComboGadget,GetGadgetText(#ExplorerList_1)): EndIf 
        Case Bt_Annuler
          End
      EndSelect 
      
      ; //////////////////////    
    Case #PB_Event_CloseWindow 
      EventWindow = EventWindow() 
      If EventWindow = #Window_0 
        Break 
      ElseIf EventWindow = #Window_2 
        CloseWindow(#Window_2) 
      EndIf 
  EndSelect 
ForEver 
:D :D :D