October 12th, 2003, 04:33 PM
easy question about MessageBox()
hi gang, this question seems simple but i don't know what is happening.
when i run the following line of code to bring up an error message box:
MessageBox(error_string, _T("Error"), MB_ICONEXCLAMATION | MB_OK);
it works if i do it inside a class derived from CDialog.
however, if i make the same call in a regular function (not inside of a class or anything) i get the following error:
error C2660: 'MessageBoxA' : function does not take 3 parameters
so i thought that maybe CDialog had access to a special version of MessageBox(). so instead of calling simply MessageBox() i called CDialog::MessageBox() in my regular function. i get this error message instead:
error C2352: 'CWnd::MessageBoxA' : illegal call of non-static member function
how do i get around this? thanx -kel
October 12th, 2003, 04:59 PM
Try the global function AfxMessageBox instead of this member function to implement a message box in your application.
October 12th, 2003, 05:42 PM
From your dialog class its calling the MessageBox member of CWnd (that takes 3 parameters). Outside a CWnd (or derived) class the MessageBox refers to the Windows API function that takes 4 parameters.
int MessageBox( HWND hWnd,
October 12th, 2003, 09:45 PM
thanx guys. that worked perfectly. i ended up just adding a hWnd parameter and it worked fine.
Click Here to Expand Forum to Full Width