RidaSana RidaSana - 29 days ago 6x
C++ Question

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..


BOOL CObjectBoundDetectDlg::OnInitDialog()


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

// IDM_ABOUTBOX must be in the system command range.

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
BOOL bNameValid;
CString strAboutMenu;
bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
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 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 ..


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.