问题描述
我创建了一个基于MFC对话框的应用,并希望在表单上添加计时器.但是事实证明,MFC与.NET Windows窗体不同.
I created an MFC dialog based app and wanted to add timer on the form. But it turns out that MFC is different than the .NET windows forms.
我在消息映射中添加了ON_WM_TIMER().并添加了CMyDialog :: OnTimer(UINT_PTR x)的函数定义{}
I added the ON_WM_TIMER() in the messagemap. and added the function definition for CMyDialog::OnTimer(UINT_PTR x){}
但是我在VS2005中遇到编译器错误.我不知道我在做什么错.错误C2509:'OnTimer':未在'CMyDialog'中声明成员函数"
But I am getting a compiler error in VS2005. I do not know what i am doing wrong."error C2509: 'OnTimer' : member function not declared in 'CMyDialog'"
非常感谢您的帮助.谢谢.
Help is greatly appreciated. Thanks.
推荐答案
很显然,您忘记了在MyDialog.h
的CMyDialog
声明中声明该函数:
Obviously, you forgot to declare the function in MyDialog.h
, in CMyDialog
declaration:
afx_msg void OnTimer(UINT_PTR x);
请注意,afx_msg纯粹是提供信息的,可以省略.
Note that afx_msg is purely informative and can be omitted.
这篇关于MFC OnTimer()方法不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!