AfxMessageBox() MFC 函数存在一些问题

发布于 2024-11-10 10:59:02 字数 1441 浏览 0 评论 0原文

我正在制作一个使用 Open.Cv 从相机加载图片的程序..

并且我在 AfxMessageBox() 语句中遇到错误..

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错误 C2665: 'AfxMessageBox' : 2 个重载中没有一个可以转换所有参数类型 c:\program files\microsoft Visual Studio 10.0\my project\objectbounddetect\objectbounddetect\objectbounddetectdlg.cpp 126 1 ObjectBoundDetect

如果我查看 AfxMessageBox() 的定义 ... 在此提供 [链接]](http://msdn.microsoft.com/en-us/library/as6se7cb(v=vs.80).aspx) ...它应该可以工作..但我认为参数列表中存在一些问题..我不明白...

根据定义.. AfxMessageBox() 语句不应让我出错...

任何人都可以帮助我解决这个问题..期待一个好的答复,谢谢..

注意: 相机已经附上,..相机没问题..

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

所谓喜欢 2024-11-17 10:59:02

两种可能性:

尽管我对此表示怀疑,但您可能必须将其范围扩展到全球范围。要做到这一点,请尝试

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

另一个是 use arebuilding for unicode 并且它认为该字符串是多字节的。要做到这一点,请尝试

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

我不在城里,在我的 Mac 上,所以我无法对此进行测试。但周末我一直被困在办公室,所以我想我可以尝试两件事。

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.

比忠 2024-11-17 10:59:02
AfxMessageBox( L"Camera have no connection",MB_OK|MB_ICONSTOP);

上面的代码运行没有任何问题。如果您仍然想使用:

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

您可以转到项目属性,在常规选项卡中,您可以将字符集从“使用 Unicode 字符集”更改为“使用多字节字符集”

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"

断爱 2024-11-17 10:59:02

使用如下:

AfxMessageBox(_T("YOUR MESSAGE"));

Use as below:

AfxMessageBox(_T("YOUR MESSAGE"));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文