'AfxMessageBox':2个重载中没有一个可以转换所有参数类型 [英] 'AfxMessageBox' : none of the 2 overloads could convert all the argument types

查看:316
本文介绍了'AfxMessageBox':2个重载中没有一个可以转换所有参数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在一个c ++项目中我使用HeaderFile localcpc.h.Inside出现错误

''''AfxMessageBox'':没有2个重载可以转换所有的参数类型''



错误来自下面的代码部分:



Hi,
In a c++ project Iam using a HeaderFile localcpc.h.Inside that an error is arising
''''AfxMessageBox'' : none of the 2 overloads could convert all the argument types''

And the error is coming in the below part of code:

BOOL SetLogNameAndPath(LPCWSTR FileNameandPath)
    {
        if(FileNameandPath)
        {
            FileHandle = CreateFile(FileNameandPath,GENERIC_READ | GENERIC_WRITE,FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
            if(FileHandle == INVALID_HANDLE_VALUE)
            {
                AfxMessageBox("Unable to create Log File");
                return FALSE;
            }
            SetFilePointer(FileHandle,0L,NULL,FILE_END);
        }
        else
        {
            ::AfxMessageBox(L"No FileName and path specified");
            return FALSE;
        }
        return TRUE;
    }







有人可以建议一些解决方案吗?




Can anybody suggest some solution?

推荐答案

如果 AfxMessageBox ,定义为



If AfxMessageBox which is defined as

int AfxMessageBox( LPCTSTR lpszText, UINT nType = MB_OK, UINT nIDHelp = 0 );





不能带你的 L 没有指定FileName和路径LPCWSTR参数并用默认值填写剩下的两个,这几乎可以肯定是因为你正在构建一个多字节构建或者原本无法预定义 UNICODE 和 _UNICODE 意味着预处理器解析了 AfxMessageBox 的定义事实





cannot take your L"No FileName and path specified" LPCWSTR parameter and fill in the remaining two with defaults it''s almost certainly because you''re building a Multibyte build or have otherwise failed to predfine UNICODE and _UNICODE in your build meaning that the preprocessor resolved definition of AfxMessageBox is in fact

int AfxMessageBox( const char* lpszText, unsigned int nType = MB_OK, unsigned int nIDHelp = 0 );





不再与使用 LPCWSTR 产生的 L文字宏。



你需要构建UNICODE构建或使用 _T(No FileName and path specified)这将在UNICODE和非UNICODE版本中都有效。



which no longer matches the use of LPCWSTR resulting from the L"text" macro.

You need to either build a UNICODE build or use _T("No FileName and path specified") which will work in both UNICODE and non UNICODE builds.

这篇关于'AfxMessageBox':2个重载中没有一个可以转换所有参数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆