Discussion of article "Graphical Interfaces IX: The Progress Bar and Line Chart Controls (Chapter 2)" - page 2

 
Artyom Trishkin:

Why?

Declare the TYPES of data at the beginning of the program, and after that - initiate the values of variables of the types you declared.

m_progress_bar.Update(i,total); is nothing at all. What size bar should it show?

 
Алексей Тарабанов:
Declare the TYPES of data at the beginning of the program, and after that - initiate the values of variables of the types you have declared.
What is wrong with loop variables?
 
Алексей Тарабанов:

...

m_progress_bar.Update(i,total); is nothing at all. What size bar should it show?

double new_width=(m_current_index/m_steps_total)*m_bar_bg.XSize();
like this ...
 
Artyom Trishkin:
like this ...

1. Data type declaration.

2. Assigning a value to a variable of that type.

If it doesn't add up, then - you've messed something up.

Rules for entering a room:

1. Grenade.

2. Automatic rifle.

3. Я.

The main thing is not to mix it up.

 
Алексей Тарабанов:

1. Data type declaration.

2. Assigning a value to a variable of this type.

If it doesn't add up, then - you've messed something up.

Rules for entering a room:

1. Grenade.

2. Automatic rifle.

3. Я.

The main thing is not to mix it up.

Perhaps your words are too wise for my vacationing mind....

Why zuid-zuid-west?

 
Artyom Trishkin:

Anatoly, I apologise for being intrusive, but I would like to know how it is possible to update the progress bar inside a loop with heavy calculations.

For example, we have a progress bar m_progress_bar, we have a loop inside CProgram

Could you explain on such an "abstract" example what I don't understand?

Perhaps these heavy calculations are so long that the programme cannot exit the Func() function ? Is that why the progress bar is not updated? Maybe there is a perpetual loop there?

   m_progress_bar.Show();  // is pointless, as it is already visible immediately when showing the window (m_window.Show()) to which it is bound,
                           // and I would like to create it in a hidden state, and show it when it is needed

Each element has Show() and Hide() methods to control its visibility.

m_progress_bar.Hide();  // does not hide the progress bar for some reason, I have to hide it under another graphical object.

//---

In general, it's hard to say something on a code block taken out of context. A working example with a progress bar where everything works is shown in the article: GUIs X: Updates for Easy And Fast library (build 2).

 

Better yet, attach a minimal code for playback. This is the fastest way to get a hint. A simple diagram is enough for reproduction:

  • Main window with a button.
  • Adialogue window with two elements attached to it: (1) a button and (2) a progress bar, initially hidden (right after creation).

The button on the main window opens the dialogue box. The button on the dialogue box starts "heavy calculations".

 
Anatoli Kazharski:

Probably these heavy calculations are so long that the programme cannot exit Func() ? Is that why the progress bar is not updated? Maybe there is a perpetual loop there?

Each element has Show() and Hide() methods to control its visibility.

//---

In general, it's hard to say something on a code block taken out of context. A working example with a progress bar where everything works is shown in the article: GUIs X: Updates for Easy And Fast library (build 2).

Yes, Anatol, it works in your examples, of course. But it's just an example, it's just a decoration. The progress bar, the example of its update, is made in a timer with abstract values.

When I start doing it not in a timer with hypothetical values, but in a regular long loop inside the programme, not in a timer, the progress bar is not updated during the loop, it is shown already updated when it is shown again.

Would you mind giving an example of working with the progress bar in the main program in some loop? For example, in a loop like this:

//+------------------------------------------------------------------+
   //--- If the button is pressed
   //--- Let's show the progress bar
   m_progress_bar_d1.Show();
   for(int i=0; i<sz; i++) {
      //--- Update the progress bar
      Print("Update progress bar: index=",i,", total=",sz);
      m_progress_bar_d1.Update(i,sz);
      double a=1;
      //--- some lengthy calculations
      for(int k=0; k<(INT_MAX/16); k++) a=pow(a,a+a);
      }
   //--- Hide the progress bar
   m_progress_bar_d1.Hide();
//+------------------------------------------------------------------+

it would be interesting to see the correct operation with the progress bar, not the way I think it should be.

 
Artyom Trishkin:

Yes, Anatole, it works in your examples, of course. But they are just an example, a sham. The progress bar, the example of its update, is made in a timer with abstract values.

When I start doing it not in a timer with hypothetical values, but in a regular long loop inside the programme, not in a timer, the progress bar is not updated during the loop, it is shown already updated when it is shown again.

Maybe ChartRedraw() will help?
 
Anatoli Kazharski:
Maybe ChartRedraw() would help?

Yes, thanks, m_chart.Redraw() helped:

MetaTrader trading platform screenshots

KBR, D1, 2016.08.22.

Just2Trade Online Ltd, MetaTrader 5, Demo

KBR, D1, 2016.08.22, Just2Trade Online Ltd, MetaTrader 5, Demo