在.cpp文件中, 响应函数的函数体 void CWinAppTestDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent); }
void OnTimer ( UINT uTimerID, TIMERPROC pTimerProc ) { if ( 1 != uTimerID ) SetMsgHandled(false); else { // If the clock is running, get the current time & redraw our // window so the new time appears. if ( m_bClockRunning ) { GetLocalTime ( &m_stLastTime ); RedrawWindow(); } } } BEGIN_MSG_MAP(CWTLClock2View) MESSAGE_HANDLER(WM_PAINT, OnPaint) MSG_WM_CREATE(OnCreate) MSG_WM_DESTROY(OnDestroy) MSG_WM_TIMER(OnTimer) MSG_WM_ERASEBKGND(OnEraseBkgnd) END_MSG_MAP() 我有消息映射 同OnTimer声明和实现。 怎么还会报CWTLClock2View::OnTimer' : function does not take 1 arguments错误
MSG_WM_TIMER(OnTimer) 编译报错:e:\program files\wtl80\wtlproject\wtl sample from mike\wtl4mfc2_demo\wtlclock\wtlclockview.h(26) : error C2660: 'CWTLClockView::OnTimer' : function does not take 1 arguments void OnTimer ( UINT uTimerID/*, TIMERPROC pTimerProc*/ )屏蔽掉第2个参数就可以了版本不一样。之前版本的为1个参数了。
//{{AFX_MSG_MAP(CWinAppTestDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()//这句是添加映射宏
ON_WM_CANCELMODE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()//头文件中
protected:
HICON m_hIcon; // Generated message map functions
//{{AFX_MSG(CWinAppTestDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
virtual void OnOK();
afx_msg void OnTimer(UINT nIDEvent);//这句是添加了响应函数的声明,你的声明也要按照这个格式。一模一样的。
afx_msg void OnCancelMode();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
在.cpp文件中, 响应函数的函数体
void CWinAppTestDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDialog::OnTimer(nIDEvent);
}
{
if ( 1 != uTimerID )
SetMsgHandled(false);
else
{
// If the clock is running, get the current time & redraw our
// window so the new time appears.
if ( m_bClockRunning )
{
GetLocalTime ( &m_stLastTime );
RedrawWindow();
}
}
} BEGIN_MSG_MAP(CWTLClock2View)
MESSAGE_HANDLER(WM_PAINT, OnPaint)
MSG_WM_CREATE(OnCreate)
MSG_WM_DESTROY(OnDestroy)
MSG_WM_TIMER(OnTimer)
MSG_WM_ERASEBKGND(OnEraseBkgnd)
END_MSG_MAP()
我有消息映射 同OnTimer声明和实现。 怎么还会报CWTLClock2View::OnTimer' : function does not take 1 arguments错误
void OnTimer(UINT_PTR uTimerID)
{
...
}
{
BEGIN_MSG_MAP(CWTLClock2View)
MSG_WM_TIMER(OnTimer)
END_MSG_MAP
public:
LRESULT OnTimer(UINT id, TIMERPROC lpTimerProc);
};//.cpp
LRESULT CMainDlg::OnTimer(UINT id, TIMERPROC lpTimerProc)
{ return 0;
}
void OnTimer ( UINT uTimerID/*, TIMERPROC pTimerProc*/ )屏蔽掉第2个参数就可以了版本不一样。之前版本的为1个参数了。
{
if (timerID==1)
{
Invalidate(0);
}
return 0;
}