Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MessageBox error (hard one) 1

Status
Not open for further replies.

Arowana

Programmer
Feb 22, 2001
19
PT
Hi,

In my code i have:

...
if(flag==1)
MessageBox(NULL,"Message1","Message2",MB_OK);
else
MessageBox(NULL,"Message3,"Message4,MB_OK);
...

but when i compile i get the error C2660 MessageBOx to not accept 4 arguments.

in other parts of the code i have the same syntax and i do not get the error.

Please help

Thanks
 
I think I know what your problem is.
When you call 'MessageBox' function from a class which is derived from the class 'CWnd' the function only get 3 parameters (it is the MFC MessageBox Function). If you still want to call the API function you should add '::' before the function.

...
if(flag==1)
::MessageBox(NULL,"Message1","Message2",MB_OK);
else
::MessageBox(NULL,"Message3,"Message4,MB_OK);
...

Goodluck...

Ido Grinblat
CET
Shifat
Tel: 972-3-6460144
972-3-6460138
Fax: 972-3-6460009
 
Hi

If your are using MFC, you should consider the function AfxMessageBox().
Otherwise, use MessageBox as this:

MessageBox( "Test1", "Test2", MB_OK);

If the AfxMessageBox does not fit your needs, the Ido's solution is better as you express the global namespace with the ::, which is, HMHO, better.

Thierry
Thierry.Marneffe@swing.be
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top