出现以下的问题:
错误 3 error C2440: “static_cast”: 无法从“HRESULT (__cdecl CGPSDlg::* )(void)”转换为“LRESULT (__cdecl CWnd::* )(WPARAM,LPARAM)” d:/work/ForCode/download/GPS2/GPS2/GPSDlg.cpp 228 GPS
主是将代码从vc6升级到Vc++2008 后出现的问题.
处理的方法(现在可以保证运行,但是以后会不会出现有其他的问题还不太清楚)
消息处理方面出现了问题:
BEGIN_MESSAGE_MAP(CGPSDlg, CDialog)
//{{AFX_MSG_MAP(CGPSDlg)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_KEYDOWN()
ON_BN_CLICKED(IDC_BUTTON1, OnCancel)
ON_WM_TIMER()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_SUSPEND, OnSuspend)
END_MESSAGE_MAP()
用户自定义消息:OnSuspend这个方法返回值、参数都与ON_MESSAGE不匹配.
ON_MESSAGE
// for Windows messages
#define ON_MESSAGE(message, memberFxn) /
{ message, 0, 0, 0, AfxSig_lwl, /
(AFX_PMSG)(AFX_PMSGW) /
(static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM) > /
(memberFxn)) },
而OnSuspend
HRESULT CGPSDlg::OnSuspend ()
{}
于是我自己定义一个消息处理
OnMyMessage
a,
afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam);
b,
LRESULT CGPSDlg ::OnMyMessage(WPARAM wParam, LPARAM lParam)
{
return 0;
}
c,最后修改成:
ON_MESSAGE(WM_SUSPEND, OnMyMessage)
最后重新编译会出
错误 1 fatal error RC1015: cannot open include file 'wceres.rc'. d:/work/ForCode/download/GPS2/GPS2/GPS.rc 655 GPS
把 #include "wceres.rc" // WCE-specific components
注释掉就可以了.