Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Progress indicator with Chilkat FTP
Message
De
24/08/2006 10:40:46
 
 
À
23/08/2006 16:01:04
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01148004
Message ID:
01148216
Vues:
22
This message has been marked as the solution to the initial question of the thread.
Hi Dragan,

here's the code I use to bind ChilKatFTP (I'm using the paid version, but it worked in the free version also). What you use for thermometer_form() is up to you, etc. toFTP is the object reference to an instantiated ChilKat FTP object. Param_val.prg is a simple program to provide a default for unpassed parameters.

enjoy,

Hank
LPARAMETERS tcTitle, toFTP
LOCAL loTherm, loProgress
tcTitle = Param_Val(tcTitle,"FTP Progress...")
loTherm = Thermometer_Form(tcTitle)
loProgress=NEWOBJECT("myclass","","",loTherm)
IF VARTYPE(toFTP) = "O"
	=EVENTHANDLER(toFTP,loProgress)
ENDIF

RETURN loProgress

DEFINE CLASS myclass AS SESSION OLEPUBLIC

	IMPLEMENTS _IChilkatFTPEvents IN "chilkatftp.chilkatftp"

	oTherm = NULL
	tStarted = NULL

	PROCEDURE INIT
		LPARAMETERS toTherm
		THIS.oTherm = toTherm
	ENDPROC

	PROCEDURE DESTROY
		THIS.oTherm.COMPLETE()
		THIS.oTherm = ""
	ENDPROC


	PROCEDURE _IChilkatFTPEvents_PutProgress(pctDone AS NUMBER) AS VOID;
			HELPSTRING "method PutProgress"
		THIS.update_therm(pctDone)
	ENDPROC

	PROCEDURE _IChilkatFTPEvents_GetProgress(pctDone AS NUMBER) AS VOID;
			HELPSTRING "method GetProgress"
		THIS.update_therm(pctDone)
	ENDPROC

	PROCEDURE update_therm(pctDone AS NUMBER)
		LOCAL lnTimeLeft, lnHrs, lnMinutes, lnTimeSpent
		IF ISNULL(THIS.tStarted)
			THIS.tStarted = DATETIME()
			THIS.oTherm.UPDATE(0,"Time Remaining: Unknown")
		ELSE
			IF pctDone = 0
				THIS.oTherm.UPDATE(0,"Time Remaining: Unknown")
			ELSE
				lnTimeSpent = (DATETIME() - THIS.tStarted)
				IF lnTimeSpent < 5
					THIS.oTherm.UPDATE(0,"Time Remaining: Unknown")
				ELSE
					lnTimeLeft = (lnTimeSpent  * 100 / pctDone) - lnTimeSpent
					lnHrs = INT(lnTimeLeft/3600)
					lnMinutes = INT((lnTimeLeft - (lnHrs * 3600)) / 60)
					lnSeconds = INT(lnTimeLeft - (lnHrs * 3600) - (lnMinutes * 60))
					THIS.oTherm.UPDATE(pctDone,"Time Remaining: " + TRANSFORM(lnHrs, "@L 99") + ":" + TRANSFORM(lnMinutes, "@L 99") + ":" + TRANSFORM(lnSeconds, "@L 99"))
				ENDIF
			ENDIF
		ENDIF
	ENDPROC

ENDDEFINE
>Chilkat FTP satisfies all my needs for FTP... but now a now need arises.
>
>Some users complain that the machine freezes on a FTP download. Since the users of this app are generally less computer literate than the average, I presume they don't know the difference between "machine freezes" and "app freezes", though either is possible.
>
>Now the least I can try to do is to have some progress indicator. However, once I issue a This.oftp.Getfile(lcFromFile, lcToFile), it's all beyond my control - the ActiveX takes over and anything I do will just have to wait until the download finishes or times out.
>
>If anyone knows how to at least download a file in chunks, or maybe if a timer would still work, or... should I just play an animated gif, or what? Does anyone have any experience with this?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform