MFC OnTimer() 方法不起作用
我创建了一个基于 MFC 对话框的应用程序,并想在窗体上添加计时器。但事实证明,MFC 与 .NET Windows 窗体不同。
我在消息映射中添加了 ON_WM_TIMER() 。并添加了 CMyDialog::OnTimer(UINT_PTR x) 的函数定义 { 但
我在 VS2005 中遇到编译器错误。我不知道我做错了什么。 “错误 C2509:‘OnTimer’:未在‘CMyDialog’中声明成员函数”
非常感谢帮助。谢谢。
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.
I added the ON_WM_TIMER() in the messagemap. and added the function definition for CMyDialog::OnTimer(UINT_PTR x)
{
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,您忘记在
MyDialog.h
中的CMyDialog
声明中声明该函数:请注意,afx_msg 纯粹是提供信息的,可以省略。
Obviously, you forgot to declare the function in
MyDialog.h
, inCMyDialog
declaration:Note that afx_msg is purely informative and can be omitted.
ON_WM_TIMER 地图宏的文档表明您的做法是正确的事物。我唯一能想到的是您已将
afx_msg
限定符从函数定义中删除。编辑:冒着陈述显而易见的风险,您是否还在类声明中包含了 OnTimer 函数的原型?
The documentation for the ON_WM_TIMER map macro shows that you're doing the right thing. The only thing I can think of is that you have left the
afx_msg
qualifier off of your function definition.Edit: At the risk of stating the obvious, did you also include the prototype of the OnTimer function in your class declaration?