100个windows平台C++开发错误之五MFC编程

更多精彩内容,请见:http://www.16boke.com


by zxy,Java/C++编程交流群:168424095

(21)Debug版本,编译生成成功,运行,弹出对话框:没有找到mfc90ud.dll<mfcXXX.dll>

项目属性->配置属性->链接器->调试->生成映射文件选择:是(/MAP)

(22)error C2065:’IDD_DIALOG’:undeclared identifier

在主文件中加入#include “resource.h” 

(23)error C2440:’static_cast’:cannot convert from ‘LRESULT(_thiscallCXXDlg::*)(CPoint)’ to ‘UNIT (_thiscall CWnd::*)(CPoint)

因为旧版本的ON_WM_NCHITTEST宏使用了UINT (_thiscall CWzButton::*)(CPoint);类型的类成员函数指针,其定义如下:

#define ON_WM_NCHITTEST()\

{

WM_NCHITTEST,0,0,0,AfxSig_wp,\

(AFX_PMSG)(AFX_PMSGW)(UINT(AFX_MSG_CALL CWnd::*)(CPoint)&OnNcHitTest},

#defineON_WM_NCHITTEST()\

    {WM_NCHITTEST, 0, 0, 0,AfxSig_wp, \

        (AFX_PMSG)(AFX_PMSGW)(UINT(AFX_MSG_CALLCWnd::*)(CPoint)&OnNcHitTest) },

新版本的是:

#defineON_WM_NCHITTEST()\

    {WM_NCHITTEST, 0, 0, 0,AfxSig_l_p, \

        (AFX_PMSG)(AFX_PMSGW)\

        (static_cast<LRESULT (AFX_MSG_CALLCWnd::*)(CPoint)> (&ThisClass :: OnNcHitTest)) },

返回值类型由UINT改成了LRESULT,再加上static_cast的严格检查,所以出错。

解决方法:将OnNcHitTest函数由:

afx_msg UINT OnNcHitTest(CPoint point);

改成:

afx_msg LRESULT OnNcHitTest(CPoint point);

(24)Xdebug Errors:Xdebug(32):error C2365:’operatornew’:redefinition;previous definition was ‘function’

原因:MFC和标准库混用

解决方法:方法一:把所有文件里面#definenew DEBUG_NEW全部删除

方法二:保证使用了new的语句在宏#define newDEBUG_NEW的前面。

(25)fatal errorC1189: #error :  WINDOWS.H already included. MFC apps must not #include<windows.h>

遇到问题情况:
试试把#include<afx.h>挪到最靠前位置;

#import"c:\ProgramFiles\Common Files\System\ADO\msado15.dll" \

        no_namespace rename("EOF","EndOfFile")

#include<afx.h>

解决方法:

#include<afx.h>挪前不行的话,就看看项目属性里有没有定义_WINDOWS_这个宏,有的话就去掉。


更多精彩内容,请见:http://www.16boke.com

你可能感兴趣的:(100个windows平台C++开发错误之五MFC编程)