深入浅出MFC 第3章中 例子7如何运行起来呢
深入浅出MFC 第3章中 例子7怎么运行起来呢?
我在VC++中建立了WIN32控制台程序,将AFXMSG_.H,MFC.CPP,MFC.H,MY.CPP,MY.H导入。编译出现错误!
Compiling...
mfc.cpp
D:\61\mfc7\mfc.cpp(61) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(65) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(69) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(73) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(77) : error C2101: '& ' on constant
my.cpp
D:\61\mfc7\my.cpp(18) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(22) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(26) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(30) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(55) : warning C4018: '== ' : signed/unsigned mismatch
Error executing cl.exe.
mfc7.exe - 9 error(s), 1 warning(s)
请问这怎么解决呢?
问题好象在 下面代码中
BEGIN_MESSAGE_MAP(CMyWinApp, CWinApp)
ON_COMMAND(CMyWinAppid, 0)
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd)
ON_COMMAND(CMyFrameWndid, 0)
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CMyDoc, CDocument)
ON_COMMAND(CMyDocid, 0)
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CMyView, CView)
ON_COMMAND(CMyViewid, 0)
END_MESSAGE_MAP()
谢谢1
------解决方案--------------------
你用的是VS2003? 和VC 6、5消息映射有不同。
1)
修改 头文件 Afxmsg_.h 中
#define ON_COMMAND(id, memberFxn) \
{ WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSig_vv, (AFX_PMSG)memberFxn },
改 CN_COMMAND为 0
并且
2)
修改 头文件mfc.h中
// Message map signature values and macros in separate header
#include <afxmsg_.h>
为
// Message map signature values and macros in separate header
#include "afxmsg_.h "
rebuild all
我在VC++中建立了WIN32控制台程序,将AFXMSG_.H,MFC.CPP,MFC.H,MY.CPP,MY.H导入。编译出现错误!
Compiling...
mfc.cpp
D:\61\mfc7\mfc.cpp(61) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(65) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(69) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(73) : error C2101: '& ' on constant
D:\61\mfc7\mfc.cpp(77) : error C2101: '& ' on constant
my.cpp
D:\61\mfc7\my.cpp(18) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(22) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(26) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(30) : error C2101: '& ' on constant
D:\61\mfc7\my.cpp(55) : warning C4018: '== ' : signed/unsigned mismatch
Error executing cl.exe.
mfc7.exe - 9 error(s), 1 warning(s)
请问这怎么解决呢?
问题好象在 下面代码中
BEGIN_MESSAGE_MAP(CMyWinApp, CWinApp)
ON_COMMAND(CMyWinAppid, 0)
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CMyFrameWnd, CFrameWnd)
ON_COMMAND(CMyFrameWndid, 0)
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CMyDoc, CDocument)
ON_COMMAND(CMyDocid, 0)
END_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CMyView, CView)
ON_COMMAND(CMyViewid, 0)
END_MESSAGE_MAP()
谢谢1
------解决方案--------------------
你用的是VS2003? 和VC 6、5消息映射有不同。
1)
修改 头文件 Afxmsg_.h 中
#define ON_COMMAND(id, memberFxn) \
{ WM_COMMAND, CN_COMMAND, (WORD)id, (WORD)id, AfxSig_vv, (AFX_PMSG)memberFxn },
改 CN_COMMAND为 0
并且
2)
修改 头文件mfc.h中
// Message map signature values and macros in separate header
#include <afxmsg_.h>
为
// Message map signature values and macros in separate header
#include "afxmsg_.h "
rebuild all