home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c12 / clock / clockctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  3.3 KB  |  119 lines

  1. // ClockCtl.h : Declaration of the CClockCtrl OLE control class.
  2.  
  3. /////////////////////////////////////////////////////////////////////////////
  4. // CClockCtrl : See ClockCtl.cpp for implementation.
  5.  
  6. class CClockCtrl : public COleControl
  7. {
  8.     DECLARE_DYNCREATE(CClockCtrl)
  9.  
  10. // Constructor
  11. public:
  12.     CClockCtrl();
  13.  
  14. // Overrides
  15.  
  16.     // Drawing function
  17.     virtual void OnDraw(
  18.                 CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
  19.  
  20.     // Persistence
  21.     virtual void DoPropExchange(CPropExchange* pPX);
  22.  
  23.     // Reset control state
  24.     virtual void OnResetState();
  25.     virtual BOOL OnGetPredefinedStrings( DISPID dispid, 
  26.         CStringArray* pStringArray, CDWordArray* pCookieArray );
  27.     virtual BOOL OnGetPredefinedValue( DISPID dispid, DWORD dwCookie, 
  28.         VARIANT FAR* lpvarOut );
  29.     virtual BOOL OnGetDisplayString( DISPID dispid, CString& strValue );
  30.     virtual BOOL OnMapPropertyToPage(DISPID dispid, LPCLSID lpclsid,
  31.                                      BOOL * pbPageOptional);
  32.   
  33.  
  34. // Implementation
  35. protected:
  36.     CFont* m_pClockFont;
  37.     CFont* m_pAlarmFont;
  38.     ~CClockCtrl();
  39.  
  40.     DECLARE_OLECREATE_EX(CClockCtrl)    // Class factory and guid
  41.     DECLARE_OLETYPELIB(CClockCtrl)      // GetTypeInfo
  42.     DECLARE_PROPPAGEIDS(CClockCtrl)     // Property page IDs
  43.     DECLARE_OLECTLTYPE(CClockCtrl)        // Type name and misc status
  44.  
  45. // Message maps
  46.     //{{AFX_MSG(CClockCtrl)
  47.     afx_msg void OnTimer(UINT nIDEvent);
  48.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  49.     afx_msg void OnDestroy();
  50.     afx_msg void OnSize(UINT nType, int cx, int cy);
  51.     afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  52.     //}}AFX_MSG
  53.     DECLARE_MESSAGE_MAP()
  54.  
  55. // Dispatch maps
  56.     //{{AFX_DISPATCH(CClockCtrl)
  57.     BOOL m_bAlarmSet;
  58.     afx_msg void OnAlarmSetChanged();
  59.     afx_msg short GetAlarmHour();
  60.     afx_msg void SetAlarmHour(short nNewValue);
  61.     afx_msg short GetAlarmMinute();
  62.     afx_msg void SetAlarmMinute(short nNewValue);
  63.     afx_msg short GetAlarmType();
  64.     afx_msg void SetAlarmType(short nNewValue);
  65.     afx_msg BSTR GetAlarmSound();
  66.     afx_msg void SetAlarmSound(LPCTSTR lpszNewValue);
  67.     afx_msg BSTR GetAlarmCommand();
  68.     afx_msg void SetAlarmCommand(LPCTSTR lpszNewValue);
  69.     afx_msg void TestAlarm();
  70.     afx_msg void SetAlarmTime(short hour, short nNewValue);
  71.     //}}AFX_DISPATCH
  72.     DECLARE_DISPATCH_MAP()
  73.  
  74.     afx_msg void AboutBox();
  75.  
  76. // Event maps
  77.     //{{AFX_EVENT(CClockCtrl)
  78.     void FireAlarmEvent()
  79.         {FireEvent(eventidAlarmEvent,EVENT_PARAM(VTS_NONE));}
  80.     //}}AFX_EVENT
  81.     DECLARE_EVENT_MAP()
  82.  
  83. // Dispatch and event IDs
  84. public:
  85.     enum {
  86.     //{{AFX_DISP_ID(CClockCtrl)
  87.     dispidAlarmHour = 2L,
  88.     dispidAlarmMinute = 3L,
  89.     dispidAlarmType = 4L,
  90.     dispidAlarmSound = 5L,
  91.     dispidAlarmCommand = 6L,
  92.     dispidAlarmSet = 1L,
  93.     dispidAlarmTime = 8L,
  94.     dispidTestAlarm = 7L,
  95.     eventidAlarmEvent = 1L,
  96.     //}}AFX_DISP_ID
  97.     };
  98. private:
  99.     enum {RT_CLOCK = 1, RT_ALARM};
  100.     int m_TimerID;
  101.     COleDateTime m_dtCurrent;
  102.     short m_ClockSecond;
  103.     short m_ClockMinute;
  104.     short m_ClockHour;
  105.     short m_AlarmMinute;
  106.     short m_AlarmHour;
  107.     int m_AlarmType;
  108.     CString m_AlarmSound;
  109.     CString m_AlarmCommand;    
  110.     BOOL m_bAlarmSounded;
  111.     void DoAlarm();
  112.     void DoAlarmCheck();
  113.     virtual void DrawCurrentTime(
  114.                 CDC* pdc, const CRect& rcBounds);
  115.     virtual void DrawAlarmDisplay(
  116.                 CDC* pdc, const CRect& rcBounds);
  117.     virtual BOOL GetClockRect(int nType, const CRect& rcBounds, CRect& rcResult);
  118. };
  119.