Discussion of article "Graphical Interfaces XI: Integrating the Standard Graphics Library (build 16)" - page 7

 

I reproduced it. I have to resize the panel when the slider is at the top of the panel. After that the slider and all elements on the panel hangs.

[Deleted]  

Hello

has anyone found the cause of the glitch in the post above?

I get the error"array out of range in 'WndEvents.mqh' (287,72)"

 
Спартак Угланов:

Hello

Has anyone found the cause of the glitch in the post above?

I get the error "array out of range in 'WndEvents.mqh' (287,72)"

stick a check for out of range in there and that's it.

[Deleted]  
Konstantin:

just put an overrun check in there and that's it.

It's an interesting idea, but how?


      int available_elements_total=CWndContainer::AvailableElementsTotal(m_active_window_index);
      int ass = ArraySize(m_wnd[m_active_window_index].m_available_elements);
      Print("ass = ",ass," available_elements_total = ",available_elements_total);
      for(int e=0; e<available_elements_total; e++)
        {
         CElement *el=m_wnd[m_active_window_index].m_available_elements[e];


12 elements, there should be no out-of-range, theoretically.

(TradePanelTest example from the article series)

 
Спартак Угланов:

It's an interesting idea, but how?



12 elements, there should be no out-of-range, theoretically.

(TradePanelTest example from the article series)

Well, if there is an error, it means there is an error, run it with a debugger, it is the surest way to see what is going on there.

[Deleted]  
Konstantin:

Well, if the error is present, it means it's there, run it with a debugger, it's the surest way to see what's going on there.

I moved the project to a folder with a different name and renamed the indicator file, it works without errors.

I was born on Monday :O)

 
Anatoli Kazharski:


 

In recent builds, we have added a message to the compiler for those cases when an ancestor method is overloaded in a descendant:

deprecated behavior, hidden method calling will be disabled in a future MQL compiler version    

Example

struct SFoo
  {
   static void func(int)
     {
      Print(__FUNCSIG__);
     }
  };
 
struct SBar : SFoo
  {
   static void func(double)
     {
      Print(__FUNCSIG__);
     }     
  };

void OnStart()
  {
   SBar::func(_Digits);       // !!! will be called SFoo::func(int) - it is more appropriate.
  }

In this case, the func(int) function of the SFoo ancestor is called in the SBar descendant class, because the compiler did not find it in the descendant. The descendant has only the func(double) function, and the compiler tries to find a function with a suitable parameter in the inheritance tree.

That is, the MQL5 compiler performs overloading instead of overriding the method in the descendant. At the beginning of the language development, this relaxation of the MQL5 compiler was not considered critical. But it may be changed in the future, so now an explicit warning is issued to developers of MQL5 programmes to take into account and correct their codes.

Strictly speaking, overriding is a bit broader concept, you can search the difference between overloading and overriding on the Internet
.

 
MetaQuotes Software Corp.:

I don't understand anything, but it's very interesting! The compiler swears at several functions, here's one of them, where does it dislike it?

//+------------------------------------------------------------------+
//| The availability of the element|
//+------------------------------------------------------------------+
void CElement::IsAvailable(const bool state)
  {
//--- Exit if already set
   if(state==CElementBase::IsAvailable())
      return;
//--- Set
   CElementBase::IsAvailable(state);
//--- Other elements
   int elements_total=ElementsTotal();
   for(int i=0; i<elements_total; i++)
      m_elements[i].IsAvailable(state);
//--- Set priorities for left mouse button clicks
   if(state)
      SetZorders();
   else
      ResetZorders();
  }
 
Pavel Kolchin:

I don't understand anything, but it's very interesting! The compiler swears at several functions, here's one of them, where does it dislike it?

Because there is also

bool              IsAvailable(void)                         const { return(m_is_available);               }


I tried to change it to

   virtual void      Set Available(const bool state)                  { m_is_available=state;                 }
   bool              IsAvailable(void)                         const { return(m_is_available);               }

it's ok )

And the same will have to be done with the others )