0
votes

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.

2
Did you add the method declaration in the .h file (MyDialog.h): afx_msg void OnTimer(UINT_PTR nIDEvent);???Javier De Pedro

2 Answers

5
votes

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.

2
votes

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?