Discussion of article "DoEasy. Controls (Part 31): Scrolling the contents of the ScrollBar control" - page 2

 
leonerd CArray should be implemented separately in an inherited class to sort objects, no?

No. There is a Sort() method in CArrayObj:

//+------------------------------------------------------------------+
//| Search of position of element in a sorted array |
//+------------------------------------------------------------------+
int CArrayObj::Search(const CObject *element) const
  {
   int pos;
//--- check
   if(m_data_total==0 || !CheckPointer(element) || m_sort_mode==-1)
      return(-1);
//--- search
   pos=QuickSearch(element);
   if(m_data[pos].Compare(element,m_sort_mode)==0)
      return(pos);
//--- not found
   return(-1);
  }
//+------------------------------------------------------------------+

Compare() method inside the method, which is what you need to override in inherited classes.

In the CBar class, whose objects are stored in the list where we are looking for the desired bar, the Compare() method is already overridden (as well as in all classes of library objects):

//+------------------------------------------------------------------+
//| Compares CBar objects to each other by the specified property ||
//+------------------------------------------------------------------+
int CBar::Compare(const CObject *node,const int mode=0) const
  {
   const CBar *bar_compared=node;
//--- comparison of integer properties of two bars
   if(mode<BAR_PROP_INTEGER_TOTAL)
     {
      long value_compared=bar_compared.GetProperty((ENUM_BAR_PROP_INTEGER)mode);
      long value_current=this.GetProperty((ENUM_BAR_PROP_INTEGER)mode);
      return(value_current>value_compared ? 1 : value_current<value_compared ? -1 : 0);
     }
//--- comparison of real properties of two bars
   else if(mode<BAR_PROP_DOUBLE_TOTAL+BAR_PROP_INTEGER_TOTAL)
     {
      double value_compared=bar_compared.GetProperty((ENUM_BAR_PROP_DOUBLE)mode);
      double value_current=this.GetProperty((ENUM_BAR_PROP_DOUBLE)mode);
      return(value_current>value_compared ? 1 : value_current<value_compared ? -1 : 0);
     }
//--- comparison of string properties of two bars
   else if(mode<BAR_PROP_DOUBLE_TOTAL+BAR_PROP_INTEGER_TOTAL+BAR_PROP_STRING_TOTAL)
     {
      string value_compared=bar_compared.GetProperty((ENUM_BAR_PROP_STRING)mode);
      string value_current=this.GetProperty((ENUM_BAR_PROP_STRING)mode);
      return(value_current>value_compared ? 1 : value_current<value_compared ? -1 : 0);
     }
   return 0;
  }
//+------------------------------------------------------------------+

The structure of object search in the library is organised correctly.

What do you fail? Maybe it is simply because you have not started studying the library from the beginning?

 
Artyom Trishkin #:


What's not working? Maybe it's because you didn't start with the library from the beginning?

Hello. I'm not complaining, of course I haven't read all your articles. I doubt there were any. But simple things don't work and it's not even described how they should work.

Here you have standard graphic elements. By the way, there are not even examples for many basic elements (Edit in this case).

So, CreateEditField() doesn't work. It crashes in the CreateNewStdGraphObjectAndGetCtrlObj() method. Here:

CChartObjectsControl *ctrl=this.GetChartObjectCtrlObj(chart_id);
                        if(ctrl==NULL)
                           ::Print(DFUN,CMessage::Text(MSG_GRAPH_ELM_COLLECTION_ERR_FAILED_GET_CTRL_OBJ),(string)chart_id);
CChartObjectsControl *CGraphElementsCollection::GetChartObjectCtrlObj(const long chart_id)
  {
//--- In a loop through the total number of objects in the list
   for(int i=0;i<this.m_list_charts_control.Total();i++)
     {
      //--- Get a pointer to the next object
      CChartObjectsControl *obj=this.m_list_charts_control.At(i);
      //--- If the pointer could not be obtained - go to the next one
      if(obj==NULL)
         continue;
      //--- If the object chart identifier is equal to the searched one - return the pointer to the object in the list
      if(obj.ChartID()==chart_id)
         return obj;
     }
//--- Did not find the object - return NULL
   return NULL;
  }

Well, m_list_charts_control is empty... accordingly, nothing is added and the method returns nothing.

In general, there are enough errors. I have a feeling that nobody uses the library in practice. Take a tool with the only allowed type of filling IOC. Well, it won't work. It doesn't define it correctly. I had to edit a lot of methods.... You just go through your trading method. Moreover, the initial method in the initialisation corrects the filling, but the trading method does not pick it up.

CTrading::OpenPosition() method

this.m_request.type_filling=(type_filling>WRONG_VALUE ? type_filling : trade_obj.GetTypeFilling());

Ok, we have found the correct type of filling, if it is not explicitly specified in the order.

But then we pass the original variable to the next method. What is the point? Or I don't understand something...

res=trade_obj.OpenPosition(type,this.m_request.volume,this.m_request.sl,this.m_request.tp,magic,comment,deviation,type_filling);
 
leonerd #:

Hello. I'm not complaining, of course I haven't read all your articles. I doubt there were any. But simple things don't work and it's not even described how they should work.

Here you have standard graphic elements. By the way, you don't even have examples for a lot of basic elements (Edit in this case).

So, CreateEditField() doesn't work. It crashes in the CreateNewStdGraphObjectAndGetCtrlObj() method. Here it is:

Well, m_list_charts_control is empty... accordingly, nothing is added and the method returns nothing.

In general, there are enough errors. I have a feeling that nobody uses the library in practice. Take a tool with the only allowed type of filling IOC. Well, it won't work. It doesn't define it correctly. I had to edit a lot of methods.... You just go through your trading method. And the initial method in the initialisation corrects the filling, but the trade method does not pick it up.

CTrading::OpenPosition() method

Ok, we have found the correct type of filling, if it is not explicitly specified in the order.

But then we pass the original variable to the next method. What is the point? Or I don't understand something...

Does this discussion somehow relate to this article? No.
Which article are the questions?
Let's deal with them in its discussion.
PS I don't remember making an input field class for the library. CreateEditField() where did you get it from?
 
Artyom Trishkin #:
Does this discussion have anything to do with this particular article? No.
Which article are the questions about?
Let's deal with them in this discussion.
PS I don't remember making an input field class for the library. CreateEditField() where did you get it from?

CreateEditField() in Engine.mqh

 
leonerd #:

CreateEditField() in Engine.mqh

I can't look at it from my phone)
I'll answer you later when I see the code.
 
leonerd #:
Well, CreateEditField() does not work. It crashes in the CreateNewStdGraphObjectAndGetCtrlObj() method.

Why are you meddling in private methods? They are needed only for the library to work.

The user needs public methods. The end user does not need the work of internal methods.

If you want to understand the work of all this, then articles describing all this kitchen are written for this purpose. It is not very clear what and how you want to do. You don't say, you don't give examples, you just point to a line taken from a huge number of them and say that it doesn't work....

leonerd #:
In general, there are enough joints. I have a feeling that nobody uses the library in practice.

If you don't read the description and try to modify and use internal methods for yourself, then it's not the author who has enough bugs, but the one who modifies it.

And, yes, the library is still under development.

I'll take a look at the fill type, thanks.

But it's better to discuss it in the discussion of the corresponding articles - so that you can see the description at once, instead of talking about one thing in the discussion of something else.

 
А зачем Вы в приватные методы лезете? Они нужны только для работы библиотеки.
I have no desire to go in there. If everything was working, I wouldn't even open it.
 
leonerd #:
I have no desire to go in there. If everything was working, I wouldn't even open it.

What's not working? The code, please. Just saying it doesn't work isn't productive.

 
Artyom Trishkin #:

What's not working for you? The code, please. Just saying it doesn't work is not productive.

I agree that it is not productive. That's why I provided maximum details in this comment https://www.mql5.com/ru/forum/438481/page2#comment_53551638.

Обсуждение статьи "DoEasy. Элементы управления (Часть 31): Прокрутка содержимого элемента управления "ScrollBar""
Обсуждение статьи "DoEasy. Элементы управления (Часть 31): Прокрутка содержимого элемента управления "ScrollBar""
  • 2023.06.19
  • Artyom Trishkin
  • www.mql5.com
Опубликована статья DoEasy. Элементы управления (Часть 31): Прокрутка содержимого элемента управления "ScrollBar" : Автор: Artyom Trishkin...
 
leonerd #:
I provided maximum details in this comment.

Maximum detail is code that you can compile, run, see what doesn't work and find and report the cause.

Without tests, articles are not published. Everything works in tests. That's why I'm asking for the third time: what are you doing and what doesn't work there. The code, please.