massage box not working

 

my massagebox() code is not working???

//EXPERT INIT SPECIAL FUNCTION
int init()
{
   //local variable
   bool oc;
   oc = ObjectCreate("buy here now",OBJ_TEXT,0,D'2009.12.10',Ask);
   ObjectSetText("buy here now","buy here now",12,"Times New Roman",Green);
   Alert("object created = ",oc);
   int y;
   Alert("market distance = ",MarketInfo(Symbol(),MODE_STOPLEVEL));
   Alert("market freezelevel = ",MarketInfo(Symbol(),MODE_FREEZELEVEL));
   if(ObjectsTotal()>0)
   {
   int mb = MessageBox("Do you want to delete all objects created",MB_YESNO|MB_ICONQUESTION|MB_TOPMOST);
   if(mb==IDYES)
   {
      ObjectsDeleteAll(0);
   }
   }
return(0);
 

When you run this, look in your Experts tab of the Terminal window and you should see the error "title for MessageBox function must be a string".

The function MessageBox() has three parameters, and they all have defaults. If you use fewer parameters, it takes them in the order you give them and the default is used for any remaining without values. You used only two parameters, so it takes them to be the text (string) and caption/title (string), which is the problem. If you want to specify the flags you must use all three parameters.


Hope this helps.

Jellybean


P.S. I had a little chuckle over the title of your question ;-)

 
Jellybean wrote >>

When you run this, look in your Experts tab of the Terminal window and you should see the error "title for MessageBox function must be a string".

The function MessageBox() has three parameters, and they all have defaults. If you use fewer parameters, it takes them in the order you give them and the default is used for any remaining without values. You used only two parameters, so it takes them to be the text (string) and caption/title (string), which is the problem. If you want to specify the flags you must use all three parameters.

Hope this helps.

Jellybean

P.S. I had a little chuckle over the title of your question ;-)

thanks. i see it now. lol and i see what you are talking about the title. oops

Reason: