Download MetaTrader 5

How to use Window Messaging from a DLL?

To add comments, please log in or register
Develop trading robots to order. Make profit with Freelance service!
RMACD
13
RMACD 2012.09.22 20:17 

I want to trigger the chart (window) from a DLL (DLL starts separate thread with  WinAPI CreateThread).

In MT4, I simply trigger the EA resp. Indi. with a tick sent with message  "MT4 Internal Message".  For this, I need the

Window Handle HWND. I obtain the Handle  with MT4-Function WindowHandle(Symbol, timeframe). This is a "real" Window

Handle. It can be used with the Windows API and addresses exactly the MDI-Window of the Chart.


How can I do the same things in MT5/MQL5? If it is not implemented, how can it be patched?

Furthermore, I am not sure that MT5 ChartGetInteger ./.Chart_Window_Handle delivers the "right" HWND of the window.

I fear  this HWND is rather an "Internal MT5 Handle". (therefore useless for WinAPI).

Thanks!

onewithzachy
2271
onewithzachy 2012.09.23 01:37  
RMACD:

I want to trigger the chart (window) from a DLL (DLL starts separate thread with  WinAPI CreateThread).

In MT4, I simply trigger the EA resp. Indi. with a tick sent with message  "MT4 Internal Message".  For this, I need the

Window Handle HWND. I obtain the Handle  with MT4-Function WindowHandle(Symbol, timeframe). This is a "real" Window

Handle. It can be used with the Windows API and addresses exactly the MDI-Window of the Chart.


How can I do the same things in MT5/MQL5? If it is not implemented, how can it be patched?

Furthermore, I am not sure that MT5 ChartGetInteger ./.Chart_Window_Handle delivers the "right" HWND of the window.

I fear  this HWND is rather an "Internal MT5 Handle". (therefore useless for WinAPI).

Thanks!

Hi RCMAD,

I check the parents of ChartGetInteger' CHART_WINDOW_HANDLE  and use WinAPI CloseWindow to close the chart - works for me.

I haven't further check with other Win API though :).

BTW, what do you want to create that needed chart handle so bad ? 

 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Chart Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Chart Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Chart Constants / Chart Properties - Documentation on MQL5
RMACD
13
RMACD 2012.09.23 10:42  
onewithzachy:

Hi RCMAD,

I check the parents of ChartGetInteger' CHART_WINDOW_HANDLE  and use WinAPI CloseWindow to close the chart - works for me.

I haven't further check with other Win API though :).

BTW, what do you want to create that needed chart handle so bad ? 

 

I have to blame myself.... I'm so sorry.

Yes, HWND definitely works, with GetParent and SetWindowText I could change the title of the window. Even the

SendMessage stuff works , both with user32dll and my testdll.

Why I want the chart handle so bad? e.g. now I can write a timer with arbitrarily short intervals ,e.g. 100 milliseconds, and send

timer-ticks to different charts. And I can set up my own window and synchronize with an EA. IMHO, the "best control" of Windows/ WinAPI

is the TreeView-Control. This is not implemented in MQL5.


onewithzachy
2271
onewithzachy 2012.09.23 12:17  
RMACD:

I have to blame myself.... I'm so sorry.

Yes, HWND definitely works, with GetParent and SetWindowText I could change the title of the window. Even the

SendMessage stuff works , both with user32dll and my testdll.

Why I want the chart handle so bad? e.g. now I can write a timer with arbitrarily short intervals ,e.g. 100 milliseconds, and send

timer-ticks to different charts. And I can set up my own window and synchronize with an EA. IMHO, the "best control" of Windows/ WinAPI

is the TreeView-Control. This is not implemented in MQL5. 

Hi RCMAD,

Just an idea, if it is EA or script and not CI, why not using while loop ?. AFAIK it not really burden the processor.

while(!IsStopped())
  {
  // here the main code

  
  int slept = 100;
  // here we can vary the slept value
  Sleep (slept);
  }

Then again that is your idea and your code , and not mine, so you can mind mine if you disagree :)


To add comments, please log in or register