home *** CD-ROM | disk | FTP | other *** search
/ Using Visual C++ 4 (Special Edition) / Using_Visual_C_4_Special_Edition_QUE_1996.iso / ch03 / ch3_diag / tinabox.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-16  |  1.8 KB  |  84 lines

  1. // TInABox.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ch3_menu.h"
  6. #include "TInABox.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // TimeInABox dialog
  16.  
  17.  
  18. TimeInABox::TimeInABox(CWnd* pParent /*=NULL*/)
  19.     : CDialog(TimeInABox::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(TimeInABox)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26.  
  27. void TimeInABox::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(TimeInABox)
  31.         // NOTE: the ClassWizard will add DDX and DDV calls here
  32.     //}}AFX_DATA_MAP
  33. }
  34.  
  35.  
  36. BEGIN_MESSAGE_MAP(TimeInABox, CDialog)
  37.     //{{AFX_MSG_MAP(TimeInABox)
  38.     ON_WM_TIMER()
  39.     //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // TimeInABox message handlers
  44.  
  45. BOOL TimeInABox::OnInitDialog() 
  46. {
  47.     CDialog::OnInitDialog();
  48.  
  49.     // Set the initial time
  50.     SetDlgItemText(
  51.         IDC_TIMEBOX_TIME, 
  52.         CTime::GetCurrentTime().Format("%#c"));
  53.     // trigger a timer every second, to update the time
  54.     SetTimer(1, 1000, NULL);
  55.     
  56.     return TRUE;  // return TRUE unless you set the focus to a control
  57.                   // EXCEPTION: OCX Property Pages should return FALSE
  58. }
  59.  
  60. void TimeInABox::OnTimer(UINT nIDEvent) 
  61. {
  62.     // display current date/time in long format
  63.     if (nIDEvent == 1) {
  64.         SetDlgItemText(
  65.             IDC_TIMEBOX_TIME, 
  66.             CTime::GetCurrentTime().Format("%#c"));
  67.     }
  68.     CDialog::OnTimer(nIDEvent);
  69. }
  70.  
  71. void TimeInABox::OnOK() 
  72. {
  73.     // TODO: Add extra validation here
  74.     
  75.     CDialog::OnOK();
  76. }
  77.  
  78. void TimeInABox::OnCancel() 
  79. {
  80.     // TODO: Add extra cleanup here
  81.     
  82.     CDialog::OnCancel();
  83. }
  84.