基于对话框的串口通信:在CDebugDlg.h中,对WM_COMM_RXCHAR响应函数进行声明: // Generated message map functions
//{{AFX_MSG(CDebugDlg)
afx_msg LONG OnCommunication(WPARAM ch,LPARAM port);
//}}AFX_MSG在CDebugDlg.cpp中,对WM_COMM_RXCHAR进行消息映射:
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_MESSAGE(WM_COMM_RXCHAR,OnCommunication)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()并在CDebugDlg.cpp中,加入函数
LONG CDebugDlg::OnCommunication(WPARAM ch,LPARAM port)
{
return 0;
}//我新手做程序,提示有两个错误
ompiling...
debugDlg.cpp
D:\debug\debug\debugDlg.cpp(55) : error C2065: 'OnCommunication' : undeclared identifier
D:\debug\debug\debugDlg.cpp(55) : 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
Error executing cl.exe.debugDlg.obj - 2 error(s), 0 warning(s)
//怎么回事?那位能帮一下
//{{AFX_MSG(CDebugDlg)
afx_msg LONG OnCommunication(WPARAM ch,LPARAM port);
//}}AFX_MSG在CDebugDlg.cpp中,对WM_COMM_RXCHAR进行消息映射:
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_MESSAGE(WM_COMM_RXCHAR,OnCommunication)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()并在CDebugDlg.cpp中,加入函数
LONG CDebugDlg::OnCommunication(WPARAM ch,LPARAM port)
{
return 0;
}//我新手做程序,提示有两个错误
ompiling...
debugDlg.cpp
D:\debug\debug\debugDlg.cpp(55) : error C2065: 'OnCommunication' : undeclared identifier
D:\debug\debug\debugDlg.cpp(55) : 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
Error executing cl.exe.debugDlg.obj - 2 error(s), 0 warning(s)
//怎么回事?那位能帮一下
//{{AFX_MSG_MAP(CAboutDlg)
ON_MESSAGE(WM_COMM_RXCHAR,OnCommunication)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP() 地方错了,得在debugDlg的消息入口处添加
//有的书上也是那地方啊,什么标志算是消息入口处?还请ls说说,我新手
//{{AFX_MSG_MAP(CAboutDlg)
ON_MESSAGE(WM_COMM_RXCHAR,OnCommunication)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
(#define WM_COMM_RXCHAR WM_USER+***)"***"是一个值
同时"ON_MESSAGE(WM_COMM_RXCHAR,OnCommunication)"
也应该放在"//}}AFX_MSG_MAP"之后