>I am tring to download some files via FTP protcol using Robert Abram's FTP class. I rebuild this class to Visual (by copy & paste) & made some modification to show progress of the donwload process (Thanks again Cetin) by creating Progress event w/ the class. Somethng like that:
>
>
>
> lnSize = FtpGetFileSize(hFile, @lpdwFileSizeHigh)
> lnSize = lnSize + lpdwFileSizeHigh * (0xFFFFFFFF+1)
>
> hOut = FCREATE(lcNewFile)
> lnBytesWritten = 0
> ret_val = .T.
> DO WHILE lnBytesWritten < lnSize
> lpdwNumberOfBytesRead = 0
> lcRead = SPACE(this.bites_to_read)
> IF InternetReadFile(hFile, @lcRead, this.bites_to_read, @lpdwNumberOfBytesRead) = 0
> THIS.GetExtendedError()
> THIS.CloseFtpConnection()
> RETURN .F.
> ENDIF
> lnBytesWritten = lnBytesWritten + FWRITE(hOut,lcRead,lpdwNumberOfBytesRead)
> this.Progress(lnBytesWritten, lnSize)
> IF INKEY() == 27
> ret_val = .F.
> EXIT
> ENDIF
> ENDDO
> =FCLOSE(hOut)
>...
>
>
>I put that class in the form where I have ProgressBar control & modify Progress event of the FTP class:
>
>
> LPARAMETERS lnBytesWritten, lnSize
> thisform.ProgressBar.Value = INT(lnBytesWritten / lnSize * 100)
> thisform.Label1.Caption = STR(lnBytesWritten) + " / "+ STR(lnSize)
>
>
>but when I run the download, caption of the label is changed, but the progressbar not.
>Why?
>When I pass a progressbar as a parameter to FTP class & put it into Progress Event everithing is OK.
Borislav,
You're calculating percentage there and setting progbar value as so (min = 0, max=100).
Might it be that initially you set Progbar.Max = lnFileSize and not 100 ( Filesize is high enough not to move when it's under 100).
I simply set Progbar.Max to lnFileSize and on update :
with Progbar
.Value = Min(lnBytesWritten, .Max)
endwith
Cetin