Download MetaTrader 5
To add comments, please log in or register
No time to learn MQL5? Order your application from a developer!
maindoor
120
maindoor 2014.10.28 10:48 

There is this code to programmatically a chart

https://forum.mql4.com/24948#194891

But a call like this:

 ChartWindow("EURUSD");
 ChartWindow("GBPJPY");
 ChartWindow("AUDUSD");

only works for the first symbol, the second and third window don't open,

why is this so ?

I modified the code to take variable window handles still doesn't work:

int hWndcount = 0;
int ChartWindow(string SymbolName)
{
   int hFile, SymbolsTotal, hTerminal;
   int hWnd[30];

   hFile = FileOpenHistory("symbols.sel", FILE_BIN|FILE_READ);
   if(hFile < 0) return(-1);

   SymbolsTotal = (FileSize(hFile) - 4) / 128;
   FileSeek(hFile, 4, SEEK_SET);

   hTerminal = GetAncestor(WindowHandle(Symbol(), Period()), 2);

   hWnd[hWndcount] = GetDlgItem(hTerminal, 0xE81C);
   hWnd[hWndcount] = GetDlgItem(hWnd[hWndcount], 0x50);
   hWnd[hWndcount] = GetDlgItem(hWnd[hWndcount], 0x8A71);

   PostMessageA(hWnd[hWndcount], WM_KEYDOWN, VK_HOME, 0);

   for(int i = 0; i < SymbolsTotal; i++)
   {
      if(FileReadString(hFile, 12) == SymbolName)
      {
         PostMessageA(hTerminal, WM_COMMAND, 33160, 0);
         return(0);
      }
      PostMessageA(hWnd[hWndcount], WM_KEYDOWN, VK_DOWN, 0);
      FileSeek(hFile, 116, SEEK_CUR);
   }
   hWndcount++;
   FileClose(hFile);

   return(-1);
}
Alain Verleyen
Moderator
28537
Alain Verleyen 2014.10.28 11:01  
You don't need all this hack any more, use ChartOpen()
maindoor
120
maindoor 2014.10.28 11:24  
Awesome, thank you.
whroeder1
13602
whroeder1 2014.10.28 16:56  
angevoyageur: You don't need all this hack any more, use ChartOpen()
Alphabetic Index of MQL4 Functions (600+) - MQL4 forum
/
To add comments, please log in or register