Progress Bar

This is a discussion on Progress Bar within the Windows Programming forums, part of the Platform Specific Boards category; I know people are probably groaning right now, but yeah: I need help with these dumb things. I have a ...

  1. #1
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183

    Progress Bar

    I know people are probably groaning right now, but yeah: I need help with these dumb things. I have a function that takes a while, and while it's going I'd like to update the status bar along with it. Problem is, I can't find out how to do it. I know this was just asked, but the reply didn't help (it was a link for some message thing), and so if anyone can help please do so. Thanks.

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    A progress bar in the status bar? I don't know how to do that off the top of my head.

    But the general principal of windows progress bars, Set the progress bar's range[by sending a PBM_SETRANGE message to the control] (ie if you expect the task to take say 10 seconds, set it to 10 - where each unit represents a second which you update every second). Or instead of using time you could use say 'tasks', ie say you have 10,000 files to move, you could set the progress bar's range to 1000 and update it every 10 files (incrementing by 1 unit). Be sure to read http://msdn2.microsoft.com/en-us/library/bb760816.aspx . Take note that the maximum range of a progress bar is 65, 535.

    After setting the progress bar's range with PBM_SETRANGE you'd use PBM_DELTAPOS or PBM_SETPOS to update the position of the progress bar.

    It's all on that MSDN page.

  3. #3
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    Oh, yeah I didn't mean have one in the status bar (did I say that? oops), I just wanted to know how to use one in general.

    Anyway, thanks, I'm trying timing how long it takes to perform a function and then I'm going to use that to set the range...

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,854
    Quote Originally Posted by mikeman118 View Post
    Oh, yeah I didn't mean have one in the status bar (did I say that? oops), I just wanted to know how to use one in general.

    Anyway, thanks, I'm trying timing how long it takes to perform a function and then I'm going to use that to set the range...
    Time is a very bad way of measuring these things because;

    time is not overly accurate on Windows.
    time varies on system load.
    time varies on system type (PC specs).
    time varies in debug to release mode.

    So it will be very hard to get the same time each run.

    I use file size, number of records ect (as zacs7 pointed out) and usually reduce to a percentage. Then I can set the number of ticks to 100 and call PMB_SETPOS with the current percentage.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Updating a progress bar
    By NewGuy100 in forum C++ Programming
    Replies: 2
    Last Post: 03-13-2006, 12:00 PM
  2. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 12:32 PM
  3. Is comctl32.lib required for progress bar controls?
    By JasonD in forum Windows Programming
    Replies: 4
    Last Post: 08-28-2004, 02:30 PM
  4. progress bar newbie
    By WaterNut in forum Windows Programming
    Replies: 18
    Last Post: 08-09-2004, 01:42 PM
  5. File Through Winsock & Progress on bar
    By (TNT) in forum Windows Programming
    Replies: 4
    Last Post: 12-05-2001, 09:50 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21