Window Handles

 
Hi there,

The WindowHandle function is defined as...

>int WindowHandle( string symbol, int timeframe)
>Returns the system window handler containing the given chart. If the chart of symbol and timeframe has not been >opened by the moment of function calling, 0 will be returned.

What happens though if you have more than one window open with of the same chart and timeframe? i.e. If you have say two GBPUSD,M1 chart windows open which window handle does WindowHandle return?

How can one use WindowHandle to get the window handles of chart windows that share the same symbol and timeframe?

Also, is there any way to programatically iterate through the MAIN chart windows open in the terminal to determine each main windows handle?

Regards,

Laurence.
 
No, sorry. You cannot programmatically iterate windows with the same symbols-periods. With Windows API only
 
No, sorry. You cannot programmatically iterate windows with the same symbols-periods. With Windows API only


Hi Slawa, thanks for the reply.

Any answer tthe other two questions in my original post, which were....

What happens though if you have more than one window open with of the same chart and timeframe? i.e. If you have say two GBPUSD,M1 chart windows open which window handle does WindowHandle return?

How can one use WindowHandle to get the window handles of chart windows that share the same symbol and timeframe?

Regards,

Laurence.
 
"What happens though if you have more than one window open with of the same chart and timeframe? i.e. If you have say two GBPUSD,M1 chart windows open which window handle does WindowHandle return?"


"How can one use WindowHandle to get the window handles of chart windows that share the same symbol and timeframe?"


Have you tried it?


I don't seem to have a problem getting the handle of the window on which the query is run. Attach an "update" script to the window you want updated, is my solution.
 
Hello phy,

Yes I have tried it.

If you have more than one chart open with the same symbol and timeframe then WindowHandle seems to return the handle of the most recently activated/viewed chart.

As an aside, within a script/expert/indicator how would one get the handle of the window that the script/expert/indicator is running in? i.e. somthing like a CurrentWindowHandle() function?

You mentioned using an "update" script. I presume that is a script that runs on a chart and force the chart to refresh itself periodically. Do you have some sample code of such a script?

Regards,

Laurence.

[/quote]
 
1-2. I just use WindowHandle to get the handle of the window where the code is running.

3. "Period Converter Optimized" has update code.
 
Hi, i've observed that the function int WindowHandle( string symbol, int timeframe) is of no use in MQL4, may be that MQL5 will extend its use.
At the time, a call to int WindowHandle( string symbol, int timeframe) returns an int referencing the window by(system ?) integer. Anyway you don't need it, as any expert have a default value '0' to target the chart window he's running in.
Remember, main window (chart) as default value '0', even if you get an other reference to it, calling WindowHandle( Symbol(),0); the returned value is more than zero, and refers to a subwindow, attached to what, only MQL conceptor knows !
If you try to create an object in the EA chart window, using the return value of WindowHandle( Symbol(),0); you're wrong, it always raise en error. If you try the same using '0' as window integer reference instead of WindowHandle( Symbol(),0) value, you get what you want : your object is drawn on chart.
Thus, before any change in MQL implements, you can't target an other chart window than the one the EA is running in to draw an object.
Saddly Funny....!
 
"Hi, i've observed that the function int WindowHandle( string symbol, int timeframe) is of no use in MQL4 blah blah blah"

Incorrect. You are misuing the information.

It is useful in PostMessageA(hwnd,WM_COMMAND,CHART_CMD_UPDATE_DATA,1)

where hwnd is the WindowHandle
 
"Hi, i've observed that the function int WindowHandle( string symbol, int timeframe) is of no use in MQL4 blah blah blah"

Incorrect. You are misuing the information.

It is useful in PostMessageA(hwnd,WM_COMMAND,CHART_CMD_UPDATE_DATA,1)

where hwnd is the WindowHandle



No Bla bla bla Phy, we are not in Academic course. Obviously you talk cause your mouth is open.
So check this, tell me if you can dram an object in the EA chart window, targeting the window reference with the return value of this function ?
Chikken Jay You ARE !

PS : Forgotten, i should be more polite, as you should too ! Anyway, in orther to wipe any doubt, if you're EA is posting message in its own chart window, hwnd=0 is the simplest code. You should be aware, expert coder you claim to be, that int WindowHandle(blah,blah) does'nt return '0' targeting the main window, even when you check it inside the EA code running in this window chart.
No other answer usefull than the adverse proof.
I'll stay around to get this proof from you, May Be You Can !
Next time, think before you talk Blah blah blah Guy

Sincerely

The guy your mother told you should not meet... :)
 
As you wish.

Enjoy your anger.
Reason: