Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why the progress bar not moving?
Message
From
25/03/2004 12:52:15
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00889669
Message ID:
00889674
Views:
21
>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()   && Close FTP Handle
>        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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform