Stack Damaged at winapi call

To add comments, please log in or register
Tusher Ahmed
169
Tusher Ahmed  
#import "user32.dll"
int    MessageBoxW(uint hWnd,string lpText,string lpCaption,uint uType);
#import


////invoking
onCalculate ()
{
  MessageBoxW(NULL,"Message Body","Caption",MB_OK);
............
............
}

message box showing okay. But when i click "ok" /close the box, it stops working .

I guess its due to some parameter types mismatch, but not sure. Tried exact data types, but the issue still not solved.

the error its reporting:

Stack Damaged -> check dll function call in xyz.mq4 (line : xyz,zyx)

Tusher Ahmed
169
Tusher Ahmed  

anyone on this forum ever faced the same issue with MessageBoxW?

If you are  using MessageBoxW successfully, can you please verify my code? what i'm doing wrong?

Demos Stogios
226
Demos Stogios  
I 've put it on a script, but there is nothing wrong with it
Tusher Ahmed
169
Tusher Ahmed  
Demos Stogios:
I 've put it on a script, but there is nothing with it

you meant it worked? or didn't even show the box?

Demos Stogios
226
Demos Stogios  
Tusher Ahmed:

you meant it worked? or didn't even show the box?

heeh sorry, I updated my message before I see your answer - well, it is working ok here

Tusher Ahmed
169
Tusher Ahmed  
Demos Stogios:

heeh sorry, I updated my message before I see your answer - well, it is working ok here

okay, can you please share your code examples,  

1. how are u importing the routines

2. how you are invoking 

Demos Stogios
226
Demos Stogios  
Tusher Ahmed:

okay, can you please share your code examples,  

1. how are u importing the routines

2. how you are invoking 

It is an empty script, with the #import above and the MessageBoxW() inside OnStart() and that 's it. Maybe the error is somewhere else? Is it happening when changing TFs? Of course, it could be a problem In MetaTrader or something
Tusher Ahmed
169
Tusher Ahmed  
Demos Stogios:
It is an empty script, with the #import above and the MessageBoxW() inside OnStart() and that 's it. Maybe the error is somewhere else? Is it happening when changing TFs? Of course, it could be a problem In MetaTrader or something

Hi,

the problem is happening whenever  the  buttons are pressed (OK, CANCEL, CLOSE etc.) for the first times. It no longer pops up the messageboxs.

try this on a live chart :

/// #import first

//then invoke in an indicator's Oncalculate
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
    MessageBoxW(NULL,"a message","caption",NULL);

  }
Demos Stogios
226
Demos Stogios  

I put it there and somewhat it works. I mean,

if the indicator is loaded in the chart when I launch MetaTrader, the log prints "DLL loading is not allowed", but the indicator works ok. If I load the indicator on an empty chart, I do not get that message on the log but no problem as well.

A remark, maybe you are missing the message box, as it opens a new icon in the Windows task bar? It may be in the background I mean. Despite that, I get no problems, but maybe the issue you are having has to do with the fact that indicators are not accepting blocking functions? I am in Windows 10 64 bit fwiw

To add comments, please log in or register