0

Hi guys I'm currently trying to get to grips with winforms GUI programming in visual studio C++.

I'm having an issue that's been addressed a little in c#, but how do you update the progress of the progress bar while your internal program is iterating through loop. I'm especially interested in mathematical modelling but have no idea how to implement a decent progress bar. Any help on the topic would be great. Here's what I've got so far:

private: System::Void button6_Click(System::Object^  sender, System::EventArgs^  e) 
         {
             this->timer1->Start(); //Inside a start button

         }
private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) 
{

         //this->progressBar1->PerformStep();
         this->progressBar1->Minimum=0;
         this->progressBar1->Maximum=100;

         for(int i = 0; i <= 100; i++) 
         {
           this->progressBar1->Value = i;
           this->progressBar1->PerformStep();
         }      


}
Ross
  • 51
  • 6
  • Your question is kind of generic. What do you mean by mathematical modelling? How to determine what percent of your long running job is done? That would be highly specific to the job and is up to you to calculate (although most of the times, these are pretty rough estimates). Other than that, the main issue with progress bars is that they are on the GUI thread while your long running task is on another thread (in order to keep the GUI responsive) and when updating the value of the progress bar, you have to observe the rules of updating GUI from another thread. – o_weisman Mar 20 '16 at 13:09
  • Let's say I wanted a progress bar to reflect the progress of a calculation inside a "for loop". – Ross Mar 29 '16 at 16:51
  • I believe your questions is already covered here: http://stackoverflow.com/questions/12126889/how-to-use-winforms-progress-bar . If that is not the case, then please explain your needs further. – o_weisman Mar 30 '16 at 05:01

0 Answers0