easy question about MessageBox()
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: easy question about MessageBox()

  1. #1
    Join Date
    Oct 2003

    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

  2. #2
    Join Date
    Nov 2002
    Try the global function AfxMessageBox instead of this member function to implement a message box in your application.

  3. #3
    Join Date
    May 2000
    Scotland, Livingston.
    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,
    LPCTSTR lpText,
    LPCTSTR lpCaption,
    UINT uType
    Dave Mclelland.

  4. #4
    Join Date
    Oct 2003
    thanx guys. that worked perfectly. i ended up just adding a hWnd parameter and it worked fine.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Azure Activities Information Page

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center