我在自定义消息时出现了一个错误
E:\Source Code\UserServer\UserServerDlg.cpp(57) : error C2440: 'type cast' : cannot convert from 'int *' to 'long (__thiscall CWnd::*)(unsigned int,long)'
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_MESSAGE(WM_TC_MESSAGE,OnTcMessage)//“问题语句”
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
我是按照网上的文档做的,不知为何会出这个问题?那位大侠能帮帮我,或者给我一个能调通的步骤!感谢感谢!

解决方案 »

  1.   

    你要在UserServerDlg.h的//{{AFX_MSG块中加入
    //{{AFX_MSG(...)
    ...
    afx_msg LRESULT OnTcMessage(WPARAM wParam, LPARAM lParam);
    ...
    //}}AFX_MSG然后还要在UserServerDlg.CPP中给出
    LRESULT CUserServerDlg::OnTcMessage(WPARAM wParam, LPARAM lParam)
    {
      ...
    }
      

  2.   

    //{{AFX_MSG_MAP(CAboutDlg)
    //}}AFX_MSG_MAP
    ON_MESSAGE(WM_TC_MESSAGE,OnTcMessage)//“问题语句”
    要放到外面,不要在里面头文件也一样
      

  3.   

    我在.h and .Cpp文件中都给定义了,之后我也改了flySnow兄所说的地方,便以后还是不能通过,
    E:\Source Code\UserServer\UserServerDlg.cpp(59) : error C2440: 'type cast' : cannot convert from 'int *' to 'long (__thiscall CWnd::*)(unsigned int,long)'
            There is no context in which this conversion is possible
    E:\Source Code\UserServer\UserServerDlg.cpp(59) : error C2065: 'OnTcMessage' : undeclared identifier
    出现了两个错误!谁能给我写一个自定义消息的步骤?
      

  4.   

    我觉得你号行写错位置了。好像是这句话
    ON_MESSAGE(WM_TC_MESSAGE,OnTcMessage)//
    你把它放在了CAboutDlg里面了。
      

  5.   

    感觉 ON_MESSAGE(WM_TC_MESSAGE,OnTcMessage)
    放错地方了,
    //----------------------
    BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    //{{AFX_MSG_MAP(CAboutDlg)
    ON_MESSAGE(WM_TC_MESSAGE,OnTcMessage)//“问题语句”
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    //----------------------
    CAboutDlg??我猜应该是另外的类里去影射吧?
      

  6.   

    你声明OnTcMessage()应该声明为CWnd的成员函数
      

  7.   

    ON_MESSAGE(WM_TC_MESSAGE,OnTcMessage)
    应放在.cpp文件中。
      

  8.   

    ok,正如: nanjianhui(nan) 、 yjwan(皮球) 、yhb4(胖子) 所说的,
    现在已经解决,谢谢大家
      

  9.   

    以下语句:
    ON_MESSAGE(WM_TC_MESSAGE,OnTcMessage)你把它放到UserServerDlg.cpp中的影射的地方