Standard Library

 

I have created subclass "CMyAppDialog" as following, so I can manage instances.

//+------------------------------------------------------------------+
//|                                                  MyAppDialog.mqh |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#include <Controls\Dialog.mqh>
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class CMyAppDialog : public CAppDialog
  {
public:
                     CMyAppDialog(void) {}
                    ~CMyAppDialog(void) {}
   //---
   static string     m_instance_id;
   //---
   bool              IsMaximized(void        const { return(!m_minimized);  }
protected:
   virtual string    CreateInstanceId(void)        { return(m_instance_id); }
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string CMyAppDialog::m_instance_id="90562";
//+------------------------------------------------------------------+

The method "CreateInstanceId()" in parent class is protected but it is not defined as virtual, so only  overloading is possible and not  overriding.

It is needed to override by defining it virtually, since it sets a parent private member.

I would suggest modifying standard library and define "CAppDialog::CreateInstanceId()" as virtual string.

 

Forum on trading, automated trading systems and testing trading strategies

Avoiding MT5 update to modify Include\Trade\ files

Alain Verleyen, 2020.03.11 01:38

By preference order :

1. Never modify the library files directly. But work on a copy, fix the bugs. Of course there are drawbacks in case of good changes or addition made by MQ, you will need to port it to your copy,

2. Take the libraries as a base by copying them (as point 1), but after that maintain them entirely yourself.

3. Add the libraries to the mql5 storage. This way you can control the changes and accept or refuse the ones coming with the new updates. Of course there are drawbacks, but different from point 1, you will need to check on each update.

4. Stop using these buggy libraries, allegedly "standard". It is my preferred solution :-D (I use also solution 3 for some I am still using).

Reason: