#include <afxwin.h>
class CSimpleApp : public CWinApp
{
public:
BOOL InitInstance();
};
class CMainFrame : public CFrameWnd
{
public:
CMainFrame();
CString msg;
afx_msg void OnTimer (UINT nTimerID);
DECLARE_MESSAGE_MAP()
};
BOOL CSimpleApp::InitInstance(){
m_pMainWnd = new CMainFrame();
m_pMainWnd->ShowWindow(m_nCmdShow);
return TRUE;
}
CMainFrame::CMainFrame()
{
Create(NULL, "MFC Timer", WS_OVERLAPPEDWINDOW ,CRect(25,25,100,100));
SetTimer (1, 500, NULL);//sets up timer
msg="Hello World";
}
BEGIN_MESSAGE_MAP(CMainFrame,CFrameWnd)
ON_WM_TIMER ()
END_MESSAGE_MAP()
CSimpleApp MFCApp1;
//respond to timer message
afx_msg void CMainFrame::OnTimer(UINT tid)
{
CClientDC dc(this);
dc.TextOut(0,0,msg);
if (msg=="Hello World")
{
msg="                       ";
}
else
{
msg="Hello World";
}
}