⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calendarpage.cpp

📁 该时间管理是模仿酷派628手机上的时间管理书写其功能
💻 CPP
📖 第 1 页 / 共 4 页
字号:
	
	//窗体最大化
	//ShowWindow(SW_SHOWMAXIMIZED);	
	::SetWindowPos(m_hWnd,HWND_TOP,0,STATUS_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT - STATUS_HEIGHT,SWP_SHOWWINDOW);
	ModifyStyleEx(0, WS_EX_NODRAG);
	
	//设置控件的位置与大小
	SetPosAddSize();

	m_sticLunar.SetWindowPos(NULL,3,152,232,80, SWP_SHOWWINDOW);
	m_MonthctrlDate.SetMaxSelCount(2049);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


/**
************************************************************* 
* 函 数 名: OnSeleDateChange(NMHDR* pNMHDR, LRESULT* pResult)
* 描    述: 用户点击日历控件触发该事件
* 数 据 库: 无
* 数据库表: 无
* 输入参数: 无
* 输出参数: 无
* 返 回 值: 无
* 创 建 人: 袁军
* 日    期: 2007/06/01
* 修改记录: 
*     修改人      修改日期      修改描述
*************************************************************
*/ 

void CCalendarPage::OnSeleDateChange(NMHDR* pNMHDR, LRESULT* pResult)
{
	//如果用户在日历控件上有选择
	if ( NULL != pNMHDR )
	{
		LONG lSelectTime;
		LONG lResetTime;
		SYSTEMTIME stSet;

		CString strMsgInfo;

		//获取用户选择的值
		NMDAYSTATE *pSeleDate = (NMDAYSTATE*)pNMHDR;
		
		
		// 获得选择日期的阳历的年
		uiCalendarSolarYear  = pSeleDate->stStart.wYear;
		
        // 获得选择日期的阳历的月
		uiCalendarSolarMonth = pSeleDate->stStart.wMonth;

		// 获得选择日期的阳历的日
		uiCalendarSolarDay   = pSeleDate->stStart.wDay;

		m_iYear  = uiCalendarSolarYear;
		m_iMonth = uiCalendarSolarMonth;
		m_iDay   = uiCalendarSolarDay;
		
		// 由于CTime类型的大小有限定,所以直接用CTime类型进行比较不行
		// 判断年份是否合格
		lSelectTime = uiCalendarSolarYear*10000 + uiCalendarSolarMonth*100 + uiCalendarSolarDay;
		lResetTime  = BEGIN_YEAR*10000 + BEGIN_MONTH*100 + BEGIN_DAY;


		//注:该时间范围还没有具体确定
		// 如果年份小于能显示的最小年份,那么弹出无法显示阴历的提示框
		if ( lSelectTime < lResetTime )
		{
//			strMsgInfo.LoadString(IDS_CLNSHOWLUNARINFOFAIL1);

//			::MessageDlg(strMsgInfo,strMsgTitle);
			//AfxMessageBox(_T("只能在1950年到2050年之间"));
			// 为了突破CTime类型的限制,所以采用SYSTEMTIME类型
			stSet.wYear  = BEGIN_YEAR;
			stSet.wMonth = BEGIN_MONTH;
			stSet.wDay   = BEGIN_DAY;

		    ((CMonthCalCtrl*)GetDlgItem(IDC_MONTHCALDATE))->SetCurSel(&stSet);
			*pResult = 0;
			return;
		}

		lResetTime  = END_YEAR*10000 + END_MONTH*100 + END_DAY;

		// 如果年份大于能显示的最大年份,那么弹出无法显示阴历的提示框
		if ( lSelectTime > lResetTime )
		{
//			strMsgInfo.LoadString(IDS_CLNSHOWLUNARINFOFAIL2);

//			::MessageDlg(strMsgInfo,strMsgTitle);

			// 为了突破CTime类型的限制,所以采用SYSTEMTIME类型
			stSet.wYear  = END_YEAR;
			stSet.wMonth = END_MONTH;
			stSet.wDay   = END_DAY;

		    ((CMonthCalCtrl*)GetDlgItem(IDC_MONTHCALDATE))->SetCurSel(&stSet);
			*pResult = 0;
			return;
		}


		// 获得阳历对应的阴历日期
		int iRet = GetLunarDate();
    
		// 设定阴历显示信息文本的显示信息
		SetLunarStaticInfo(iRet);

		if ( -1 == iRet)
		{
			*pResult = 1;
		}
	}
	else // 该情况第一次的时候有用到,人为触发该函数
	{
		// 获得用户选择的时间
		SYSTEMTIME tSelectDate;
		m_MonthctrlDate.GetToday(&tSelectDate);
		m_MonthctrlDate.SetCurSel(&tSelectDate);

		// 获得选择日期的阳历的年、月、日
		uiCalendarSolarYear  = tSelectDate.wYear;
		uiCalendarSolarMonth = tSelectDate.wMonth;
		uiCalendarSolarDay   = tSelectDate.wDay; 

		m_iYear  = uiCalendarSolarYear;
		m_iMonth = uiCalendarSolarMonth;
		m_iDay   = uiCalendarSolarDay;

		// 获得阳历对应的阴历日期
		int iRet = GetLunarDate();
    
		// 设定阴历显示信息文本的显示信息
		SetLunarStaticInfo(iRet);		
	
		*pResult = 0;
	}
}

/******************************************************************************
* 函数名称: SetLunarStaticInfo
* 功能描述: 设定日期控件下的静态控件的显示信息
* 访问的表: 无
* 修改的表: 无
* 输入参数: int iFlag:是否显示阴历信息
* 输出参数: 无
* 返 回 值: 0:成功;-1:失败
* 其它说明: 
* 修改日期	   版本号     修改人	      修改内容
* ---------------------------------------------------------
* 2006/11/30   V1.0	      Dragon Cai	  创建该函数
******************************************************************************/
int CCalendarPage::SetLunarStaticInfo(int iFlag)
{
	if (-1 ==  iFlag )
	{
		CString strNoLunarInfo;
//		strNoLunarInfo.LoadString(IDS_CLNNOLUNARINFO);
		m_sticLunar.SetWindowText(_T("不能显示阴历信息"));
		return -1;
	}

	// 阴历年所对应的天干在汉字表中的位置
	int itempyearTG = 0;  

	// 阴历年所对应的地支在汉字表中的位置
	int itempyearDZ = 0; 
	
	// 阴历月所对应的汉字在列表中的位置
	int itempmonth = 0;   

	// TCHAR clunarcalendar[100] = {0};    // 存放阴历、节日等信息
	CString strLunarCalendar;
	CString strFeast;

	// 存放月的对应汉字或者空格
	TCHAR clunarmonth[6] = {0};         

	// 通过1901年的信息计算天干、地支
	itempyearTG = (uiCalendarLunarYear + 7 - BEGIN_YEAR) % 10;
	itempyearDZ = (uiCalendarLunarYear + 1 - BEGIN_YEAR) % 12;

	// 加上阴历年的信息
	/*_tcscat(clunarcalendar, _T("  农历:"));
	_tcscat(clunarcalendar, cTGname[itempyearTG]);
	_tcscat(clunarcalendar, cDZname[itempyearDZ]);
	_tcscat(clunarcalendar, cZXname[itempyearDZ]);
	_tcscat(clunarcalendar, _T("年"));*/

	strLunarCalendar = _T("  农历:");
	strLunarCalendar += cTGname[itempyearTG];
	strLunarCalendar += cDZname[itempyearDZ];
	strLunarCalendar += cZXname[itempyearDZ];
	strLunarCalendar += _T("年");

	// 判断是否闰月,然后加上月信息
	if ( ileapmonthflag > 0 )
	{
		_tcscat(clunarmonth, _T("闰"));
		_tcscat(clunarmonth, cmonthname[uiCalendarLunarMonth-1]);
	}
	else
	{
		_tcscat(clunarmonth, cmonthname[uiCalendarLunarMonth-1]);
		_tcscat(clunarmonth, _T("月"));
	}

	//_tcscat(clunarcalendar,clunarmonth);
	//_tcscat(clunarcalendar,cdayname[uiCalendarLunarDay-1]);

	strLunarCalendar += clunarmonth;
	strLunarCalendar += cdayname[uiCalendarLunarDay-1];
	strLunarTime = strLunarCalendar;
	// 加上星座
	//_tcscat(clunarcalendar, _T("\r\n"));
	//_tcscat(clunarcalendar, _T("  星座:"));

	strLunarCalendar += _T("\r\n");
	strLunarCalendar += _T("  星座:");


	int iXZPos;
	switch ( uiCalendarSolarMonth )
	{
	case 1:
		{
			if ( uiCalendarSolarDay >= 20 )
			{
				iXZPos = 1;
			}
			else
			{
				iXZPos = 12;
			}
			break;
		}
	case 2:
		{
			if ( uiCalendarSolarDay >= 19 )
			{
				iXZPos = 2;
			}
			else
			{
				iXZPos = 1;
			}
			break;
		}
	case 3:
		{
			if ( uiCalendarSolarDay >= 21 )
			{
				iXZPos = 3;
			}
			else
			{
				iXZPos = 2;
			}
			break;
		}
	case 4:
		{
			if ( uiCalendarSolarDay >= 20 )
			{
				iXZPos = 4;
			}
			else
			{
				iXZPos = 3;
			}
			break;
		}
	case 5:
		{
			if ( uiCalendarSolarDay >= 21 )
			{
				iXZPos = 5;
			}
			else
			{
				iXZPos = 4;
			}
			break;
		}
	case 6:
		{
			if ( uiCalendarSolarDay >= 21 )
			{
				iXZPos = 6;
			}
			else
			{
				iXZPos = 5;
			}
			break;
		}
	case 7:
		{
			if ( uiCalendarSolarDay >= 22 )
			{
				iXZPos = 7;
			}
			else
			{
				iXZPos = 6;
			}
			break;
		}
	case 8:
		{
			if ( uiCalendarSolarDay >= 23 )
			{
				iXZPos = 8;
			}
			else
			{
				iXZPos = 7;
			}
			break;
		}
	case 9:
		{
			if ( uiCalendarSolarDay >= 23 )
			{
				iXZPos = 9;
			}
			else
			{
				iXZPos = 8;
			}
			break;
		}
	case 10:
		{
			if ( uiCalendarSolarDay >= 23 )
			{
				iXZPos = 10;
			}
			else
			{
				iXZPos = 9;
			}
			break;
		}
	case 11:
		{
			if ( uiCalendarSolarDay >= 22 )
			{
				iXZPos = 11;
			}
			else
			{
				iXZPos = 10;
			}
			break;
		}
	case 12:
		{
			if ( uiCalendarSolarDay >= 22 )
			{
				iXZPos = 12;
			}
			else
			{
				iXZPos = 11;
			}
			break;
		}
	default: 
		{
			return -1;
		}
	}

	//_tcscat(clunarcalendar, cXZname[iXZPos-1]);

	strLunarCalendar += cXZname[iXZPos-1];

	// 加上节气
	//TCHAR wcTempJQDay[2] = {0};

	CString strTempJQDay;

	strLunarCalendar += _T("\r\n");
	strLunarCalendar += _T("  节气:");
	strLunarCalendar += cJQname[uiCalendarSolarMonth*2-2];
	strLunarCalendar += _T("(");

	strTempJQDay.Format(_T("%d"), GetFirstSolarTerm());


	strLunarCalendar += strTempJQDay;
	strLunarCalendar += _T("日),");
	strLunarCalendar += cJQname[uiCalendarSolarMonth*2-1];
	strLunarCalendar += _T("(");

	strTempJQDay.Format(_T("%d"), GetSecondSolarTerm());


	strLunarCalendar += strTempJQDay;
	strLunarCalendar += _T("日)");

	// 加上节日
	strLunarCalendar += _T("\r\n");
	strLunarCalendar += _T("  节日:");

	// 先是中国的传统节日
	// 查看是否有确定日子的节日
	int iTemp = uiCalendarLunarMonth * 100 + uiCalendarLunarDay; 
	
	// 用来处理第一个节日前不加分隔符
	int iCompartFlag = 0; 
	for ( int i = 0; i < LUNAR_FEAST_NUM; i++)
	{
		if (iTemp ==  iLunarSeq[i])
		{
			//_tcscat(clunarcalendar, cLunarFeast[i]);
			
			strFeast += cLunarFeast[i];

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -