RidaSana
RidaSana

Reputation: 563

some problem with AfxMessageBox() MFC function

I am making a program for loading a picture from camera using Open.Cv ..

And i am getting error in AfxMessageBox() statement..

program:

BOOL CObjectBoundDetectDlg::OnInitDialog()

{ 
CDialogEx::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
    BOOL bNameValid;
    CString strAboutMenu;
    bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
    ASSERT(bNameValid);
    if (!strAboutMenu.IsEmpty())
    {
        pSysMenu->AppendMenu(MF_SEPARATOR);
        pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
    }
}

int nSelected = cvcamGetCamerasCount();
if(nSelected == 0)
{       
    AfxMessageBox("Camera have no connection",MB_OK|MB_ICONSTOP);
    return FALSE;
}

}

error:

Error 2 error C2665: 'AfxMessageBox' : none of the 2 overloads could convert all the argument types c:\program files\microsoft visual studio 10.0\my project\objectbounddetect\objectbounddetect\objectbounddetectdlg.cpp 126 1 ObjectBoundDetect

if i look on the defination of AfxMessageBox() ... provided in this [link]](http://msdn.microsoft.com/en-us/library/as6se7cb(v=vs.80).aspx) ... it should work.. but i think some problem in parameter list .. that i am not understanding...

According to the defination.. AfxMessageBox() statement should not make me error ...

Any one can help me with this problem .. Expoecting a good response thanks ..

Note: Camera is already Attached,.. no problem with camera ..

Upvotes: 0

Views: 14844

Answers (3)

S G
S G

Reputation: 802

Use as below:

AfxMessageBox(_T("YOUR MESSAGE"));

Upvotes: 1

Programmer
Programmer

Reputation: 439

AfxMessageBox( L"Camera have no connection",MB_OK|MB_ICONSTOP);

The above code worked without any issue. If you still want to go with:

AfxMessageBox("Camera have no connection",MB_OK|MB_ICONSTOP);

You can go to Project properties, in general tab you can change Character set from "Use Unicode Character Set" to "Use Multi-Byte Character Set"

Upvotes: 1

DevSolo
DevSolo

Reputation: 697

Two possibilities:

You may, although I doubt this, have to scope it globally. To do that, try

::AfxMessageBox("Camera have no connection",MB_OK|MB_ICONSTOP);

The other is that use are building for unicode and it thinks the string is multi-byte. To do that, try

AfxMessageBox( L"Camera have no connection",MB_OK|MB_ICONSTOP);

I'm out of town, on my Mac, so I can't test this. But I have been stuck in the office on weekends so I figured I'd offer up two things to try.

Upvotes: 6

Related Questions