Add custom indicator to subwindow from EA - page 2

 
Kun Li:
#import "user32.dll"
  int RegisterWindowMessageW(string MessageName);
  int PostMessageW(int hwnd, int msg, int wparam, char &Name[]);
#import

void callIndic(){
   string name = "ATR";
   char name2[256];
   StringToCharArray(name , name2);
   
   int hWnd = WindowHandle(Symbol(), Period());
   int MessageNumber = RegisterWindowMessageW("MetaTrader4_Internal_Message");
   int r = PostMessageW(hWnd, MessageNumber, 15, name2);

}



Does not work at all.

 
Andre Tavares:

Does not work at all.

Please look at this topic here,  it might help you.

 
MadMik:

Thanks for the help.

Works now BUT ....

had to put the    keybd_event(13, 0, 0, 0);    before the SendMessageW(hWnd, MessageNumber, 15, name2)

otherwise it did not work ... instead it left dialog open and then opened the pair input box at base of chart.


MM


I tried your method without any success. I'm trying to place an indicator from within a script. I can't use PostMessageW either because it crashes my MT4 terminal. But there's no way to close the indicator config dialog box if I use SendMessageW to place the indicator. I think this is because, according to the Windows MDSN documentation, " The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message." This means that it won't allow a keyboard event to be handled until the dialog box is removed.

Is there any way to close the config dialog box which is compatible with the lastest build of MT4? Is there an alternative to using PostMessageW and SendMessageW?

Reason: