123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- #include "stdafx.h"
- #include "ylgl.h"
- #include "CalendarFrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #define IDC_YEAREDIT 101
- #define IDC_CALENDARFRM 106
- #define IDC_CALENDAR 107
- CCalendarFrm::CCalendarFrm()
- {
- }
- CCalendarFrm::~CCalendarFrm()
- {
- }
- #define IDC_MONTHSELECT 102
- #define IDC_YEARSELECT 103
- #define IDC_BUTTODAY 105
- BEGIN_MESSAGE_MAP(CCalendarFrm, CWnd)
- ON_WM_PAINT()
- ON_WM_CREATE()
- ON_MESSAGE(UM_SELCHANGE, OnSelChange)
- END_MESSAGE_MAP()
- BOOL CCalendarFrm::Create(RECT &rect, CWnd * pParentWnd, UINT nID)
- {
- CString szClassName = AfxRegisterWndClass(CS_CLASSDC|CS_SAVEBITS|CS_HREDRAW|CS_VREDRAW, 0, 0, 0);
-
-
-
-
- if(!CWnd::CreateEx( 0, szClassName, _T(""),WS_DLGFRAME|WS_CHILD|WS_VISIBLE|WS_TABSTOP, rect, pParentWnd, nID, NULL))
- return FALSE;
-
- UpdateWindow();
- l_CreateDispFont();
- return TRUE;
- }
- void CCalendarFrm::l_PaintToday(CPaintDC &dc)
- {
- }
- void CCalendarFrm::l_PaintBorder(CPaintDC &dc)
- {
- }
- void CCalendarFrm::l_PaintChineseInfo(CPaintDC &dc)
- {
- }
- void CCalendarFrm::OnPaint()
- {
- CPaintDC dc(this);
- dc.SelectObject(GetDispFont());
- }
- int CCalendarFrm::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CWnd::OnCreate(lpCreateStruct) == -1) return -1;
-
-
- CRect rect;
- GetClientRect(&rect);
-
-
- m_oCalendar.m_rect = m_rect;
- if(!m_oCalendar.Create(m_rect, this, IDC_CALENDAR))
- return -1;
-
- #define LEFT_X 2
- #define TOP_Y 2
- #define WIDTH 90
- #define HEIGHT 22
-
-
-
-
-
- #undef LEFT_X
- #undef TOP_Y
- #undef WIDTH
- #undef HEIGHT
-
-
-
- return 0;
- }
- void CCalendarFrm::OnSelChange(LONG iYearMonth, LONG iDay)
- {
- Invalidate(FALSE);
- }
- void CCalendarFrm::DateChange2(LONG iYear2, LONG iMonth2, LONG iDay2)
- {
- WORD iYear, iDay, iMonth;
- m_oCalendar.GetDate(iYear, iMonth, iDay);
-
- if(iMonth != iMonth2 || iYear != iYear2 || iDay !=iDay2)
- {
- if(iDay2 > CCalendar::MonthDays(iYear2, iMonth2))
- iDay2 = CCalendar::MonthDays(iYear2, iMonth2);
- m_oCalendar.SetDate(iYear2, iMonth2, iDay2);
- Invalidate();
- }
- }
- void CCalendarFrm::DateChange(LONG iYear2, LONG iMonth2)
- {
- WORD iYear, iDay, iMonth;
- m_oCalendar.GetDate(iYear, iMonth, iDay);
-
- if(iMonth != iMonth2 || iYear != iYear2)
- {
- if(iDay > CCalendar::MonthDays(iYear2, iMonth2))
- iDay = CCalendar::MonthDays(iYear2, iMonth2);
- m_oCalendar.SetDate(iYear2, iMonth2, iDay);
- Invalidate();
- }
- }
- void CCalendarFrm::OnMonthChange()
- {
-
- }
- void CCalendarFrm::OnYearChange()
- {
- }
- void CCalendarFrm::OnTodayClick()
- {
- }
- void CCalendarFrm::l_CreateDispFont()
- {
- static LOGFONT logFont;
- memset(&logFont, 0 ,sizeof(logFont));
- #if 1
- logFont.lfHeight = 16;
- logFont.lfWeight = FW_NORMAL;
- logFont.lfWidth = 0;
- logFont.lfCharSet = GB2312_CHARSET;
- logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
- logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- logFont.lfQuality = PROOF_QUALITY;
- logFont.lfPitchAndFamily = VARIABLE_PITCH|FF_ROMAN;
- strcpy(logFont.lfFaceName, "Disp Font");
- #else
- logFont.lfHeight = 24;
- logFont.lfWeight = FW_NORMAL;
- logFont.lfWidth = 0;
- logFont.lfCharSet = GB2312_CHARSET;
- logFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
- logFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- logFont.lfQuality = PROOF_QUALITY;
- logFont.lfPitchAndFamily = VARIABLE_PITCH|FF_ROMAN;
- strcpy(logFont.lfFaceName, "Disp Font");
- #endif
- m_oDispFont.CreateFontIndirect(&logFont);
- SetFont(&m_oDispFont, FALSE);
- }
|