MFC OnTimer() method not working
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 fo开发者_高级运维r 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.
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.
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?
精彩评论