How to switch to specific chart?

 
hi there,

there's a post which shows how to cycle trough open chart windows: https://forum.mql4.com/29660#269533
but i want to switch to a specific chart window.
is this possible somehow?
i've tried sending WM_MDIACTIVATE and WM_MDIMAXIMIZE but it doesn't have an effect.
any ideas?

thanks!
 
here's a stupid idea, use that script and break the loop when the WindowHandle is equal with the window in question ...
 
csebastian:
here's a stupid idea, use that script and break the loop when the WindowHandle is equal with the window in question ...


i know how to find the handle but i don't know how to use the handle to switch to the window...
 
here's the script

#import "user32.dll"
   int GetParent(int hWnd);
   int SendMessageA(int hWnd, int Msg, int wParam, int lParam);
#import
#define WM_MDIACTIVATE 546

extern int TargetHWND = 5047712;

void start() {
   int parent = GetParent(TargetHWND);
   int hMDI = GetParent(GetParent(WindowHandle(Symbol(), Period())));
   SendMessageA(hMDI, WM_MDIACTIVATE, parent, 0);
}
obviously you need to change the TargetHWND
 
yeah - it works. thanks!
i didn't know what the SendMessageA() had to look like.
here's my complete script now:
#property show_inputs
#import "user32.dll"
int GetParent(int hWnd);
int SendMessageA(int hWnd, int Msg, int wParam, int lParam);
#import

#define WM_MDIACTIVATE 0x222

extern string symbol = "EURUSD";

int periods[9] = {PERIOD_MN1, PERIOD_W1, PERIOD_D1, PERIOD_H4, PERIOD_H1, PERIOD_M30, PERIOD_M15, PERIOD_M5, PERIOD_M1};

int Window.activate(int hwnd) {
   int p = GetParent(hwnd);
   SendMessageA(GetParent(p), WM_MDIACTIVATE, p, 0);
}

int Window.getHandle(string symbol) {
   int i, hwnd;
   for (i=0; i<ArraySize(periods); i++) {
      hwnd = WindowHandle(symbol, periods[i]);
      if (hwnd != 0) break;
   }
   return (hwnd);
}

void start() {
   int hwnd = Window.getHandle(symbol);
   Window.activate(hwnd);
}

Reason: