123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- #if !defined(AFX_CALENDAR1_H__FD9A6DAF_8C3C_493C_AAD4_612134D8F6D4__INCLUDED_)
- #define AFX_CALENDAR1_H__FD9A6DAF_8C3C_493C_AAD4_612134D8F6D4__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif
- extern const WORD START_YEAR;
- extern const WORD END_YEAR;
- #define UM_SELCHANGE (WM_USER+101)
- class CCalendar : public CWnd
- {
- BOOL m_bMousePushDown;
- DWORD ticks;
- CFont m_font;
- private:
- WORD m_iYear, m_iMonth, m_iDay;
- CBitmap m_oBitMapList[42];
- CMenu m_oPopMenu;
-
- public:
- COLORREF m_dwBackColor, m_dwForeColor;
- COLORREF m_dwSelColor, m_dwSelForeColor;
- COLORREF m_dwTitleBkColor, m_dwTitleColor;
- CRect m_rect;
- CStringArray m_Array;
- public:
- CCalendar(WORD iYear, WORD iMonth, WORD iDay);
- CCalendar();
- virtual BOOL Create(RECT &rect, CWnd * pParentWnd, UINT nID);
-
- public:
- WORD GetYear(){return m_iYear;}
- WORD GetMonth(){return m_iMonth;}
- WORD GetDay(){return m_iDay;}
- void GetDate(WORD &iYear, WORD &iMonth, WORD &iDay);
- BOOL SetDate(WORD iYear, WORD iMonth, WORD iDay);
-
- protected:
- afx_msg void OnPaint();
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
- afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
-
- afx_msg void OnTitleBkColor();
- afx_msg void OnTitleColor();
- afx_msg void OnSelColor();
- afx_msg void OnForeColor();
- DECLARE_MESSAGE_MAP()
-
-
- public:
-
- static BOOL IsLeapYear(WORD iYear)
- {return !(iYear%4)&&(iYear%100) || !(iYear%400);}
-
-
- static WORD WeekDay(WORD iYear, WORD iMonth, WORD iDay);
-
-
- static WORD MonthDays(WORD iYear, WORD iMonth);
-
-
-
-
- static LONG LunarMonthDays(WORD iLunarYear, WORD iLunarMonth);
-
-
-
- static WORD LunarYearDays(WORD iLunarYear);
-
-
-
- static WORD GetLeapMonth(WORD iLunarYear);
-
-
- static void FormatLunarYear(WORD iYear, char *pBuffer);
-
-
- static void FormatMonth(WORD iMonth, char *pBuffer, BOOL bLunar = TRUE);
-
-
- static void FormatLunarDay(WORD iDay, char *pBuffer);
-
-
- static LONG CalcDateDiff(WORD iEndYear, WORD iEndMonth, WORD iEndDay,
- WORD iStartYear = START_YEAR,
- WORD iStartMonth =1, WORD iStartDay =1);
-
-
-
- static WORD GetLunarDate(WORD iYear, WORD iMonth, WORD iDay,
- WORD &iLunarYear, WORD &iLunarMonth, WORD &iLunarDay);
-
- public:
- virtual ~CCalendar();
-
- private:
- void l_InitData();
-
-
- static void l_CalcLunarDate(WORD &iYear, WORD &iMonth ,WORD &iDay, LONG iSpanDays);
-
- static WORD l_GetLunarHolDay(WORD iYear, WORD iMonth, WORD iDay);
-
- WORD l_CalcSelectDay(POINT * pt);
- void l_PaintTitle(CPaintDC &dc);
- void l_PaintDate(CPaintDC &dc);
- inline void l_PaintOneDay(
- CPaintDC &dc,
- CDC &imgdc,
- WORD &iDay,
- WORD &iLunarYear,
- WORD &iLunarMonth,
- WORD &iLuanrDay,
- LONG startx,
- LONG starty);
- inline void l_PaintOneDay_1(
- CPaintDC &dc,
- CDC &imgdc,
- WORD &iDay,
- WORD &iLunarYear,
- WORD &iLunarMonth,
- WORD &iLuanrDay,
- LONG startx,
- LONG starty);
- };
- #endif
|