Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9028737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:04:00+00:00 2026-06-16T07:04:00+00:00

Trying to implement windows Progressbar showing progress of download in bytes with big numbers,

  • 0

Trying to implement windows Progressbar showing progress of download in bytes with big numbers, but am unable to do it correctly.

For a download of 2.5gb if I do following, it ends short of the full range when download is complete.

double dlSize = getDlSize();
unsigned int pbRange = (unsigned int)( dlSize / 3000 );
SendMessage( hProgressbar, PBM_SETRANGE, 0, MAKELPARAM( 0, pbRange ) );

and then set new position at each download callback as :

double dlBytes = bytesDownloaded();
unsigned int newIncrement = (unsigned int)( dlBytes / 3000 );
SendMessage( hProgressbar, PBM_DELTAPOS, (WPARAM)newIncrement, 0 );

This is a very noobish implementation, and I don’t want fall in the xy situation, So my question is what is the correct way to implement a progressbar with big numbers in tune of 2-5GBs in bytes ?


I tried both approaches suggested below by @msandiford and @NikBougalis, by taking the width of the progressbar in account and by using percentage instead of actual number, I even combined both, but in all cases the newIncrement always comes out 0, maybe that’s because dlSize is always lower( in double newIncrement comes out something like 1.15743e+007, type cast it and its 0 ).

What else I can do ?

New Code combining both approaches:

EDIT 2:
Added few checks to the code as I was constantly getting 0 for newIncrement, looks like its working now, not sure how well:

GetClientRect(hProgressbar, &pbRCClient);
pbWidth = pbRCClient.right - pbRCClient.left; // (pbWidth  its a global variable)
unsigned int pbRange = pbRCClient.right - pbRCClient.left;
SendMessage( hProgressbar, PBM_SETRANGE, 0, MAKELPARAM( 0, pbRange ) );

and while updating :

double dlSize = getDlSize();
double doubleIncrement = ( ( dlSize * pbWidth ) / totalSize );

unsigned int newIncrement;

if ( (unsigned int)doubleIncrement < 1 )
{
    blockFill += doubleIncrement;

    if ( (unsigned int)blockFill > 1 )
    {
        newIncrement = ( unsigned int )blockFill;
        SendMessage( hProgressbar, PBM_DELTAPOS, (WPARAM)newIncrement, 0 );
        blockFill = 0;
    }
}
else
{
    newIncrement = ( unsigned int )( doubleIncrement );
    SendMessage( hProgressbar, PBM_DELTAPOS, (WPARAM)newIncrement, 0 );
    //blockFill = 0;
}

EDIT 3 : Looks like its still finishing early.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:04:02+00:00Added an answer on June 16, 2026 at 7:04 am

    There probably isn’t much point making the progress bar more accurate than the number of pixels in progress bar window itself. Based on this, you should be able to scale the target to the number of pixels pretty easily.

        RECT rcClient;
        GetClientRect(hProgressBar, &rcClient);
        unsigned int pbRange = rcClient.right - rcClient.left;
    
        // Need to either keep unitsPerPixel, or recalculate later
        double pixelsPerUnit = pbRange / dlSize;
        SendMessage(hProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, pbRange));
    

    Then updating progress would be something like:

        double dlBytes = totalBytesDownloaded();
        unsigned int newProgress = (unsigned int)(dlBytes * pixelsPerUnit);
        SendMessage(hProgressBar, PBM_SETPOS, (WPARAM)newProgress, 0);
    

    If the progress window was somehow resizeable, you would need to recalculate pbRange, reset the progress bar range and recalculate unitsPerPixel in response to a WM_SIZE message.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement the Windows Update Agent API asynchronous download/installation methods, however,
I am trying to implement a progress bar for a console application in windows
I'm trying to implement binding validation using Silverlight on Windows Phone, but all I
I am trying to implement a data push from a Windows Service to a
I am trying to figure out how to implement an ASP.NET page with Windows
I am trying to implement Windows Messaging in C# in order to communicate a
I'm trying to implement the infinite scrolling within a Windows Phone 7.1 project. Most
I'm trying to implement SQL Server CE code in Windows Phone 7.1 (Mango). I
We're trying to implement a custom solution for Growl for Windows. We tell the
I'm trying to implement Copy as path option in windows context menu ,which copies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.