Click to See Complete Forum and Search --> : progress bar help


Rayman2
December 15th, 2005, 10:15 AM
i need some help with progres bar :S i am deleteing something from files and that takes some time and i would like to show progress bar and how much it will take till end :S i was reading help but i dont have any idea how to put progressbar in here :S


while (a < this->Meritve->Items->Count)
{
if (this->Meritve->Items[ a ]->Checked::get())
{
l=(a)*7;
this->ShraniVFile->BrisanjeZapisov(l,7);
this->Meritve->Items[ a ]->Remove();
}
a++;
}



i would like that when this while loop is doing that progress bar would be shown how much progres was done :S

can some one help me with some code :S

LP

slanted
December 15th, 2005, 10:40 AM
I'm not a windows C++ coder, but progress bars are pretty simple...


pbar1->Visible = true;
pbar1->Maximum = this->Meritve->Items->Count;
pbar1->Minimum = 1;
pbar1->Value = 1;
pbar1->Step = 1;

while (a < this->Meritve->Items->Count)
{
if (this->Meritve->Items[ a ]->Checked::get())
{
l=(a)*7;
this->ShraniVFile->BrisanjeZapisov(l,7);
this->Meritve->Items[ a ]->Remove();
}
a++;
pbar1->PerformStep();
}

Notsosuperhero
December 15th, 2005, 10:49 AM
To create a progress bar, you have to call InitCommonControls() or InitCommonControlsEx() (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/common/functions/initcommoncontrolsex.asp) InitCommonControlsEx() somewhere in WinMain. You must also include commctrl.h and link to comctl32.lib. When you create the child window specify PROGRESS_CLASS as the class name.
You can then send a PBM_SETRANGE (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/progbar/messages/pbm_setrange.asp) message to set the progress bar range. Then you send a PBM_SETSTEP (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/progbar/messages/pbm_setstep.asp) to specify how much the bar will be incremented each time(default is 10). To actually increase the bar you use PBM_STEPIT (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/progbar/messages/pbm_setstep.asp).

This is assuming you are not creating this as a dialog.

Hope that helps, I was stuck on these for a while too.

Rayman2
December 15th, 2005, 11:29 AM
thanx to you both

Lp

NoHero
December 15th, 2005, 12:36 PM
[ Moved Thread ]