* DelZip wrapper class.
* Written by Andrus Moor, Eetasoft
* Please send any improvements and suggestions to eetasoft@online.ee
* Required improvements:
* 1. OnProgess() event should allow to interrupt if Esc key or cancel button is
* pressed. .Cancel property does not work.
* 2. OCX file German resource strings should be changed to english using resource hacker:
* http://rpi.net.au/~ajohnson/resourcehacker
* a. You open the zipmaster .ocx file
* b. then choose Action | Replace other resource from the menu
* c. open the desired language resource file (ZipMsgUS.res) from
* http://www.geocities.com/SiliconValley/Network/2114/index.html
* d. Replace the complete string table available (16 times)
* 3. or even better, run time translation should be added.
* 4. I need the option to exlude some files during unzipping.
* 5. If I use options
* .AddDirNames = .t. and
* .AddRecurseDirs = .t.
* and create a zip file in C: disk, it adds a 001 suffix to file name.
* Is it possible to eliminate this: delzip must recognize a hard drive
* and will not apped this suffix ?
* 6. .ocx must be created from the latest delzip release. Problably this
* resolves problems 1-4
* 7. WAIT WINDOW NOWAIT in OnProgress() event flashes strangely. Why ?
* It should be replaced by progress bar.
* 8. Creating zip file to cdrom (mounted using hp easy cd creator) gives error
* this disk could not be formatted but creates zip file ok.
LOCAL cOnError
cOnError = ON('error')
ON ERROR NOTE
THIS.oZip = CREATEOBJECT( "ZipMastr2XControl1.ZipMastr2X" )
ON ERROR &cOnError
IF VARTYPE( THIS.oZip ) #'O' && For vfp 5-6, use VARTYPE.PRG emulator
* This searces the .exe file starting directory also:
DECLARE INTEGER DllRegisterServer ;
IN ZipM2X.OCX ;
AS __DllRegisterServer__
IF __DllRegisterServer__()#0
MESSAGEBOX( 'ZipMaster registration fails')
SET DEFAULT TO (THIS.cOldFolder)
RETURN .F.
ENDIF
ENDIF
THIS.oZip = CREATEOBJECT( "ZipMastr2XControl1.ZipMastr2X" )
SET DEFAULT TO (THIS.cOldFolder)
***********************************
* ZIP and UZIP methods are for simple operations only.
* For more sophisticated control, use oZip property directly.
* lAddMove - .t. if files are moved to file
PROCEDURE ZIP
LPARAMETERS cDestFile, cSourceFiles, lAddMove
WITH THIS.oZip
.ZipFilename = m.cDestFile
* this will not work: .ZipComment = 'Created by Eeva ' + dtoc(date())
.AddMove = m.lAddMove
PROCEDURE IZipMastr2XEvents_OnProgress(ProgrType AS VARIANT, ;
Filename AS STRING, FileSize AS NUMBER) AS VOID
DO CASE
CASE ProgrType=d_TotalSize2Process
THIS.cursize = 0
THIS.totalsize = FileSize
CASE ProgrType=d_Totalfiles2Process
THIS.nCurFile = 0
THIS.nfileCnt = FileSize
CASE ProgrType=d_NewFile
THIS.nCurFile = THIS.nCurfile +1
THIS.curfile = Filename
CASE ProgrType = d_EndOfBatch
WAIT CLEAR
OTHERWISE
THIS.cursize = THIS.cursize + filesize
* bug: constand width wait window flashes. Why ?
WAIT WINDOW NOCLEAR AT SROWS()/2, SCOLS()/5 NOWAIT ;
'Total ' + TRANSFORM(THIS.cursize/THIS.TotalSize*100,'999')+'%'+CHR(13) + ;
'File ' + THIS.curfile + CHR(13) + ;
SPACE(120)+ CHR(13) + ;
'Files ' +TRANSFORM(THIS.nCurFile)+ '/'+TRANSFORM(THIS.nfileCnt)+ CHR(13)+ ;
'KBytes ' +LTRIM(TRANSFORM(THIS.cursize/1024,'999 999 999 999'))+ '/'+LTRIM(TRANSFORM(THIS.totalsize/1024,'999 999 999 999'))
ENDCASE
* Bug: it is not possible to interrupt: this did not work:
*IF INKEY()=27
* .cancel = .t.
* ENDIF
ENDPROC
PROCEDURE IZipMastr2XEvents_OnMessage(ErrCode AS NUMBER, MESSAGE AS STRING) AS VOID
* critical errors are writen out even if this procedure does not run
IF ErrCode#0
MESSAGEBOX( 'Error '+TRANSFORM(Errcode, '@0') + CHR(13) + ;
TRANSFORM(MESSAGE), 'Zip', 16 )
ENDIF
ENDPROC
ENDDEFINE