Results 1 to 9 of 9

Thread: Showing Progress with API Functions...

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    12

    Showing Progress with API Functions...

    This is a rather simple piece of code, but I am trying to do something and am not even sure if it is possible.

    Here is the code that I am using...

    Code:
    connect_status.Text = "•Transferring file as ASCII; " & output & vbCrLf & connect_status.Text
    DoEvents
    flestat = FtpGetFile(hConnection, output, _
    main.queue.ListItems(startQueueDownload).Text, False, &H80000000,  _
    INTERNET_FLAG_TRANSFER_ASCII, 0)
    This code downloads a file from an FTP server. I want to have a progress bar or some other means of monitoring the download progress of this file. Unfortunately, the API call will not update its status until it has completely downloaded the file.

    Does anyone have any ideas of how I could go about preparing a progress bar to calculate the amount of data that has been sent in the middle of this API call. This could be accomplished by getting the local filesize of the downloaded file, but I need to find a way to temporarily pause the API function while the program calculates the amount of the file that has been downloaded.

    Thanks,
    Shawn

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Toss a DoEvents in there.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    12
    Unfortunately, DoEvents doesn't work because the code already completes the API command before proceeding

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Hmm....good point.

    Ok, how 'bout this.

    .Wav files are typically called asynchroniously so the program can continue processing while the sound file is playing. How about asynchroniously popping a form with a progress bar?

    Now, if you can determine the size of the file before processing starts, so much the better. If you can't, then fake as best you can. If you have ever watched the microsoft download status progress bar, you get the feeling thats what they do.

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2001
    Posts
    12
    I have the exact filesize in bytes before it begins transfer, but the problem lies in that a timer for example will only execute once when the process is running, this at the absolute beginning or end of the API call. I do not know how to go about resolving this issue, but is is quite important.

    Thanks for your help,
    Shawn

  6. #6
    DerFarm
    Guest
    Swinging in the dark here, but if you know the exact size of the
    file could you invoke the API to download only a certain number
    of bytes (say 10%) and then update the progress bar in
    iterations?

    Code:
    While byte_Num < full_byte_Num
       call api(byte_num to next_byte_num)
       update progress bar
       set byte_num = next_byte_num
    wend

    Don't even know if it can be done, but seems logical.

  7. #7
    Member
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    36
    I have created a small FTP tool, and was looking at putting something similar (Some sort of progress indicator) into mine. At the moment, the App seems a bit dead while the FTP is happening, it even reports Not Responding from Task manager.

    I am using the API FtpPutFile (with DoEvents just before it), and I am seeing the same thing, you get nothing back from the API till it either finishes, or dies for some reason.
    Currently I set the mouse cursor to hourglass, and hope the user doesnt get too impatient and kill my app while the FTP is going

  8. #8
    Member
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    36
    A post I read elsewhere by Shawn N is a good idea.....
    What if you used multi-threading, either create a new thread to perform the FTP API, or perhaps to monitor the progress of the API running from your main thread !!

    I guess that periodically you could check the file size of the file you are getting (or putting), and compare that to the total file size....

    hmmm I wonder if it will let me get the file size of a the mainframe dataset I am uploading.....

  9. #9
    Member
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    36
    Well the API guide tells me that Multiple threads is going to crash my VB6 Application...
    I know C++ can use multiple threads... anyone care to share some wisdom ??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width