WinAPI function to know the Active window (GetActiveWindow doesn't work) ?

 

Hello,


I wonder if it is possible to know which window is the active one, the one that has the top priority for mouse clicks Or get the name or anything specific about the top active window?

I've tested all these functions and more but they usually return 0 :

int      GetWindow(int hWnd,int uCmd);
int      GetWindowTextLengthA(int hWnd);
int      GetWindowTextW(int hWnd,string lpString,int nMaxCount);
int      GetParent(int hWnd);
int      GetActiveWindow();


I found something strange though. The OnChartEvent doesn't work when you right click in the mouse Or when you click on "Draw text label" and the "Label" window appear to create a text label on the chart. But it works fine when there is another window of a different program above MT4  (when the mouse is hovering around the chart). I mean when MT4 window isn't active, it still get OnChartEvent outputs when the mouse coordinates are in on the chart.

I would like to get the top active window in order to stop a function to stop a function from working when MT4 (Chart) isn't in focus or Active.

NOTE: Is there a reference book/article about which WINAPI functions work on MT4 (besides MSDN references which doesn't include Unicode functions).


Thank You very much.

 

Use int GetForegroundWindow()

 
Reason: