Popup window with already opened chart - page 2

 
Alain Verleyen: It's a method of a CChart object, not an mql function.
Oops! My bad! Sorry!
 

There is the part of my code that I used :

ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true)


It worked fine.

The only issue is if the chart window was "minimized". It will appears just the Title bar menu of the chart window.
Late I will try to find a function to "maximize". 


bool CProgram::ChartChange(const long id)
  {
//--- Check the element ID
   if(id!=m_table_button.Id())
      return(false);

//--- Get a symbol
   string symbol=m_symb_trade.GetValue();
   if(symbol=="")
      symbol=Symbol();
   if(!SymbolInfoInteger(symbol,SYMBOL_EXIST))
      {
       Alert("Check Symbol Name");
       return(false);
      }
      
//--- Searching for opened charts
   string chartid[101];
   long currChart,prevChart=ChartFirst();
   long idchart[101];

   int i=0,limit=100;
   while(i<limit)// We have certainly not more than 100 open charts
     {
      idchart[0]=ChartFirst();
      chartid[0]=ChartSymbol(idchart[0]);
      currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
      if(currChart<0)
         break;          // Have reached the end of the chart list
      idchart[i+1]=currChart;
      chartid[i+1]=ChartSymbol(currChart);
      prevChart=currChart;// let's save the current chart ID for the ChartNext()
      i++;// Do not forget to increase the counter
     }

   bool chartexist=false;
   long chart_handle;
   for(int z=0 ; z<ArraySize(chartid) ; z++)
     {
      if(chartid[z]==symbol)
        {
         chartexist=true;
         chart_handle=z;
         break;
        }
     }
//--- Open a new chart window
   if(!chartexist)
     {
      Print("Opening new chart window");
      if(ChartOpen(symbol,PERIOD_D1)>0)
        {
         //--- Update the arrays after opened a new chart
         while(i<limit)// We have certainly not more than 100 open charts
           {
            idchart[0]=ChartFirst();
            chartid[0]=ChartSymbol(idchart[0]);
            currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
            if(currChart<0)
               break;          // Have reached the end of the chart list
            idchart[i+1]=currChart;
            chartid[i+1]=ChartSymbol(currChart);
            prevChart=currChart;// let's save the current chart ID for the ChartNext()
            i++;// Do not forget to increase the counter
           }
        }
      chartexist=false;
      chart_handle;
      for(int z=0 ; z<ArraySize(chartid) ; z++)
         {
          if(chartid[z]==symbol)
            {
             chartexist=true;
             chart_handle=z;
             break;
            }
         }   
     }



//--- show the chart on top of all others
   long chart_ID=idchart[chart_handle];
   if(!ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true))
      {
//--- display the error message in Experts journal
       Print(__FUNCTION__+", Error Code = ",GetLastError());
       return(false);
       ResetLastError();
      }


   return(true);
  }



//+------------------------------------------------------------------+
 
Alain Verleyen:

Except there is no WindowHandle on mql5.

Need to use :

And I doubt the rest of the code will work on MT5, but I didn't try.

Yeas, you're correct, that was from MQL4. Sorry, I forget which one is being discussed at times.