home *** CD-ROM | disk | FTP | other *** search
- // mytimvw.cpp : implementation of the CMytimerView class
- //
-
- #include "stdafx.h"
- #include "mytimer.h"
-
- #include "mytimdoc.h"
- #include "mytimvw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CMytimerView
-
- IMPLEMENT_DYNCREATE(CMytimerView, CView)
-
- BEGIN_MESSAGE_MAP(CMytimerView, CView)
- //{{AFX_MSG_MAP(CMytimerView)
- ON_WM_CREATE()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMytimerView construction/destruction
-
- CMytimerView::CMytimerView()
- {
- // TODO: add construction code here
- }
-
- CMytimerView::~CMytimerView()
- {
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMytimerView drawing
-
- void CMytimerView::OnDraw(CDC* pDC)
- {
- CMytimerDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
- // TODO: add draw code for native data here
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMytimerView diagnostics
-
- #ifdef _DEBUG
- void CMytimerView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CMytimerView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CMytimerDoc* CMytimerView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMytimerDoc)));
- return (CMytimerDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CMytimerView message handlers
-
- int CMytimerView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- // TODO: Add your specialized creation code here
-
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Install a system timer with 500 milliseconds interval.
- if ( SetTimer (1, 500, NULL) == 0 )
- MessageBox ("Cannot install timer!!!");
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
-
- return 0;
- }
-
- void CMytimerView::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- //MessageBeep(-1);
-
- // Create an object of class CTime.
- CTime tNow;
-
- // Update tNow with the current time.
- tNow = CTime::GetCurrentTime();
-
- // Format the current time.
- CString sNow = tNow.Format("%I:%M:%S %p");
-
- // Display the current time.
- CClientDC dc(this);
- dc.TextOut(15,15,sNow);
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- CView::OnTimer(nIDEvent);
- }
-