Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to receive progress update during COPY FILE TO ?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00793714
Message ID:
00793756
Vues:
60
This message has been marked as the solution to the initial question of the thread.
Hi Dawa,

For cases like that I've a function that's based on the late Ed Rauh's code that uses SHFileOperation Win API. It supports wild cards and shows standard Windows progress bar. It requires Heap allocation class File #9482.
llSuccess = FileOpWithProgressbar("H:\TEMP\tord.dbf", "H:\TMP\TEST.dbf", "Copy")
* or copy with the same name
llSuccess = FileOpWithProgressbar("H:\TEMP\tord.dbf", "H:\TMP\", "Copy")
* or copy all dbf's
llSuccess = FileOpWithProgressbar("H:\TEMP\*.dbf", "H:\TMP\", "Copy")
...

* FUNCTION FileOpWithProgressbar
#INCLUDE SHFileOperation.h

LPARAMETERS tcSource, tcDestination, tcAction, tlUserCanceled
LOCAL lcSourceString, lcDestString, nStringBase, lcFileOpStruct, lnFlag, lnStringBase
LOCAL loHeap, lcAction, lnRetCode, llCanceled, laActionList[1]

DECLARE INTEGER SHFileOperation IN SHELL32.DLL STRING @ LPSHFILEOPSTRUCT
SET PROCEDURE TO CLSHEAP ADDITIVE
loHeap = CREATEOBJ('Heap')

lcAction = UPPER(IIF( Empty( tcAction) Or VarType(tcAction) <> "C", "COPY", tcAction))
* Convert Action name into function parameter
ALINES(laActionList, "MOVE,COPY,DELETE,RENAME", ",")
lnAction = ASCAN(laActionList, lcAction)
IF lnAction = 0
	* Unknown action
	RETURN Null
ENDIF

lcSourceString = tcSource + CHR(0) + CHR(0)
lcDestString   = tcDestination + CHR(0) + CHR(0)
lnStringBase   = loHeap.AllocBlob(lcSourceString+lcDestString)

lnFlag = FOF_NOCONFIRMATION + FOF_NOCONFIRMMKDIR + FOF_NOERRORUI

lcFileOpStruct  = NumToLONG(_screen.hWnd) + ;
                NumToLONG(lnAction) + ;
                NumToLONG(lnStringBase) + ;
                NumToLONG(lnStringBase + LEN(lcSourceString)) + ;
                NumToWORD(lnFlag) + ;
                NumToLONG(0) + NumToLONG(0) + NumToLONG(0)

lnRetCode = SHFileOperation(@lcFileOpStruct) 

* Did user canceled operation?
tlUserCanceled= ( SUBSTR(lcFileOpStruct, 19, 4) <> NumToLONG(0) )

RETURN (lnRetCode = 0)
*-----------------------------------------------------------------------------
SHFileOperation.h
* Shell File Operations

#DEFINE FO_MOVE           0x0001
#DEFINE FO_COPY           0x0002
#DEFINE FO_DELETE         0x0003
#DEFINE FO_RENAME         0x0004

#DEFINE FOF_MULTIDESTFILES         0x0001
#DEFINE FOF_CONFIRMMOUSE           0x0002
#DEFINE FOF_SILENT                 0x0004  && don't create progress/report
#DEFINE FOF_RENAMEONCOLLISION      0x0008
#DEFINE FOF_NOCONFIRMATION         0x0010  && Don't prompt the user.
#DEFINE FOF_WANTMAPPINGHANDLE      0x0020  && Fill in SHFILEOPSTRUCT.hNameMappings
		                                      && Must be freed using SHFreeNameMappings
#DEFINE FOF_ALLOWUNDO              0x0040
#DEFINE FOF_FILESONLY              0x0080  && on *.*, do only files
#DEFINE FOF_SIMPLEPROGRESS         0x0100  && means don't show names of files
#DEFINE FOF_NOCONFIRMMKDIR         0x0200  && don't confirm making any needed dirs
#DEFINE FOF_NOERRORUI              0x0400  && don't put up error UI
#DEFINE FOF_NOCOPYSECURITYATTRIBS  0x0800  && dont copy NT file Security Attributes
>Hi,everybody,
>
>I am developing an archive application using VFP7. My app needs to do alot of copying. I am using:
>
>COPY FILE C:\FILE1 TO H:\FILE2
>
>to achieve this. But, the problem is that when the file size is large, the user thinks that the computer or the app is locked up.
>
>Is there a way to receive a progress notification during a copying progress?
>
>Any help will be appreciated,
>
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform