Set event handler callback for MetaTrader 5
Posted: Wed Mar 21, 2018 4:38 pm
Hello all,
I need a working example for the SET_EVENT_HANDLER function in MT5:
The given example:
works only for C# or the likes, i guess.
In MT5 I can't convert the address of my event handler function to the 64-bit int required by the DLL function.
I've tried this:
but I get the compilation error:
Since the SET_EVENT_HANDLER wants "a 64 Bit-Pointer to address of callback function".
If I use this:
I get:
Any idea?
I need a working example for the SET_EVENT_HANDLER function in MT5:
Code: Select all
$TRADE_COMMANDER_HOME/twslink2/Documentation/html/fct_SET_EVENT_HANDLER.html
Code: Select all
ret = SET_EVENT_HANDLER(ProcessTWSEvents,17,0)
In MT5 I can't convert the address of my event handler function to the 64-bit int required by the DLL function.
I've tried this:
Code: Select all
...
typedef void (*TFunc)(int,int,int,int,double,double,double,double,string,string,string,string,double,double,int,int);
...
void ibEventHandler(
int integer1, // carries always main category of event
int integer2, // can have specific meaning, in particular when integer1=2
int integer3, // carries any value
int integer4, // carries any value
double double1, // carries any value
double double2, // carries any value
double double3, // carries any value
double double4, // carries any value
string string1, // carries any value
string string2, // carries any value
string string3, // carries any value
string string4, // carries any value
double double5, // carries any value
double double6, // carries any value
int integer5, // carries any value
int integer6 // carries any value
){
// TODO
return;
}
int OnInit() {
...
TFunc func_ptr = ibEventHandler;
res = SET_EVENT_HANDLER( func_ptr, 0, 0 );
...
}
Code: Select all
'func_ptr' - parameter conversion not allowed
If I use this:
Code: Select all
res = SET_EVENT_HANDLER( (int) func_ptr, 0, 0 );
Code: Select all
'(int)' - invalid cast operation