MFC OnTimer() 方法不起作用

发布于 2024-11-29 00:36:21 字数 252 浏览 4 评论 0原文

我创建了一个基于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心奴独伤 2024-12-06 00:36:21

显然,您忘记在 MyDialog.h 中的 CMyDialog 声明中声明该函数:

afx_msg void OnTimer(UINT_PTR x);

请注意,afx_msg 纯粹是提供信息的,可以省略。

Obviously, you forgot to declare the function in MyDialog.h, in CMyDialog declaration:

afx_msg void OnTimer(UINT_PTR x);

Note that afx_msg is purely informative and can be omitted.

夏见 2024-12-06 00:36:21

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文