error C2440: 'static_cast' LRESULT LRESULT错误

来源:互联网 发布:淘宝店铺售假怎么申诉 编辑:程序博客网 时间:2024/05/02 01:29

这是以前在网上搜到得一段对话

问1:为什么编译的时候在消息映射那里出错了:   
  error   C2440:   “static_cast”:   无法从“void   (__thiscall   CMainFrame::*   )(void)”转换为“LRESULT   (__thiscall   CWnd::*   )(WPARAM,LPARAM)”                   在匹配目标类型的范围内没有具有该名称的函数   
答:There   is   a   bug   in   6.0   compiler   that   permits   you   to   use   afx_msg   void   OnProgress();.   You   need   to   change   your   function   to   LRESULT   OnProgress(WPARAM,LPARAM).

问2:为什么MFC在其他的消息或者事件响应里面却能这样写呢?它不也都是用的void来申明的?
答:Some   message   handler   functions   such   as   the   wizard   generated   WM_CREATE   handler   are   virtual   functions   derived   from   default   MFC   implementations.   Check   out   MFC   source   code   to   see   how   MFC   handle   these   messages.
It   is   safe   if   you   don't   use   the   result   and   the   parameter   of   the   message   at   all.

原创粉丝点击