DateTimeCtrl.h
上传用户:lxjxxg
上传日期:2007-01-02
资源大小:42k
文件大小:4k
源码类别:

工具条

开发平台:

Visual C++

  1. #if !defined(AFX_DATETIMECTRL_H__D4DC9621_54F2_11D1_ABBA_00A0243D1382__INCLUDED_)
  2. #define AFX_DATETIMECTRL_H__D4DC9621_54F2_11D1_ABBA_00A0243D1382__INCLUDED_
  3. #if _MSC_VER >= 1000
  4. #pragma once
  5. #endif // _MSC_VER >= 1000
  6. // DateTimeCtrl.h : header file
  7. //
  8. // MFC Wrapper class for the IE3 DateTimePicker control
  9. //
  10. // Written by Chris Maunder (chrismaunder@codeguru.com)
  11. // Copyright (c) 1998.
  12. //
  13. // This code is free
  14. //
  15. // This file is provided "as is" with no expressed or implied warranty.
  16. // The author accepts no liability if it causes any damage to your
  17. // computer, causes your pet cat to fall ill, increases baldness or
  18. // makes you car start emitting strange noises when you start it up.
  19. //
  20. // Expect bugs.
  21. // 
  22. // Please use and enjoy. Please let me know of any bugs/mods/improvements 
  23. // that you have found/implemented and I will fix/incorporate them into this
  24. // file. 
  25. //
  26. // History: 15 April 1998 - Modifications to workaround multiple DTP notifications
  27. //                          causing infinite loops. Added virtual fns for messages.
  28. //
  29. /////////////////////////////////////////////////////////////////////////////
  30. void AFXAPI DDX_DateTime(CDataExchange *pDX, int nIDC, SYSTEMTIME &SysTime);
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CDateTimeCtrl window
  33. class CDateTimeCtrl : public CWnd
  34. {
  35. // Construction 
  36. public:
  37.     CDateTimeCtrl();
  38.     virtual ~CDateTimeCtrl();
  39.     BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
  40. // Operations
  41. public:
  42.     CTime GetDateTime();
  43.     COleDateTime GetOleDateTime();
  44.     BOOL  SetDateTime(const CTime& time);
  45.     BOOL  SetDateTime(const COleDateTime& time);
  46. // Attributes
  47. public:
  48.     COLORREF SetMonthCalColour(int nColIndex, COLORREF colour);
  49.     COLORREF GetMonthCalColour(int nColIndex);
  50.     BOOL     SetFormat(LPCTSTR szFmt);
  51.     void     SetMonthCalFont(CFont& font, BOOL bRedraw = TRUE);
  52.     CFont*   GetMonthCalFont();
  53.     BOOL     SetRange(CTime* pMinTime, CTime* pMaxTime);
  54.     BOOL     SetRange(COleDateTime* pMinTime, COleDateTime* pMaxTime);
  55.     DWORD    GetRange(CTime* pMinTime, CTime* pMaxTime);
  56.     DWORD    GetRange(COleDateTime* pMinTime, COleDateTime* pMaxTime);
  57. // Overrides
  58.     // ClassWizard generated virtual function overrides
  59.     //{{AFX_VIRTUAL(CDateTimeCtrl)
  60.     //}}AFX_VIRTUAL
  61.     virtual void DoDateTimeChange();
  62. // Implementation
  63. protected:
  64.     void  SysTimeFromCTime(const CTime& time, SYSTEMTIME *SysTime);
  65.     void  SysTimeFromCOleDateTime(const COleDateTime& time, SYSTEMTIME *SysTime);
  66.     COleDateTime GetSystemTime();
  67.     BOOL  SetSystemTime(const SYSTEMTIME& time);
  68.     BOOL  SetSystemTime(const COleDateTime& time);
  69.     BOOL  SetSystemTime(const CTime& time);
  70.     COleDateTime m_CurrentTime;
  71.     static BOOL nCommonControlsInitialised;
  72.     BOOL   m_bDroppedDown;
  73.     BOOL   m_bReportDateChangeWhileDropped;
  74.     // Generated message map functions
  75. protected:
  76.     //{{AFX_MSG(CDateTimeCtrl)
  77.     //}}AFX_MSG
  78.     virtual BOOL OnDateTimeChangeNotify(LPNMDATETIMECHANGE dtmh, LRESULT* result);
  79.     virtual BOOL OnDropDown(NMHDR * pNotifyStruct, LRESULT* result);
  80.     virtual BOOL OnCloseUp(NMHDR * pNotifyStruct, LRESULT* result);
  81.     virtual BOOL OnFormat(NMDATETIMEFORMAT* lpNMFormat, LRESULT* pResult);
  82.     virtual BOOL OnFormatQuery(NMDATETIMEFORMATQUERY* lpNMFormat, LRESULT* pResult);
  83.     virtual BOOL OnUserString(NMDATETIMESTRING* lpDTstring, LRESULT* pResult);
  84.     virtual BOOL OnKeyDown(NMDATETIMEWMKEYDOWN* lpDTKeystroke, LRESULT* pResult);
  85.     DECLARE_MESSAGE_MAP()
  86. };
  87. /////////////////////////////////////////////////////////////////////////////
  88. //{{AFX_INSERT_LOCATION}}
  89. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  90. #endif // !defined(AFX_DATETIMECTRL_H__D4DC9621_54F2_11D1_ABBA_00A0243D1382__INCLUDED_)