Download MetaTrader 5

Get text from window

To add comments, please log in or register
Vitalya Antonov
1378
Vitalya Antonov  

Hi all!

There is code of script which get the name of chart window in MetaTrader 4 terminal (e.g. "EURUSD,M1"):

#import "user32.dll"
   int GetParent(int hWnd);
   int GetWindow(int hWnd, int uCmd);
   int GetWindowTextA(int hWnd, string str, int nMaxCount);
   int GetWindowTextLengthA(int i);
#import

#define GW_CHILD 0x5

void start()
{
   int MDI_handle = GetParent(GetParent(WindowHandle(Symbol(), Period())));
   
   int Chart_board = GetWindow(MDI_handle, GW_CHILD);
   string s = "                             ";
   int nMaxCount = GetWindowTextLengthA(Chart_board);
   GetWindowTextA(Chart_board, s, nMaxCount + 1);
   Print(s);
}

These script worked with MT4 builds older then 2014 year. But with 2014 year's builds this script doesn't work. It just prints spaces.

Please, help me to get name of chart in MT4 terminal by its handle.

qjol
3243
qjol  

strings in the new build (600 >) are unicode

adapt your code accordingly

Vitalya Antonov
1378
Vitalya Antonov  
qjol:

strings in the new build (600 >) are unicode

adapt your code accordingly


thanks!


so, solution is to use GetWindowTextW and "&" with string

To add comments, please log in or register