您的位置:首页 > 其它

MFC工程从VC6.0转换成VS2013遇到的问题以及解决方法

2016-08-04 15:28 423 查看
1.没有与参数列表匹配的重载函数

使用_T。

例如:

m_edtSendData.SetWindowText(_T("Please enter a message content!"));

strSetting.Format(_T("%d%c%d%d"), rates[nRate], paritys[nParity], dataBits[nDataBit], stopBits[nStopBit]);

2.编译时候出现如下错

error C2440: 'static_cast' : cannot convert from 'void (__thiscall XXX::* )(void)' to 'void (__thiscall CWnd::* )(UINT_PTR)'只需要吧对应的事件响应函数声明与实现的部分,函数的参数由UINT改为UINT_PTR即可。

3.问题:不能将参数 1 从“const char [14]”转换为“const wchar_t *”

解决方法:m_strSQL.Format("book_name'%s'",m_strSeek);

修改为:

m_strSQL.Format(_T("book_name\'%s\'"),m_strSeek);

cstr.Format(_T("%s"),sctr1);这个函数还是很好用的。

4.“int strcmp(const char *,const char *)”: 无法将参数 1 从“CString”转换为“const char *”

这里面涉及到一个CString转换为const char *的问题,而且涉及到Unicode。

例子:

CString strTest = _T("abcd");

USES_CONVERSION;

LPSTR lpszTest = T2A(strTest);

lpszTest为被转换的字符串

5.warning C4996: 'CWinApp::Enable3dControls': CWinApp::Enable3dControls is no longer needed.

通常向导生成的代码是:

#ifdef _AFXDLL

    Enable3dControls();            // Call this when using MFC in a shared DLL

#else

    Enable3dControlsStatic();    // Call this when linking to MFC statically

#endif

这两个函数的调用是旧的MFC版本对新版本的操作系统特性的支持,在新的(那个时候是新的)Windows 95平台上要这样调用一下才能使用新的Windows 3D样式的控件,否则就是老的Win 3.2样子的控件。想当初喜欢OWL就是因为感觉它的控件比较“酷”,比如那个带底纹的对话框,菱形的checkbox,还有带图标的“OK”按钮。对于新的MFC版本来说已经不需要再调用这两个函数了,参考前面的方法,用_MSC_VER对其隔离就行了:

添加红色部分代码即可, 其他不用修改

#if _MSC_VER <= 1200 // MFC 6.0 or earlier
    #ifdef _AFXDLL

        Enable3dControls();            // Call this when using MFC in a shared DLL

    #else

        Enable3dControlsStatic();    // Call this when linking to MFC statically

    #endif
#endif
6.VS2010如何安装MSComm控件

第一步:下载MSComm控件

下载地址:http://download.csdn.net/detail/flydream0/4583699

第二步:注册组件

压缩包内包含四个文件:

MSCOMM.SRG

MSCOMM32.DEP

MSCOMM32.oca

mscomm32.ocx

复制到系统盘的C:\Windows\System32(WIN7系统)。

然后在在开始菜单内输入cmd,输入如下指令:

[plain] view
plain copy

regsvr32 C:\Windows\System32\mscomm32.ocx  

如下图:



这表示注册成功了。
7.使用批处理函数自动注册MSComm空间(如何使用批处理将DOS提升至管理员权限)
在批处理的第一行添加

cd /d %~dp0

然后右键单击批处理文件,选择管理员权限运行

8.vs2013,MFC工程中,将对话框关闭后,在哪里重新找到对话框?

在对应的MFC工程的*****.rc文件中,点击这个文件,即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐