Discussion of article "Graphical Interfaces X: Text selection in the Multiline Text box (build 13)" - page 5

 
Pavel Kolchin:
@Pavel Kolchin, to prevent arrows from deals from hanging over the panel use the CWndEvents::ResetWindow() method.
 
Anatoli Kazharski:

yes, but there is one problem, when used for a long time an error appears for no reason, deleting the EA subwindow causes the EA to be deleted

img

 
Pavel Kolchin:

yes, but there is one problem, when used for a long time an error appears without any reason, deleting the EA subwindow leads to deleting the EA

In the Defines.mqh file, set the EXPERT_IN_SUBWINDOW parameter to false:

//+------------------------------------------------------------------+
//|Defines.mqh |
//| Copyright 2015, MetaQuotes Software Corp. | |
//|http://www.mql5.com |
//+------------------------------------------------------------------+
//--- Expert in window mode
#define  EXPERT_IN_SUBWINDOW false

//---

For Expert Advisors whose graphical interface is located in the main window of the chart, the value of this parameter should be false.

 
Anatoli Kazharski:

In the Defines.mqh file, set the EXPERT_IN_SUBWINDOW parameter to false:


it is clear, there is a function that works works works works works works (several days) and then takes and fails.


//+------------------------------------------------------------------+
//| Checking and updating the number of the Expert Advisor window |
//+------------------------------------------------------------------+
void CWndEvents::CheckExpertSubwindowNumber(void)
  {
//--- Exit if it is not an expert
   if(PROGRAM_TYPE!=PROGRAM_EXPERT)
      return;
//--- Get the number of sub-windows on the graph
   int subwindows_total=(int)::ChartGetInteger(m_chart_id,CHART_WINDOWS_TOTAL);
//--- Exit if the number of subwindows and the number of indicators have not changed
   if(subwindows_total==m_subwindows_total)
      return;
//--- Save the current number of subwindows
   m_subwindows_total=subwindows_total;
//--- To check if there is an expert subwindow
   bool is_subwindow=false;
//--- Find the subwindow of the expert.
   for(int sw=0; sw<subwindows_total; sw++)
     {
      //--- Stop the loop if there is an expert subwindow
      if(is_subwindow)
         break;
      //--- How many indicators are in this window/subwindow
      int indicators_total=::ChartIndicatorsTotal(m_chart_id,sw);
      //--- Let's go through all the indicators in the window 
      for(int i=0; i<indicators_total; i++)
        {
         //--- Get the short name of the indicator
         string indicator_name=::ChartIndicatorName(m_chart_id,sw,i);
         //--- If this is not an Expert subwindow, go to the next one
         if(indicator_name!=m_subwindow_shortname)
            continue;
         //--- Note that the EA subwindow is
         is_subwindow=true;
         //--- If the subwindow number has changed, then 
         // we need to save the new number in all elements of the main form
         if(sw!=m_subwin)
           {
            //--- Save subwindow number
            m_subwin=sw;
            //--- Let's save it also in all elements of the main form of the interface
            int elements_total=CWndContainer::ElementsTotal(0);
            for(int e=0; e<elements_total; e++)
               m_wnd[0].m_elements[e].SubwindowNumber(m_subwin);
           }
         //---
         break;
        }
     }
//--- If the Expert Advisor subwindow is not found, delete the Expert Advisor
   if(!is_subwindow)
     {
      ::Print(__FUNCTION__," > Deleting an EA subwindow causes the EA to be deleted!");
      //--- Removing the Expert Advisor from the chart
      ::ExpertRemove();
     }
  }
 
Pavel Kolchin:


it's clear, there is a function that works for a few days and then fails.

You are not using the latest version of the library or have made changes to it. There should be this condition at the beginning of this method:

//--- Exit if (1) it is not an EA or (2) the EA GUI is in the main window
   if(PROGRAM_TYPE!=PROGRAM_EXPERT || !EXPERT_IN_SUBWINDOW)
      return;

//---

And you have:

//--- Exit if it is not an expert
   if(PROGRAM_TYPE!=PROGRAM_EXPERT)
      return;
 
Anatoli Kazharski:

You are not using the latest version of the library or have made edits to it. At the beginning of this method there should be this condition:

yes, I think that would be better)

version 10.2, so it has all the menu items I need and mt4 support.

are there any other critical changes since then that may affect the work?

 
Pavel Kolchin:

...

have there been any other critical edits since then that might affect performance?

It's hard to say right off the bat. Something is constantly being added and corrected.
 

It is desirable to add to the form a mechanism for adding objects on the principle of "factory", as in Qt, or something similar and preferably with orientation relative to each other:

- right

- left

- top

- bottom

 
Konstantin:

It is desirable to add to the form a mechanism for adding objects on the principle of "factory", as in Qt, or something similar and preferably with orientation relative to each other:

- right

- left

- top

- bottom

Please describe it in detail. I don't know how it is in Qt.

Now elements can be positioned relative to the form: right, left, top, bottom. Only the form can be a parent element. In the next version it will be possible to set any other element as a parent element. This will make element management and positioning even easier.

 
Anatoli Kazharski:

Describe it in more detail. I don't know how it is in Qt.

Now elements can be positioned relative to the form: right, left, top, bottom. Only the form can be a parent element. In the next version it will be possible to set any other element as a parent element. This will make element management and positioning even easier.


in Qt is a factory function:

QWidgetAction *createWidget();

and this is how the tests for creating widgets are done:

QWidget * widget() {
   static QWidget * inst = new QWidget;
   return inst;
}

and in general about QWidget here is all the information.

Now elements can be positioned relative to the form: right, left, top, bottom.

I don't quite get it here, is this positioning of the element relative to the borders and they can be placed both behind the form and inside the form?

For example, there is a form, we position an element relative to the left border of the form further to the left?