home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / cx201 / vbcxf.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-03-01  |  7.4 KB  |  254 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "CXF"
  4.    Height          =   5445
  5.    Left            =   1065
  6.    LinkTopic       =   "Form1"
  7.    MaxButton       =   0   'False
  8.    MinButton       =   0   'False
  9.    ScaleHeight     =   5040
  10.    ScaleWidth      =   5055
  11.    Top             =   1140
  12.    Width           =   5175
  13.    Begin TextBox dtext 
  14.       Height          =   285
  15.       Left            =   2160
  16.       TabIndex        =   2
  17.       Text            =   "c:\test2.cxf"
  18.       Top             =   960
  19.       Width           =   2535
  20.    End
  21.    Begin TextBox ctext 
  22.       Height          =   285
  23.       Left            =   2160
  24.       TabIndex        =   1
  25.       Text            =   "c:\test1.cxf"
  26.       Top             =   600
  27.       Width           =   2535
  28.    End
  29.    Begin TextBox itext 
  30.       Height          =   285
  31.       Left            =   2160
  32.       TabIndex        =   0
  33.       Top             =   240
  34.       Width           =   2535
  35.    End
  36.    Begin CommandButton decompress 
  37.       Caption         =   "decompress"
  38.       Height          =   495
  39.       Left            =   240
  40.       TabIndex        =   4
  41.       Top             =   2160
  42.       Width           =   1935
  43.    End
  44.    Begin Frame method 
  45.       Caption         =   "Compression"
  46.       Height          =   2175
  47.       Left            =   2760
  48.       TabIndex        =   6
  49.       Top             =   1440
  50.       Width           =   1935
  51.       Begin OptionButton methodd 
  52.          Caption         =   "CX_METHODD"
  53.          Height          =   255
  54.          Left            =   120
  55.          TabIndex        =   12
  56.          Top             =   1800
  57.          Width           =   1695
  58.       End
  59.       Begin OptionButton methodc 
  60.          Caption         =   "CX_METHODC"
  61.          Height          =   255
  62.          Left            =   120
  63.          TabIndex        =   11
  64.          Top             =   1440
  65.          Width           =   1695
  66.       End
  67.       Begin OptionButton method3 
  68.          Caption         =   "CX_METHOD3"
  69.          Height          =   255
  70.          Left            =   120
  71.          TabIndex        =   10
  72.          Top             =   1080
  73.          Width           =   1695
  74.       End
  75.       Begin OptionButton method2 
  76.          Caption         =   "CX_METHOD2"
  77.          Height          =   255
  78.          Left            =   120
  79.          TabIndex        =   9
  80.          Top             =   720
  81.          Width           =   1695
  82.       End
  83.       Begin OptionButton method1 
  84.          Caption         =   "CX_METHOD1"
  85.          Height          =   255
  86.          Left            =   120
  87.          TabIndex        =   8
  88.          Top             =   360
  89.          Value           =   -1  'True
  90.          Width           =   1695
  91.       End
  92.    End
  93.    Begin Timer ptimer 
  94.       Enabled         =   0   'False
  95.       Interval        =   1000
  96.       Left            =   2280
  97.       Top             =   2760
  98.    End
  99.    Begin CommandButton Cancel 
  100.       Caption         =   "Cancel"
  101.       Enabled         =   0   'False
  102.       Height          =   495
  103.       Left            =   240
  104.       TabIndex        =   5
  105.       Top             =   2880
  106.       Width           =   1935
  107.    End
  108.    Begin CommandButton Compress 
  109.       Caption         =   "Compress"
  110.       Height          =   495
  111.       Left            =   240
  112.       TabIndex        =   3
  113.       Top             =   1440
  114.       Width           =   1935
  115.    End
  116.    Begin Label notice 
  117.       Caption         =   "The evaluation object code runs MUCH slower than the object code that may be purchased.  Use TEST.EXE for EXACT size and speed measurements."
  118.       Height          =   615
  119.       Left            =   240
  120.       TabIndex        =   17
  121.       Top             =   4320
  122.       Width           =   4575
  123.    End
  124.    Begin Label dlabel 
  125.       Caption         =   "Decompressed File:"
  126.       Height          =   255
  127.       Left            =   360
  128.       TabIndex        =   16
  129.       Top             =   960
  130.       Width           =   1815
  131.    End
  132.    Begin Label olabel 
  133.       Caption         =   "Compressed File:"
  134.       Height          =   255
  135.       Left            =   360
  136.       TabIndex        =   15
  137.       Top             =   600
  138.       Width           =   1575
  139.    End
  140.    Begin Label ilabel 
  141.       Caption         =   "Input File:"
  142.       Height          =   255
  143.       Left            =   360
  144.       TabIndex        =   14
  145.       Top             =   240
  146.       Width           =   975
  147.    End
  148.    Begin Label size 
  149.       Height          =   255
  150.       Left            =   360
  151.       TabIndex        =   13
  152.       Top             =   3840
  153.       Width           =   2055
  154.    End
  155.    Begin Label progress 
  156.       Height          =   255
  157.       Left            =   2760
  158.       TabIndex        =   7
  159.       Top             =   3840
  160.       Width           =   2055
  161.    End
  162. Dim continue As Integer
  163. Dim bytes As Long
  164. Dim start As Single
  165. Sub Cancel_Click ()
  166.     continue = False
  167. End Sub
  168. Sub Compress_Click ()
  169.     Dim method As Integer
  170.     Dim i As Integer
  171.     If method1.Value Then method = CX_METHOD1
  172.     If method2.Value Then method = CX_METHOD2
  173.     If method3.Value Then method = CX_METHOD3
  174.     If methodc.Value Then method = CX_METHODC
  175.     If methodd.Value Then method = CX_METHODD
  176.     src$ = itext.Text
  177.     dst$ = ctext.Text
  178.     start_progress
  179.     i = cx_compress_file(dst$, src$, method, CX_MAX_BUFFER, CX_C_MAXTEMP, continue, bytes)
  180.     stop_progress
  181.     If Not continue Then
  182.         MsgBox "Canceled by operator", MB_ICONOK, "CXF"
  183.     Else
  184.         If i = 0 Then
  185.             size.Caption = diffstr(filelength(dst$), filelength(src$))
  186.             MsgBox "File Compressed", MB_ICONOK, "CXF"
  187.         Else
  188.             s$ = cx_error_message(itol(i))
  189.             MsgBox s$, MB_ICONOK, "CXF ERROR"
  190.         End If
  191.     End If
  192. End Sub
  193. Sub decompress_Click ()
  194.     Dim i As Integer
  195.     src$ = ctext.Text
  196.     dst$ = dtext.Text
  197.     start_progress
  198.     i = cx_decompress_file(dst$, src$, continue, bytes)
  199.     stop_progress
  200.     If Not continue Then
  201.         MsgBox "Canceled by operator", MB_ICONOK, "CXF"
  202.     Else
  203.         If i = 0 Then
  204.             size.Caption = diffstr(filelength(dst$), filelength(src$))
  205.             MsgBox "File Decompressed", MB_ICONOK, "CXF"
  206.         Else
  207.             s$ = cx_error_message(itol(i))
  208.             MsgBox s$, MB_ICONOK, "CXF ERROR"
  209.         End If
  210.     End If
  211. End Sub
  212. Function diffstr (a As Long, b As Long) As String
  213.     diffstr = Format(a / b, "###0.00") + " of input"
  214. End Function
  215. Function filelength (s As String) As Long
  216.     Dim h As Integer
  217.     Dim l As Long
  218.     h = binio_open(s, BINIO_OPEN_READ)
  219.     If h = -1 Then
  220.         filelength = -1
  221.     Else
  222.         l = binio_length(h)
  223.         If l = -1 Then filelength = -1 Else filelength = l
  224.         k% = binio_close(h)
  225.     End If
  226. End Function
  227. Sub ptimer_Timer ()
  228.     Dim t As Single
  229.     t = Timer - start
  230.     If t = 0# Then
  231.         progress.Caption = "0 K/sec"
  232.     Else
  233.         progress.Caption = Format$(bytes / (t * 1024), "###0.00") + " K/sec"
  234.     End If
  235. End Sub
  236. Sub start_progress ()
  237.     compress.Enabled = False
  238.     decompress.Enabled = False
  239.     cancel.Enabled = True
  240.     size.Caption = ""
  241.     progress.Caption = ""
  242.     continue = True
  243.     bytes = 0
  244.     start = Timer
  245.     ptimer.Enabled = True
  246. End Sub
  247. Sub stop_progress ()
  248.     compress.Enabled = True
  249.     decompress.Enabled = True
  250.     cancel.Enabled = False
  251.     ptimer.Enabled = False
  252.     ptimer_Timer
  253. End Sub
  254.