只要出现
BEGIN_MESSAGE_MAP(CWnd, CCmdTarget)
ON_COMMAND(CWndid, 0)
END_MESSAGE_MAP()就说
ON_COMMAND(CWndid, 0)处 error C2101: '&' on constant每个地方都是这样,怎么回事?如何解决?

解决方案 »

  1.   

    如果没有这代码的GGJJDDMM都可以留下E_mail,我发给你
    是关于Message Mapping(消息映射)这节的
      

  2.   

    是吗?我编译一点问题都没有啊?frame7.03?
      

  3.   

    运行结果:CWinApp::InitApplication
    CMyWinApp::InitInstance
    CFrameWnd::Create
    CWnd::CreateEx
    CFrameWnd::PreCreateWindow
    CWinApp::Run
    CWinThread::RunCMyView Message Map :
    1221    CMyView
    122    CView
    12    CWnd
    1    CCmdTargetCMyDoc Message Map :
    131    CMyDoc
    13    CDocument
    1    CCmdTargetCMyFrameWnd Message Map :
    1211    CMyFrameWnd
    121    CFrameWnd
    12    CWnd
    1    CCmdTargetCMyWinApp Message Map :
    1111    CMyWinApp
    111    CWinApp
    1    CCmdTarget
      

  4.   

    我是新建一个"Win32 console Application"的空工程
    然后将frame7.03里的.h和.cpp文件复制到该目录下并添加到工程中
    然后编译运行就出现了9个相同的错误,如下:
    --------------------Configuration: Frame7 - Win32 Debug--------------------
    Compiling...
    MFC.cpp
    e:\frame7\mfc.cpp(61) : error C2101: '&' on constant
    e:\frame7\mfc.cpp(65) : error C2101: '&' on constant
    e:\frame7\mfc.cpp(69) : error C2101: '&' on constant
    e:\frame7\mfc.cpp(73) : error C2101: '&' on constant
    e:\\frame7\mfc.cpp(77) : error C2101: '&' on constant
    My.cpp
    E:\Frame7\My.cpp(18) : error C2101: '&' on constant
    E:\Frame7\My.cpp(22) : error C2101: '&' on constant
    E:\Frame7\My.cpp(26) : error C2101: '&' on constant
    E:\Frame7\My.cpp(30) : error C2101: '&' on constant
    E:\Frame7\My.cpp(55) : warning C4018: '==' : signed/unsigned mismatch
    Error executing cl.exe.Frame7.exe - 9 error(s), 1 warning(s)
      

  5.   

    已发,这都是候sir光盘里的原码(MFC.h、MFC.cpp、MY.h、MY.cpp、afxmsg_.h)如果问题得到解决请回复,谢谢
      

  6.   

    哦,你最好不要用建新工程再添加上述文件的方法来编译。
    你这样试一试:
    直接打开my.cpp(main函数在这里面),然后编译该文件,环境会询问你该工程不存在是否要建立该工程,当然是了。这样应该没问题。
    你的'&' on constant的错误很奇怪的,因为_messageEntries只是定义的静态而已。
    试试我说的编译方法,不行的话(应该不会吧?),我把我编译的工程寄给你,你自己比较一下吧。
      

  7.   

    我用你的方法编译了一遍,也是可以的。所以,可能你的文件有问题。
    你把MFC.h的DECLARE_MESSAGE_MAP宏定义和BEGIN_MESSAGE_MAP宏定义贴出来看看?
      

  8.   

    你把AFXMSG_.H的代码换成enum AfxSig
    {
            AfxSig_end = 0,     // [s end of message map]
            AfxSig_vv,
    };#define ON_COMMAND(id, memberFxn) \
            { WM_COMMAND, 0, (WORD)id, (WORD)id, AfxSig_vv, (AFX_PMSG)memberFxn },
    试试