cannot open #include

 

I am testing MessageBox function in MT4 using a demo account.

To use MessageBox, I understand we need to include WinUser32.mgh file in a program (EA).

The following program(EA) is from the MT4 Book.


#include <WinUser32.mgh> // needed for messagebox function
extern double Time_News=07.05; // time of impt news
bool Question=false; // Flag (question is not put yet)

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() // special fn start
{
PlaySound("tick.wav"); // at each tick
double Time_cur=Hour()+Minute()/100.0; // current time (double)
if (OrdersTotal>0 && Question==false && Time_cur<=Time_News-0.05) // conditions
{
PlaySound("news.wav"); // at new tick
Question=true; // flag (question already included)
int ret=MessageBox("Time of important news release. Close all orders ?","Question",MB_YESNO | MB_ICONQUESTION | MB_TOPMOST);
//----------------------------------------------------------+
if (ret==IDYES) // if answer is yes
CloseOrders(); // close all orders
}
return; // exit
}
//+------------------------------------------------------------------+

void Close_Orders() // user-defined fn
{
Alert("function of closing all orders being executed");
return;

}

When I compile the EA, I get an error message:

'WinUser32.mgh' - cannot open the program file C:\Program Files\MetaTrader - Alpari UK\experts\create.mq4 (9, 1)

Same error message is given when I compile EA with MT4 of another broker.

Can anyone very kindly enlighten ?

Thank you

 

it is mqh not mgh


  #####
##   ##
##   ##            NOT     g
  #####
     ##
     ##

You need a bigger screen / larger font size.
 
7bit:

it is m q h not mgh




BINGO !

You are right. The file extension should be .mqh not .mgh Many many thanks.

For those interested, I attach the corrected program (EA), successfully compiled with no errors, below.


#include <WinUser32.mqh> // needed for messagebox function
extern double Time_News=18.56; // time of impt news
bool Question=false; // Flag (question is not put yet)

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start() // special fn start
{
PlaySound("tick.wav"); // at each tick
double Time_cur=Hour()+Minute()/100.0; // current time (double)
if (OrdersTotal()>0 && Question==false && Time_cur<=Time_News-0.05) // conditions
{
PlaySound("news.wav"); // at new tick
Question=true; // flag (question already included)
int ret=MessageBox("Time of important news release. Close all orders ?","Question",MB_YESNO | MB_ICONQUESTION | MB_TOPMOST);
//----------------------------------------------------------
if (ret==IDYES) // if answer is yes
Close_Orders(); // close all orders
}
return; // exit
}
//+------------------------------------------------------------------+
void Close_Orders() // user-defined fn
{
Alert("function of closing all orders being executed");
return;
}