Dave's Brain

Browse - Programming Tips - How can I manually add a timer message handler to my MFC code?

Date: 2015oct23
OS: Windows
Framework: MFC
Language: C/C++

Q.  How can I manually add a timer message handler to my MFC code?

A.

In the .h file add:

class CMyDialogDlg : public CDialog { ... afx_msg void OnTimer(UINT nIDEvent); ... }
In the .cpp file add:
BEGIN_MESSAGE_MAP(CMyDialogDlg, CDialog) ... ON_WM_TIMER() ... END_MESSAGE_MAP() ... void CMyDialog::OnTimer(UINT id) { // ... Do what you want here... CDialog::OnTimer(id); }

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.