Click here to Skip to main content
15,885,811 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello!!!,

How to get a message "2 out of 5" has been completed while using progress bar?
Posted
Updated 28-Apr-10 1:09am
v2

What I would do:

Create a small window with a progress bar and a label. Let this show your status. Now each time an item finishes with an update (or whatever you're doing), update the label with "X items out of Total have completed" and update the progressbar so it'll fill up just that extra bit.

Pseudo code:

Integer total = ItemsToProgress.Count();
Integer done = 0;

ProgressWindow progWin = new ProgressWindwos();
progWin.Label1.Text = done & " items out of " & total & " completed";
progWin.Bar.Completed = done / total;
progWin.Show();

foreach (item in ItemsToProgress) {
  ProcessItemFunction(item);
  done++;
  progWin.Label1.Text = done & " items out of " & total & " completed";
  progWin.Bar.Completed = done / total;
}

progWin.Close();
progWin.Dispose();
 
Share this answer
 
v2
Unless you inherit/subclass the progress bar control, you cannot write text over it. So, you need to use label/static-text control to display your progress.
For progress bar, you need to use CProgressCtrl class.
 
Share this answer
 
There's not many articles under the progress bar section of codeproject, but this article has a progress bar with text on it:
How long is this process going to take?[^]

You can adapt that to your heart's content.

DavidCrow is a very reliable programmer, so it should be good code!

Iain.
 
Share this answer
 
You should iherit from CProgressCtrl and make it owner-drawn (you could do it via the Create function or using GetStyle and SetStyle); then add a message-handler for the WM_DRAWITEM message and on it you have to make the shole work (i.e. draw the progress-bar border, background, foreground, text, etc.)
 
Share this answer
 
Hi KenBonny,

I do want to display message on Progress Bar not somewhere near to progress bar.

I tried your method which is not giving proper result.

And i do want to do this in MFC VC++.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900