home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / dtime / data.1 / DENTRY.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-08  |  12.1 KB  |  455 lines

  1. /*
  2. Module : DENTRY.H
  3. Purpose: Defines the interface to a number of classes to allow data entry of 
  4.          the date/time classes
  5. Created: PJN / DATE/1 / 20-02-1996
  6. History: None
  7.  
  8. Copyright (c) 1996 by PJ Naughter.  
  9. All rights reserved.
  10.  
  11. */
  12.  
  13. #ifndef __DENTRY_H__
  14.  
  15.  
  16. ////////////////////////////////// Macros /////////////////////////////////////
  17.  
  18. #define __DENTRY_H__
  19.  
  20.  
  21. ////////////////////////////////// Consts /////////////////////////////////////
  22.  
  23. //flags used to control how the drop down dialogs are displayed
  24.  
  25. const DWORD DT_ONLYVALID        = 0x0001;   //only allows valid data to be entered
  26. const DWORD DT_NOMILLISECOND    = 0x0002;   //do not show the millisecond field
  27. const DWORD DT_NODRAG           = 0x0004;   //do not allow dialog dragging
  28. const DWORD DT_CLOSEONDEACTIVE  = 0x0008;   //close the drop down dialog when it losses focus, needs DT_MODELESS
  29. const DWORD DT_PUSHPIN          = 0x0010;   //Displays a push pin in the drop down dialog, needs DT_MODELESS
  30. const DWORD DT_MODAL            = 0x0020;   //Creates the drop down dialog as modal
  31. const DWORD DT_MODELESS         = 0x0040;   //Creates the drop down dialog as modeless
  32.  
  33. ////////////// Id of the edit button created at run time //////////////////////
  34. #define DTIME_EDIT_CONTROL_ID 1000                                                   
  35. #define UWM_BN_CLICKED WM_USER + 100
  36.  
  37.  
  38. ////////////////////////////////// Includes ///////////////////////////////////
  39. #include "stdafx.h"
  40. #include "datetime.h"
  41.  
  42.  
  43. ////////////////////////////// classes ////////////////////////////////////////
  44. class CDTDialog : public CDialog
  45. {
  46. public:
  47.   CDTDialog();
  48.   CDTDialog(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL);
  49.   CDTDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL);
  50.   
  51. protected:
  52.   //{{AFX_DATA(CDTDialog)
  53.   //}}AFX_DATA
  54.  
  55.   virtual void OnOK();
  56.   virtual void OnCancel();
  57.  
  58.   //{{AFX_VIRTUAL(CDTDialog)
  59.   public:
  60.   virtual BOOL PreTranslateMessage(MSG* pMsg);
  61.   //}}AFX_VIRTUAL
  62.  
  63.   //{{AFX_MSG(CDTDialog)
  64.   virtual BOOL OnInitDialog();
  65.   afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  66.   afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
  67.   #ifndef _WIN32
  68.     afx_msg void OnPushPin();
  69.   #endif
  70.   //}}AFX_MSG
  71.   DECLARE_MESSAGE_MAP()
  72.  
  73.   CWnd* m_pParentWnd;
  74.   DWORD m_dwFlags;
  75.   BOOL m_bSafeToClose;
  76.   CPushPinButton m_btnPushPin;
  77. #ifdef _WIN32  
  78.   CToolTipCtrl m_TipPushPin;
  79. #endif  
  80. };
  81.  
  82.  
  83. class CCDateDlg : public CDTDialog
  84. {
  85. public:
  86. //Constructors / Destructors
  87.   CCDateDlg();
  88.   CCDateDlg(CWnd* pParent, DWORD dwFlags);
  89.   BOOL Create(CWnd* pParent, DWORD dwFlags);
  90.  
  91. //Accessors / Mutators
  92.   void SetValue(const CDate& value);
  93.   CDate GetValue();
  94.   
  95. protected:
  96.   //{{AFX_DATA(CCDateDlg)
  97.   CComboBox m_ctrlMonth;
  98. #ifdef _WIN32  
  99.   CSpinButtonCtrl m_ctrlSpinYear;
  100.   CSpinButtonCtrl m_ctrlSpinDay;
  101. #endif  
  102.   CButton m_ctrlInvalid;
  103.   UINT  m_nDay;
  104.   long  m_lYear;
  105.   BOOL  m_bInValid;
  106.   //}}AFX_DATA
  107.   UINT m_nMonth;
  108.  
  109.   //{{AFX_VIRTUAL(CCDateDlg)
  110.   protected:
  111.   virtual void DoDataExchange(CDataExchange* pDX);
  112.   //}}AFX_VIRTUAL
  113.  
  114.   //{{AFX_MSG(CCDateDlg)
  115.   virtual BOOL OnInitDialog();
  116.   afx_msg void OnInvalid();
  117.   //}}AFX_MSG
  118.   DECLARE_MESSAGE_MAP()
  119. };
  120.  
  121.  
  122. class CCLTimeOfDayDlg : public CDTDialog
  123. {
  124. public:
  125. //Constructors / Destructors
  126.   CCLTimeOfDayDlg();
  127.   CCLTimeOfDayDlg(CWnd* pParent, DWORD dwFlags);
  128.   BOOL Create(CWnd* pParent, DWORD dwFlags);
  129.  
  130. //Accessors / Mutators
  131.   void SetValue(const CLTimeOfDay& value);
  132.   CLTimeOfDay GetValue();
  133.  
  134. protected:
  135.   //{{AFX_DATA(CCLTimeOfDayDlg)
  136. #ifdef _WIN32  
  137.   CSpinButtonCtrl m_ctrlSpinHour;
  138.   CSpinButtonCtrl m_ctrlSpinMinute;
  139.   CSpinButtonCtrl m_ctrlSpinSecond;
  140.   CSpinButtonCtrl m_ctrlSpinMilliSecond;
  141. #endif  
  142.   CButton m_ctrlInvalid;
  143.   UINT  m_nHour;
  144.   UINT  m_nMinute;
  145.   UINT  m_nSecond;
  146.   UINT  m_nMilliSecond;
  147.   BOOL  m_bInValid;
  148.   //}}AFX_DATA
  149.  
  150.   //{{AFX_VIRTUAL(CCLTimeOfDayDlg)
  151.   protected:
  152.   virtual void DoDataExchange(CDataExchange* pDX);
  153.   //}}AFX_VIRTUAL
  154.  
  155.   //{{AFX_MSG(CCLTimeOfDayDlg)
  156.   virtual BOOL OnInitDialog();
  157.   afx_msg void OnInvalid();
  158.   //}}AFX_MSG
  159.   DECLARE_MESSAGE_MAP()
  160. };
  161.  
  162.  
  163. class CCLTimeSpanDlg : public CDTDialog
  164. {
  165. public:
  166. //Constructors / Destructors
  167.   CCLTimeSpanDlg();
  168.   CCLTimeSpanDlg(CWnd* pParent, DWORD dwFlags);
  169.   BOOL Create(CWnd* pParent, DWORD dwFlags);
  170.  
  171. //Accessors / Mutators
  172.   void SetValue(const CLTimeSpan& value);
  173.   CLTimeSpan GetValue();
  174.   
  175. protected:
  176.   //{{AFX_DATA(CCLTimeSpanDlg)
  177. #ifdef _WIN32  
  178.   CSpinButtonCtrl m_ctrlSpinDay;
  179.   CSpinButtonCtrl m_ctrlSpinHour;
  180.   CSpinButtonCtrl m_ctrlSpinMinute;
  181.   CSpinButtonCtrl m_ctrlSpinSecond;
  182.   CSpinButtonCtrl m_ctrlSpinMilliSecond;
  183. #endif  
  184.   CButton m_ctrlInvalid;
  185.   long  m_lDay;
  186.   UINT  m_nHour;
  187.   UINT  m_nMinute;
  188.   UINT  m_nSecond;
  189.   UINT  m_nMilliSecond;
  190.   BOOL  m_bInValid;
  191.   //}}AFX_DATA
  192.  
  193.   //{{AFX_VIRTUAL(CCLTimeSpanDlg)
  194.   protected:
  195.   virtual void DoDataExchange(CDataExchange* pDX);
  196.   //}}AFX_VIRTUAL
  197.  
  198.   //{{AFX_MSG(CCLTimeSpanDlg)
  199.   virtual BOOL OnInitDialog();
  200.   afx_msg void OnInvalid();
  201.   //}}AFX_MSG
  202.   DECLARE_MESSAGE_MAP()
  203. };
  204.  
  205.  
  206. class CCLDateDlg : public CDTDialog
  207. {
  208. public:
  209. //Constructors / Destructors
  210.   CCLDateDlg();
  211.   CCLDateDlg(CWnd* pParent, DWORD dwFlags);
  212.   BOOL Create(CWnd* pParent, DWORD dwFlags);
  213.  
  214. //Accessors / Mutators
  215.   void SetValue(const CLDate& value);
  216.   CLDate GetValue();
  217.   
  218. protected:
  219.   //{{AFX_DATA(CCLDateDlg)
  220.   CComboBox m_ctrlTimeFrame;
  221. #ifdef _WIN32  
  222.   CSpinButtonCtrl m_ctrlSpinHour;
  223.   CSpinButtonCtrl m_ctrlSpinMinute;
  224.   CSpinButtonCtrl m_ctrlSpinSecond;
  225.   CSpinButtonCtrl m_ctrlSpinMilliSecond;
  226.   CSpinButtonCtrl m_ctrlSpinYear;
  227.   CSpinButtonCtrl m_ctrlSpinDay;
  228. #endif  
  229.   CButton m_ctrlInvalid;
  230.   CComboBox m_ctrlMonth;
  231.   UINT  m_nHour;
  232.   UINT  m_nMinute;
  233.   UINT  m_nSecond;
  234.   UINT  m_nMilliSecond;
  235.   UINT  m_nDay;
  236.   long  m_lYear;
  237.   BOOL  m_bInValid;
  238.   //}}AFX_DATA
  239.   UINT m_nMonth;
  240.   UINT m_nTimeFrame;
  241.  
  242.   //{{AFX_VIRTUAL(CCLDateDlg)
  243.   protected:
  244.   virtual void DoDataExchange(CDataExchange* pDX);
  245.   //}}AFX_VIRTUAL
  246.  
  247.   //{{AFX_MSG(CCLDateDlg)
  248.   virtual BOOL OnInitDialog();
  249.   afx_msg void OnInvalid();
  250.   //}}AFX_MSG
  251.   DECLARE_MESSAGE_MAP()
  252. };
  253.  
  254.  
  255. class CDateButton : public CButton
  256. {
  257. public:
  258.   CDateButton();
  259.   virtual ~CDateButton();
  260.  
  261.   void SetBuddy(CWnd* pBuddy);
  262.  
  263.  
  264. protected:
  265.   //{{AFX_VIRTUAL(CDateButton)
  266.   public:
  267.   virtual BOOL PreTranslateMessage(MSG* pMsg);
  268.   //}}AFX_VIRTUAL
  269.  
  270.   //{{AFX_MSG(CDateButton)
  271.   afx_msg void OnClicked();
  272.   afx_msg LRESULT OnMyReflectedClicked(WPARAM wParam, LPARAM lParam);
  273.   afx_msg LRESULT OnDlgClose(WPARAM, LPARAM);
  274.   //}}AFX_MSG
  275.  
  276.   DECLARE_MESSAGE_MAP()
  277.  
  278.   CWnd* m_pBuddy;
  279.   BOOL m_bFirstCall;
  280. #ifdef _WIN32  
  281.   CToolTipCtrl m_ToolTip;
  282. #endif  
  283. };
  284.  
  285.  
  286. class AFX_EXT_CLASS CDateTimeControl : public CStatic
  287. {
  288. public:
  289.   CDateTimeControl();
  290.   virtual ~CDateTimeControl();
  291.  
  292.   BOOL SubclassEdit(UINT iCtlID, CWnd* pParentWnd);
  293.   BOOL SubclassEdit(HWND hEdit);
  294.   void SetFlags(DWORD dwFlags) { m_dwFlags = dwFlags; };
  295.  
  296. protected:
  297.   //{{AFX_VIRTUAL(CDateTimeControl)
  298.   //}}AFX_VIRTUAL
  299.  
  300.   //{{AFX_MSG(CDateTimeControl)
  301.   //}}AFX_MSG
  302.  
  303.   DECLARE_MESSAGE_MAP()
  304.  
  305.   BOOL AddEditButton();
  306.  
  307.   BOOL m_bSubclassed;
  308.   CDateButton m_Edit;
  309.   DWORD m_dwFlags;
  310. };
  311.  
  312.  
  313. class AFX_EXT_CLASS CDateControl : public CDateTimeControl
  314. {
  315. public:
  316. //Constructors / Destructors
  317.   EXPORT16 CDateControl();
  318.   virtual EXPORT16 ~CDateControl();
  319.  
  320. //Accessors / Mutators
  321.   void EXPORT16 SetValue(const CDate& value);
  322.   void EXPORT16 GetValue(CDate& value) { value = m_Value; };
  323.   
  324. protected:
  325.   //{{AFX_VIRTUAL(CDateControl)
  326.   //}}AFX_VIRTUAL
  327.  
  328.   //{{AFX_MSG(CDateControl)
  329.   afx_msg LRESULT OnEditClick(WPARAM, LPARAM);
  330.   afx_msg LRESULT OnDlgClose(WPARAM, LPARAM);
  331.   //}}AFX_MSG
  332.  
  333.   DECLARE_MESSAGE_MAP()
  334.  
  335.   CDate m_Value;
  336.   CCDateDlg* m_pDlg; //used to display modeless drop - down dialog
  337. };
  338.  
  339.  
  340. class AFX_EXT_CLASS CLTimeSpanControl : public CDateTimeControl
  341. {
  342. public:
  343. //Constructors / Destructors
  344.   EXPORT16 CLTimeSpanControl();
  345.   virtual EXPORT16 ~CLTimeSpanControl();
  346.  
  347. //Accessors / Mutators
  348.   void EXPORT16 SetValue(const CLTimeSpan& value);
  349.   void EXPORT16 GetValue(CLTimeSpan& value) { value = m_Value; };
  350.  
  351. protected:
  352.   //{{AFX_VIRTUAL(CLTimeSpanControl)
  353.   //}}AFX_VIRTUAL
  354.  
  355.   //{{AFX_MSG(CLTimeSpanControl)
  356.   afx_msg LRESULT OnEditClick(WPARAM, LPARAM);
  357.   afx_msg LRESULT OnDlgClose(WPARAM, LPARAM);
  358.   //}}AFX_MSG
  359.  
  360.   DECLARE_MESSAGE_MAP()
  361.  
  362.   CLTimeSpan m_Value;
  363.   CCLTimeSpanDlg* m_pDlg; //used to display modeless drop - down dialog
  364. };
  365.  
  366.  
  367. class AFX_EXT_CLASS CLTimeOfDayControl : public CDateTimeControl
  368. {
  369. public:
  370. //Constructors / Destructors
  371.   EXPORT16 CLTimeOfDayControl();
  372.   virtual EXPORT16 ~CLTimeOfDayControl();
  373.  
  374. //Accessors / Mutators
  375.   void EXPORT16 SetValue(const CLTimeOfDay& value);
  376.   void EXPORT16 GetValue(CLTimeOfDay& value) { value = m_Value; };
  377.  
  378. protected:
  379.   //{{AFX_VIRTUAL(CCLTimeOfDayControl)
  380.   //}}AFX_VIRTUAL
  381.  
  382.   //{{AFX_MSG(CLTimeOfDayControl)
  383.   afx_msg LRESULT OnEditClick(WPARAM, LPARAM);
  384.   afx_msg LRESULT OnDlgClose(WPARAM, LPARAM);
  385.   //}}AFX_MSG
  386.  
  387.   DECLARE_MESSAGE_MAP()
  388.  
  389.   CLTimeOfDay m_Value;
  390.   CCLTimeOfDayDlg* m_pDlg; //used to display modeless drop - down dialog
  391. };
  392.  
  393.  
  394. class AFX_EXT_CLASS CLDateControl : public CDateTimeControl
  395. {
  396. public:
  397. //Constructors / Destructors
  398.   EXPORT16 CLDateControl();
  399.   virtual EXPORT16 ~CLDateControl();
  400.  
  401. //Accessors / Mutators
  402.   void EXPORT16 SetValue(const CLDate& value);
  403.   void EXPORT16 GetValue(CLDate& value) { value = m_Value; };
  404.  
  405. protected:
  406.   //{{AFX_VIRTUAL(CLDateControl)
  407.   //}}AFX_VIRTUAL
  408.  
  409.   //{{AFX_MSG(CLDateControl)
  410.   afx_msg LRESULT OnEditClick(WPARAM, LPARAM);
  411.   afx_msg LRESULT OnDlgClose(WPARAM, LPARAM);
  412.   //}}AFX_MSG
  413.  
  414.   DECLARE_MESSAGE_MAP()
  415.  
  416.   CLDate m_Value;
  417.   CCLDateDlg* m_pDlg; //used to display modeless drop - down dialog
  418. };
  419.  
  420.  
  421. //MFC Data exchange routines
  422.  
  423. void AFX_EXT_API EXPORT16 DDX_CDateControl(CDataExchange* pDX, int nIDC, CDateControl& rCDateControl, DWORD dwFlags);
  424. void AFX_EXT_API EXPORT16 DDX_CLTimeSpanControl(CDataExchange* pDX, int nIDC, CLTimeSpanControl& rCLTimeSpanControl, DWORD dwFlags);
  425. void AFX_EXT_API EXPORT16 DDX_CLTimeOfDayControl(CDataExchange* pDX, int nIDC, CLTimeOfDayControl& rCLTimeOfDayControl, DWORD dwFlags);
  426. void AFX_EXT_API EXPORT16 DDX_CLDateControl(CDataExchange* pDX, int nIDC, CLDateControl& rCLDateControl, DWORD dwFlags);
  427.  
  428. void AFX_EXT_API EXPORT16 DDX_CDate(CDataExchange* pDX, CDateControl& rCDateControl, CDate& value);
  429. void AFX_EXT_API EXPORT16 DDV_MinMaxCDate(CDataExchange* pDX, CDate& value, CDate& minVal, CDate& maxVal);
  430. void AFX_EXT_API EXPORT16 DDV_GreaterThanCDate(CDataExchange* pDX, CDate& value, CDate& minVal);
  431. void AFX_EXT_API EXPORT16 DDV_LessThanCDate(CDataExchange* pDX, CDate& value, CDate& maxVal);
  432.  
  433. void AFX_EXT_API EXPORT16 DDX_CLTimeSpan(CDataExchange* pDX, CLTimeSpanControl& rCLTimeSpanControl, CLTimeSpan& value);
  434. void AFX_EXT_API EXPORT16 DDV_MinMaxCLTimeSpan(CDataExchange* pDX, CLTimeSpan& value, CLTimeSpan& minVal, CLTimeSpan& maxVal);
  435. void AFX_EXT_API EXPORT16 DDV_GreaterThanCLTimeSpan(CDataExchange* pDX, CLTimeSpan& value, CLTimeSpan& minVal);
  436. void AFX_EXT_API EXPORT16 DDV_LessThanCLTimeSpan(CDataExchange* pDX, CLTimeSpan& value, CLTimeSpan& maxVal);
  437.  
  438. void AFX_EXT_API EXPORT16 DDX_CLTimeOfDay(CDataExchange* pDX, CLTimeOfDayControl& rCLTimeOfDayControl, CLTimeOfDay& value);
  439. void AFX_EXT_API EXPORT16 DDV_MinMaxCLTimeOfDay(CDataExchange* pDX, CLTimeOfDay& value, CLTimeOfDay& minVal, CLTimeOfDay& maxVal);
  440. void AFX_EXT_API EXPORT16 DDV_GreaterThanCLTimeOfDay(CDataExchange* pDX, CLTimeOfDay& value, CLTimeOfDay& minVal);
  441. void AFX_EXT_API EXPORT16 DDV_LessThanCLTimeOfDay(CDataExchange* pDX, CLTimeOfDay& value, CLTimeOfDay& maxVal);
  442.  
  443. void AFX_EXT_API EXPORT16 DDX_CLDate(CDataExchange* pDX, CLDateControl& rCLDateControl, CLDate& value);
  444. void AFX_EXT_API EXPORT16 DDV_MinMaxCLDate(CDataExchange* pDX, CLDate& value, CLDate& minVal, CLDate& maxVal);
  445. void AFX_EXT_API EXPORT16 DDV_GreaterThanCLDate(CDataExchange* pDX, CLDate& value, CLDate& minVal);
  446. void AFX_EXT_API EXPORT16 DDV_LessThanCLDate(CDataExchange* pDX, CLDate& value, CLDate& maxVal);
  447.  
  448.  
  449. #endif //__DENTRY_H__
  450.  
  451.  
  452.  
  453.  
  454.                                         
  455.