home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Zipping_wi2123818172008.psc / Form1.frm < prev    next >
Text File  |  2008-08-17  |  10KB  |  321 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Zip and Unzip with Info-Zipp Dll - by J÷rg von Busekist"
  5.    ClientHeight    =   8775
  6.    ClientLeft      =   60
  7.    ClientTop       =   450
  8.    ClientWidth     =   9510
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   8775
  11.    ScaleWidth      =   9510
  12.    StartUpPosition =   3  'Windows-Standard
  13.    Begin VB.CommandButton cmdClearMessages 
  14.       Caption         =   "Clear"
  15.       Height          =   1095
  16.       Left            =   8400
  17.       TabIndex        =   15
  18.       Top             =   7560
  19.       Width           =   855
  20.    End
  21.    Begin VB.TextBox txtMessages 
  22.       Height          =   1095
  23.       Left            =   240
  24.       MultiLine       =   -1  'True
  25.       ScrollBars      =   2  'Vertikal
  26.       TabIndex        =   14
  27.       Top             =   7560
  28.       Width           =   7935
  29.    End
  30.    Begin VB.TextBox txtTargetZipFile 
  31.       Height          =   285
  32.       Left            =   2760
  33.       TabIndex        =   12
  34.       Text            =   "H:\Dokumente und Einstellungen\Admin.JOX\Desktop\Unzip-Beispiel\example.zip"
  35.       Top             =   1200
  36.       Width           =   6375
  37.    End
  38.    Begin VB.TextBox txtFileToZip 
  39.       Height          =   285
  40.       Left            =   2760
  41.       TabIndex        =   10
  42.       Text            =   "H:\Dokumente und Einstellungen\Admin.JOX\Desktop\Unzip-Beispiel\mFileI.bas"
  43.       Top             =   480
  44.       Width           =   6375
  45.    End
  46.    Begin VB.CommandButton cmdZipZip 
  47.       Caption         =   "Zip file"
  48.       Height          =   615
  49.       Left            =   480
  50.       TabIndex        =   9
  51.       Top             =   600
  52.       Width           =   1815
  53.    End
  54.    Begin VB.CommandButton cmdZipDeleteSelected 
  55.       Caption         =   "Delete selected files"
  56.       Enabled         =   0   'False
  57.       Height          =   375
  58.       Left            =   4800
  59.       TabIndex        =   8
  60.       Top             =   3720
  61.       Width           =   4095
  62.    End
  63.    Begin VB.CommandButton cmdZipExtractSelected 
  64.       Caption         =   "Extract selected files"
  65.       Enabled         =   0   'False
  66.       Height          =   375
  67.       Left            =   480
  68.       TabIndex        =   7
  69.       Top             =   3720
  70.       Width           =   3735
  71.    End
  72.    Begin VB.CommandButton cmdZipUnzip 
  73.       Caption         =   "Extract all"
  74.       Height          =   615
  75.       Left            =   480
  76.       TabIndex        =   6
  77.       Top             =   2760
  78.       Width           =   1815
  79.    End
  80.    Begin MSComctlLib.ListView lsvZip 
  81.       Height          =   3135
  82.       Left            =   240
  83.       TabIndex        =   4
  84.       Top             =   4320
  85.       Width           =   9015
  86.       _ExtentX        =   15901
  87.       _ExtentY        =   5530
  88.       MultiSelect     =   -1  'True
  89.       LabelWrap       =   -1  'True
  90.       HideSelection   =   -1  'True
  91.       _Version        =   393217
  92.       Icons           =   "imlZip"
  93.       SmallIcons      =   "imlZip"
  94.       ColHdrIcons     =   "imlZip"
  95.       ForeColor       =   -2147483640
  96.       BackColor       =   -2147483643
  97.       BorderStyle     =   1
  98.       Appearance      =   1
  99.       NumItems        =   0
  100.    End
  101.    Begin VB.TextBox txtExtractDir 
  102.       Height          =   285
  103.       Left            =   2760
  104.       TabIndex        =   3
  105.       Text            =   "H:\Dokumente und Einstellungen\Admin.JOX\Desktop\Unzip-Beispiel\example\"
  106.       Top             =   2880
  107.       Width           =   6375
  108.    End
  109.    Begin VB.TextBox txtZipfile 
  110.       Height          =   285
  111.       Left            =   2760
  112.       TabIndex        =   1
  113.       Text            =   "H:\Dokumente und Einstellungen\Admin.JOX\Desktop\Unzip-Beispiel\example.zip"
  114.       Top             =   2280
  115.       Width           =   6375
  116.    End
  117.    Begin VB.CommandButton cmdZipShow 
  118.       Caption         =   "Show Zip file content"
  119.       Height          =   615
  120.       Left            =   480
  121.       TabIndex        =   0
  122.       Top             =   2040
  123.       Width           =   1815
  124.    End
  125.    Begin MSComctlLib.ImageList imlZip 
  126.       Left            =   8520
  127.       Top             =   3480
  128.       _ExtentX        =   1005
  129.       _ExtentY        =   1005
  130.       BackColor       =   -2147483643
  131.       MaskColor       =   12632256
  132.       _Version        =   393216
  133.    End
  134.    Begin VB.Line Line1 
  135.       X1              =   120
  136.       X2              =   9360
  137.       Y1              =   1740
  138.       Y2              =   1740
  139.    End
  140.    Begin VB.Label Label4 
  141.       Caption         =   "Name of the generated Zip-File"
  142.       Height          =   255
  143.       Left            =   2760
  144.       TabIndex        =   13
  145.       Top             =   960
  146.       Width           =   2655
  147.    End
  148.    Begin VB.Label Label3 
  149.       Caption         =   "File to zip"
  150.       Height          =   255
  151.       Left            =   2760
  152.       TabIndex        =   11
  153.       Top             =   240
  154.       Width           =   2655
  155.    End
  156.    Begin VB.Label Label2 
  157.       Caption         =   "Directory where to extract"
  158.       Height          =   255
  159.       Left            =   2760
  160.       TabIndex        =   5
  161.       Top             =   2640
  162.       Width           =   3135
  163.    End
  164.    Begin VB.Label Label1 
  165.       Caption         =   "Zip file to show or to extract"
  166.       Height          =   255
  167.       Left            =   2760
  168.       TabIndex        =   2
  169.       Top             =   2040
  170.       Width           =   2655
  171.    End
  172. End
  173. Attribute VB_Name = "Form1"
  174. Attribute VB_GlobalNameSpace = False
  175. Attribute VB_Creatable = False
  176. Attribute VB_PredeclaredId = True
  177. Attribute VB_Exposed = False
  178. Option Explicit
  179.  
  180. Private Sub cmdClearMessages_Click()
  181.  
  182. txtMessages.Text = ""
  183.  
  184. End Sub
  185.  
  186. Private Sub Form_Load()
  187.  
  188. 'Problem with the DLLs? You can get the DLLs here:
  189. 'ftp://ftp.dante.de/tex-archive/tools/zip/info-zip/WIN32/
  190. 'files: unz552dN.zip and zip232dN.zip  (08-15-2008)
  191. 'there may newer versions
  192.  
  193. 'Rename the Dlls if necessary (=> no DLLs on Planet-Source-Code.com allowed)
  194. If Not FileExists(App.Path & "\unzip32.dll") Or Not FileExists(App.Path & "\zip32.dll") Then
  195.     Call MsgBox("The program didn't found the Info-Zip Dlls in the program path." _
  196.                 & vbCrLf & "You can get these DLLs here:" _
  197.                 & vbCrLf & "" _
  198.                 & vbCrLf & "ftp://ftp.dante.de/tex-archive/tools/zip/info-zip/WIN32/" _
  199.                 & vbCrLf & "" _
  200.                 & vbCrLf & "or at: http://www.info-zip.org" _
  201.                 & vbCrLf & "" _
  202.                 & vbCrLf & "files: unz552dN.zip and zip232dN.zip  (08-15-2008)" _
  203.                 & vbCrLf & "" _
  204.                 & vbCrLf & "there may newer versions" _
  205.                 , vbInformation, "No Dlls ?")
  206. End If
  207.  
  208. 'Defaultpaths in the textboxes
  209. txtFileToZip.Text = App.Path & "\*.*"
  210. txtTargetZipFile.Text = App.Path & "\example.zip"
  211. txtZipfile.Text = App.Path & "\example.zip"
  212. txtExtractDir.Text = App.Path & "\example\"
  213.  
  214. End Sub
  215.  
  216. Private Sub cmdZipZip_Click()
  217.  
  218. Dim arFiles() As String   'to hold the filenames
  219. Dim ZipPath As String     'to hold the ZipPath
  220.  
  221. 'If you want to zip all Files in a given directory then set
  222. 'arFiles(0) = "*.*" . If Recursion = 2 then it will zip also
  223. 'all the files in subdirectories relative to the Zippath.
  224. 'If you want to zip all files of a choosen folder including also the
  225. 'folder itself (as relative in the zip file) then set
  226. 'arFiles(0) = "Foldertozip\*"
  227.  
  228. 'Fill the array with file paths
  229. ReDim Preserve arFiles(1)        'if you put in more files you have to ReDim bigger
  230. arFiles(0) = GetPath(txtFileToZip.Text, FileName)
  231.  
  232. 'Path to zip
  233. ZipPath = GetPath(txtFileToZip.Text, FilePath)
  234.  
  235. 'Call the Zipfunction in modVBZip
  236. Call ZipFiles(txtTargetZipFile.Text, arFiles, ZipPath, 2)
  237.  
  238. MsgBox "Done."
  239.  
  240. End Sub
  241.  
  242. Private Sub cmdZipShow_Click()
  243.  
  244. 'needs an ImageList on the form and its assignment to the listview
  245.  
  246. Dim i As Long
  247. Dim sIcon As String
  248. Dim itmX As ListItem
  249. Dim Dateinamen() As String      'String array to get the result
  250.  
  251. lsvZip.ListItems.Clear
  252.  
  253. 'Routine in modVBUnzip
  254. Dateinamen = ZipShow(txtZipfile.Text, txtExtractDir.Text)
  255.  
  256. 'Show all files in the listview
  257. For i = 0 To UBound(Dateinamen) - 2
  258.     If Right(Dateinamen(i), 1) <> "/" Then 'Because the AddIcon routine supports only files
  259.         sIcon = AddIconToImageList(Dateinamen(i), imlZip, "DEFAULT") 'sometimes the Zip-Routine gives back also folders in the form "folder/"
  260.         Set itmX = lsvZip.ListItems.Add(, Dateinamen(i), Dateinamen(i), , sIcon)
  261.         itmX.Icon = sIcon
  262.     End If
  263. Next i
  264. lsvZip.Sorted = True
  265.  
  266. cmdZipExtractSelected.Enabled = True
  267. cmdZipDeleteSelected.Enabled = True
  268.  
  269. End Sub
  270.  
  271. Private Sub cmdZipUnzip_Click()
  272.  
  273. Call ZipExtractAll(txtZipfile.Text, txtExtractDir.Text)
  274.  
  275. MsgBox "Done"
  276.  
  277. End Sub
  278.  
  279. Private Sub cmdZipExtractSelected_Click()
  280.  
  281. Dim itmX As ListItem
  282. Dim i As String
  283. Dim arFilesToExtract() As String
  284.  
  285. i = 0
  286. For Each itmX In lsvZip.ListItems
  287.     If itmX.Selected = True Then
  288.         i = i + 1
  289.         ReDim Preserve arFilesToExtract(i)
  290.         arFilesToExtract(i - 1) = itmX.Text
  291.     End If
  292. Next itmX
  293.  
  294. Call ZipExtractSingleFiles(txtZipfile.Text, txtExtractDir.Text, arFilesToExtract)
  295.  
  296. MsgBox "Done"
  297.  
  298. End Sub
  299.  
  300. Private Sub cmdZipDeleteSelected_Click()
  301.  
  302. Dim itmX As ListItem
  303. Dim i As String
  304. Dim arFilesToDelete() As String
  305.  
  306. i = 0
  307. For Each itmX In lsvZip.ListItems
  308.     If itmX.Selected = True Then
  309.         i = i + 1
  310.         ReDim Preserve arFilesToDelete(i)
  311.         arFilesToDelete(i - 1) = itmX.Text
  312.     End If
  313. Next itmX
  314.  
  315. Call DeleteFilesFromZip(txtZipfile.Text, arFilesToDelete)
  316.  
  317. Call cmdZipShow_Click
  318.  
  319. End Sub
  320.  
  321.