home *** CD-ROM | disk | FTP | other *** search
/ HTBasic 9.3 / HTBasic 9.3.iso / 83win / data1.cab / DLL_Toolkit / Source / HTBClock / lockDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-02  |  2.4 KB  |  97 lines

  1. /**********************************************
  2. HTBclock.dll
  3. TransEra Corporation 1999.
  4. This is the source for the HTBClock.dll.
  5.  
  6. ***********************************************/
  7. #include "stdafx.h"
  8. #include "HTBclock.h"
  9. #include "lockDlg.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. #define FONT            "Arial"                // Supports all Windows Fonts
  18. #define TIME_FORMAT        "%d:%0.2d:%0.2d"    // formatting string for Time string
  19. #define X_SIZE            300
  20. #define Y_SIZE            150
  21. #define FONT_SIZE        500
  22. #define COLOR_MIN        0            
  23. #define GREY_COLOR        240
  24. #define HOUR_FORMAT        12                    // 12 or 24
  25. #define TIMERVAL        100
  26. #define OFFSET            3
  27. #define NEG_OFFSET        -5
  28.  
  29.  
  30. ClockDlg::ClockDlg(CWnd* pParent /*=NULL*/)
  31.     : CDialog(ClockDlg::IDD, pParent)
  32. {
  33.     //{{AFX_DATA_INIT(ClockDlg)
  34.         // NOTE: the ClassWizard will add member initialization here
  35.     //}}AFX_DATA_INIT
  36. }
  37.  
  38.  
  39. void ClockDlg::DoDataExchange(CDataExchange* pDX)
  40. {
  41.     CDialog::DoDataExchange(pDX);
  42.     //{{AFX_DATA_MAP(ClockDlg)
  43.         // NOTE: the ClassWizard will add DDX and DDV calls here
  44.     //}}AFX_DATA_MAP
  45. }
  46.  
  47.  
  48. BEGIN_MESSAGE_MAP(ClockDlg, CDialog)
  49.     //{{AFX_MSG_MAP(ClockDlg)
  50.     ON_WM_PAINT()
  51.     ON_WM_TIMER()
  52.     //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // ClockDlg message handlers
  57.  
  58. BOOL ClockDlg::OnInitDialog()  
  59. {        
  60.     CDialog::OnInitDialog();    
  61.     SetWindowPos(FromHandle(m_hWnd), g_Xpos, g_Ypos, X_SIZE, Y_SIZE, SWP_NOZORDER);
  62.     SetTimer(1,TIMERVAL,NULL);    
  63.     return TRUE;  
  64. }
  65.  
  66. void ClockDlg::OnTimer(UINT nIDEvent)  
  67. {
  68.     Invalidate();    
  69.     CDialog::OnTimer(nIDEvent);
  70. }
  71.  
  72. void ClockDlg::OnPaint()  
  73. {
  74.  
  75.     CPaintDC dc(this); 
  76.     CRect rect;
  77.     GetClientRect(&rect);
  78.     CFont font;
  79.     font.CreatePointFont(FONT_SIZE,_T(FONT));            
  80.     dc.SelectObject(&font);                                    // Load Font
  81.     dc.SetBkMode(TRANSPARENT);                                // Background
  82.     CString sCurTime;
  83.     CTime time = CTime::GetCurrentTime();
  84.     int iSecond = time.GetSecond();
  85.     int iMinute = time.GetMinute();
  86.     int iHour = time.GetHour() % HOUR_FORMAT;
  87.     sCurTime.Format(_T(TIME_FORMAT), iHour, iMinute, iSecond);
  88.     rect.OffsetRect(OFFSET, OFFSET);
  89.     dc.SetTextColor(RGB(GREY_COLOR, GREY_COLOR, GREY_COLOR));
  90.     dc.DrawText(sCurTime, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
  91.     rect.OffsetRect(NEG_OFFSET, NEG_OFFSET);
  92.     dc.SetTextColor(RGB(COLOR_MIN, COLOR_MIN, COLOR_MIN));
  93.     dc.DrawText(sCurTime, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER);     
  94. }
  95.  
  96.  
  97.