How to bring to front one chart by code?

 

if there is 3 charts, I want let expert   bring one chart(for example D1) to front by code? how to do?

thanks

 
codeidea posted  :

if there is 3 charts, I want let expert   bring one chart(for example D1) to front by code? how to do?

thanks

 

who can help me ?
 
codeidea posted  :

if there is 3 charts, I want let expert   bring one chart(for example D1) to front by code? how to do?

thanks

 

Here is the script that brings EURUSD Daily chart to front:

//+------------------------------------------------------------------+
//|                                                  BringWindow.mq5 |
//|                        Copyright 2010, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2010, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#import "user32.dll"
int SendMessageW(int hWnd,int Msg,int wParam,int lParam);
int GetParent(int hWnd);
#import

//#property script_show_inputs
//--- input parameters
input string          InpSymbol="EURUSD";
input ENUM_TIMEFRAMES InpPeriod=PERIOD_D1;

#define WM_MDIACTIVATE  0x222
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   long chart_id=ChartFirst();
   while(chart_id>=0)
     {
      if(ChartSymbol(chart_id)==InpSymbol && ChartPeriod(chart_id)==InpPeriod)
         break;
      chart_id=ChartNext(chart_id);
     }
   if(chart_id<0)
     {
      Print("Chart not found");
      return;
     }
   int handle=(int)ChartGetInteger(chart_id,CHART_WINDOW_HANDLE);
   handle=GetParent(handle);

   int WinParent=GetParent(handle);
   SendMessageW(WinParent,WM_MDIACTIVATE,handle,0);
  }
//+------------------------------------------------------------------
Reason: