Dialog.mqh - Bug

 

There has been numerous forum topics over the years regarding panels created using CAppDialog being minimised when the user switches to another chart.

Having intermittently encountered the issue I have discovered the reason as follows:

Dialog.mqh chart events processing there is a function that checks if the panel is greater in height than the window height in pixels, if true it will automatically minimise the panel upon event CHART_EVENT_CHANGE

The problem is this happens with panels that are smaller than the window height and are already maximised and being used on the chart with plenty of space.

To make the check the function calls   m_chart.HeightInPixels(m_subwin)  located in the Chart.mqh  this returns the height of chart in pixels, BUT it is wrong no matter what the chart heigh, it is returning the value 752  so if the panel is greater in height than 752 it gets minimised.

I am unable to establish where it gets the 752 from even with all my charts docked and at the same size it still returns 752 which suggests the function that it uses ChartGetInteger(m_chart_id,CHART_HEIGHT_IN_PIXELS,num))  does not work correctly at the time of switching chart

I have checked that the chart id being sent is 0 and the subwindow is 0  I have tried overiding the chart id to the value returned from ChartID() but the result is the same always 752 returned no matter the size of the chart window

code snippets shown, can we get MQ developers to look at this?

From Dialog.mqh  void CAppDialog::ChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)

   if(id==CHARTEVENT_CHART_CHANGE)
     {
      //--- if subwindow number is not 0, and dialog subwindow has changed its number, then restart
      if(m_subwin!=0 && m_subwin!=ChartWindowFind())
        {
         long fiction=1;
         OnAnotherApplicationClose(fiction,dparam,sparam);
        }
      //--- if subwindow height is less that dialog height, minimize application window (always)
      if(m_chart.HeightInPixels(m_subwin)<Height()+CONTROLS_BORDER_WIDTH)
        {
         m_button_minmax.Pressed(true);
         Minimize();
         m_chart.Redraw();
        }
      //--- if chart width is less that dialog width, and subwindow number is not 0, try to modify dialog width
      if(m_chart.WidthInPixels()!=Width() && m_subwin!=0)
        {
         Width(m_chart.WidthInPixels());
         m_chart.Redraw();
        }
from  Chart.mqh

//+------------------------------------------------------------------+
//| Get value of the "HeightInPixels" property                       |
//+------------------------------------------------------------------+
int CChart::HeightInPixels(const int num) const
  {
//--- check
   if(m_chart_id==-1)
      return(0);
//--- result
   return((int)ChartGetInteger(m_chart_id,CHART_HEIGHT_IN_PIXELS,num));
  }

   

Documentation on MQL5: Standard Library / Panels and Dialogs / CAppDialog
Documentation on MQL5: Standard Library / Panels and Dialogs / CAppDialog
  • www.mql5.com
CAppDialog - Panels and Dialogs - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

I use this to disable automatic minimization on chart change:

void OnChartEvent(const int id,         // event ID
                  const long& lparam,   // event parameter of the long type
                  const double& dparam, // event parameter of the double type
                  const string& sparam) // event parameter of the string type
  {
//--- disable automatic minimization on chart change.
   if(id==CHARTEVENT_CHART_CHANGE)
      if(ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)<ExtDialog.Height())
         return;

   ExtDialog.ChartEvent(id,lparam,dparam,sparam);
  }