i want to ZIP / UNZIP Files using Fivewin
in TWindows i found Codeblock Slot bZip and bUnZip
- Code: Select all Expand view
- METHOD Zip( nZipInfo ) INLINE ;
If( ::bZip != nil, Eval( ::bZip, nZipInfo ),)
METHOD UnZip( nPercent ) INLINE ;
If( ::bUnZip != nil, Eval( ::bUnZip, nPercent ),)
---
there is a Sample c:\fwh\samples\testuzip.prg which use Codeblock bUnZip
Sample c:\fwh\samples\testzip.prg use Hb_ZIPFILE() but not Codeblock bZip
so how to use Codeblock bZip
both Sample use METER and Parameter nPercent / nZipInfo seem to belong to METER
can i use a "green" Windows Progressbar instead of METER
---
"why" are bZip / bUnZip and Method Zip / UnZip implement in CLASS TWindow
if Argument is that Window have Zip / Unzip since XP than Method should use "same" Way as Explorer and not "external"
this i use under harbour / HMG
- Code: Select all Expand view
- FUNCTION Unzip( cZipFile, cDestFolder )
LOCAL oShell, oZIP, oNameDest
oShell := CreateObject( "Shell.Application" )
oZIP := oShell:NameSpace( cZipFile )
oNameDest := oShell:NameSpace( cDestFolder )
oNameDest:CopyHere( oZIP:items(), 0x10 )
oShell := NIL
RETURN NIL
- Code: Select all Expand view
- FUNCTION ZIPFILE( cZipFile, aFiles, hGrid, aSourceNum )
LOCAL aHead := { 80, 75, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
LOCAL nHandle
LOCAL i, imax
LOCAL oShell
LOCAL oZIP
LOCAL oSource
LOCAL cPath
LOCAL nCount := 0
LOCAL xCount := 0
LOCAL nFiles := 0
LOCAL nPosi := 0
LOCAL oItems
LOCAL xFlag
LOCAL cFile
LOCAL cTemp
xFlag := FOF_NOCONFIRMATION + ;
FOF_NOCONFIRMMKDIR + ;
FOF_RENAMEONCOLLISION + ;
FOF_SIMPLEPROGRESS
// delete old ZIP file
IF FILE( cZipFile )
FERASE( cZipFile )
ENDIF
// create ZIP and write Header
nHandle := FCREATE( cZipFile, FC_NORMAL )
iMax := LEN( aHead )
FOR i := 1 TO iMax
FWRITE( nHandle, CHR( aHead[ i ] ) )
NEXT
FCLOSE( nHandle )
// create COM Object
oShell := CreateObject( "Shell.Application" )
oZIP := oShell:NameSpace( cZipFile )
// now add files
nFiles := LEN( aFiles )
IF nFiles > 1
xFlag += FOF_MULTIDESTFILES
ENDIF
FOR i := 1 TO nFiles
cFile := aFiles[ i ]
IF FILE( cFile )
cFile += CHR( 0 )
oZIP:CopyHere( cFile, xFlag ) // copy one file
// wait until all file are written
xCount := 0
DO WHILE .T.
nCount := oZIP:items() :Count()
IF nCount >= i
EXIT
ENDIF
hb_idleSleep( 0.1 )
xCount ++
IF xCount > 50
EXIT
ENDIF
ENDDO
ENDIF
DO EVENTS
NEXT
hb_idleSleep( 1.0 )
// clean up
oZIP := NIL
oShell := NIL
// just show Msg 1 Sec.
INKEY( 1 )
RETURN NIL