Libraries: Easy Canvas - page 8

 
Nikolai Semko:

Rename is not difficult. There is Ctrl+H

But I agree with Andrei. Look for #define T or #include <Canvas\iCanvas.mqh> put it first in the project

The search for files is automatic ) There is no #define T in any file in the MQL5 folder.

I managed to find out that there is a conflict with something in TypeToBytes.mqh from TradeTransactions https://www.mql5.com/en/code/22166.

This library hasn't been changed for a long time, so most likely some innovation or bug appeared in one of the new builds )

 
Oleksii Chepurnyi:

Managed to figure out that the conflict is with something in TypeToBytes.mqh from TradeTransactions https://www.mql5.com/en/code/22166

This library hasn't been changed for a long time, so most likely some new feature or bug appeared in one of the new builds )

This is a compiler bug.

#include <TypeToBytes.mqh> // https://www.mql5.com/en/code/16282

class CLASS
{
  void Method()
  {
    datetime T[1];
    
    T[0] = 0; // '[' - name expected
  };
};

void OnStart()
{
  datetime T[1];
  
  T[0] = 0; // OK
}
 
Got it. Thank you. I'll fix it then, of course.
 

Yay, we found it! )


@fxsaber, do you track branches for "your" keywords with something automatic, or do you just scroll through all the branches regularly? You are very quick to respond to "targeted" questions.

 
Andrey Khatimlianskii:

@fxsaber, do you track branches for "your" keywords with something automatic, or do you just scroll through all the branches regularly? You answer "targeted" questions very quickly.

It happens by chance.

 

I would like to clarify for interested programmers an important point of kanvas operation in the tester mode.
A well-known programmer in this community asked me this question:

- Why in tester mode the panel created on objects is redrawn an order of magnitude faster than the one realised on kanvas, while in normal mode everything is fine with the speed of kanvas?

Having analysed it, I understood the reason and solution of this problem.

The thing is that when objects are redrawn together with the redrawing of the whole screen, and the screen in the tester is redrawn not more often than 30 frames per second.

Objects are ultimately the same canvas (internal), but when you change the properties of an object, the object's canvas is not formed (not recalculated), but is formed only at the moment of screen refresh (ChartRedraw), which happens in the tester (and in normal mode too) not more often than our eye can distinguish changes, i.e. not more often than ~ 32 frames per second.

Let's assume that the panel changes every tick. Then in the default tester the canvas will be recalculated every tick, but redrawing in the tester is still not more often than ~30 milliseconds (~30 frames per second).

In other words, kanvas will be recalculated much more often than it will be actually displayed on the screen, so there is a disproportionate overconsumption of resources.

The solution to this problem is to control recalculation and redrawing of kanvas not more often than once every 15-30 milliseconds of computer time, then there will be no unnecessary cycles of empty recalculations.

For example, like this:

void OnTick()
  {
  static uint lastCalc=0;
  uint cur=GetTickCount();
  if (cur-lastCalc>15) {
    ReDrawMyCanvas();
    lastCalc=cur;
   }
  }
 

Good afternoon.

   if(width==0) {width=W.Width;   FullWinCanvW=true; Xpos=0;} else FullWinCanvW=false;
   if(height==0){height=W.height[SubWin]; FullWinCanvH=true; Ypos=0;} else FullWinCanvH=false;
   Name+=IntegerToString(rand())+IntegerToString(rand());
   Handle=ChartGetInteger(chart_id,CHART_WINDOW_HANDLE,SubWin);
   if(!CreateBitmapLabel(chart_id,SubWin,Name,Xpos,Ypos,width,height,formatCF))
      Print("Error creating canvas: ",GetLastError());

This line in the constructor, why?

CCanvas also adds a lot to the name, including rand. Sometimes the name is so long that it exceeds the allowed length )

 
Oleksii Chepurnyi:

Good afternoon.

This line in the constructor, why?

CCanvas also adds a lot to the name, including rand. Sometimes the name is so long that it exceeds the allowed length )

Yes, I agree.
In my version of iCanvas I have already fixed it, but here it seems I forgot.

 
Version 1.40
Fixed some bugs.
In particular, fixed a bug: iCanvas object was not automatically resized vertically if there was more than one object.
 
Last version 1.40
Files:
iCanvas.mqh  48 kb