Programming a window with two buttons

 

Hi,

 

I am looking for a function in a script that opens a window with some information (that I pass as a string) and has to buttons to select "OK" and "Cancel". If "Cancle" is chosen, I would like to exit the script. 

 

Thank you.

 

Best,

Chris 

 
zubr:

Hi,

 

I am looking for a function in a script that opens a window with some information (that I pass as a string) and has to buttons to select "OK" and "Cancel". If "Cancle" is chosen, I would like to exit the script. 

 

Thank you.

 

Best,

Chris 

MessageBox function.
Documentation on MQL5: Common Functions / MessageBox
Documentation on MQL5: Common Functions / MessageBox
  • www.mql5.com
Common Functions / MessageBox - Documentation on MQL5
 
angevoyageur:
MessageBox function.

OK, that's what I was looking for. If "Cancle" is clicked, I would like to immediately exit the script. Is there a function for that?

 
zubr:

OK, that's what I was looking for. If "Cancle" is clicked, I would like to immediately exit the script. Is there a function for that?

You only have to check the returned code and use the return statement from OnStart() function, something like :

   void OnStart()
     {
      ...
      int result= MessageBox("Message...",...);
      if(result == IDCANCEL) return;
      ...
     }
 
angevoyageur:

You only have to check the returned code and use the return statement from OnStart() function, something like :

This would be one feasable solution if I would invoke the function with MessageBox within OnStart(). However, I invoke MessageBox deeply embedded in my code, like OnStart()=>FunctionA()=>FunctionB()=>MessageBox(). So I had to pass the return code from MessageBox to FunctionA an from FunctionA to OnStart().

 What I am looking for is a function that immediately exits the script where I don't need to "jump back" to OnStart(). Is there such a function? 

 
zubr:

This would be one feasable solution if I would invoke the function with MessageBox within OnStart(). However, I invoke MessageBox deeply embedded in my code, like OnStart()=>FunctionA()=>FunctionB()=>MessageBox(). So I had to pass the return code from MessageBox to FunctionA an from FunctionA to OnStart().

 What I am looking for is a function that immediately exits the script where I don't need to "jump back" to OnStart(). Is there such a function? 

What do you mean using term "script"? See difference between "script" and "expert advisor" https://www.mql5.com/en/docs/runtime

Try ExpertRemove

Documentation on MQL5: MQL5 programs
Documentation on MQL5: MQL5 programs
  • www.mql5.com
MQL5 programs - Documentation on MQL5
 
stringo:

What do you mean using term "script"? See difference between "script" and "expert advisor" https://www.mql5.com/en/docs/runtime

Try ExpertRemo

stringo:

What do you mean using term "script"? See difference between "script" and "expert advisor" https://www.mql5.com/en/docs/runtime

Try ExpertRemove

I am programming a script to set an order. So this is not an EA. While placing the order I want to exit the script when some comditions are not met.