8万年历

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

程序设计综合实践报告(C语言)项目名称:桌面万年历班级:信息与计算2010级1班姓名:郭玉豪学号:201001051506山东科技大学信息科学与工程学院2012年12月2目录1.项目概述··············································································31.1需求陈述········································································31.2开发技术、环境与工具······················································32.软件需求··············································································42.1功能性需求·····································································43.软件架构设计········································································44.软件详细设计与实现·······························································54.1主要模块的流程图····························································54.2核心代码········································································55总结与体会·········································································215.1遇到的问题与解决途径·····················································215.2心得体会······································································2231.项目概述1.1需求陈述本项目是桌面时钟与万年历的实现,时钟可以实现年月日、时分秒、天干地支及生肖的输出,并且还能显示阴历的日期。右击时钟会选中日历会出现日历的输出。日历上显示今天阳历的年月日、阴历的年月日、干支年,生肖及图片,并且右边还有年和月的加减,点击今日按钮时间就立刻转的电脑本地的日期。日历本身显现阳历与阴历,和国家法定节假日。在日历的右上角有个取消按钮。为了增加日历的外观,增加了换肤按钮,使得本万年历更加人性化。1.2开发技术、环境与工具1.2.1(DrawClockText)此函数给出了表盘的的年月日与时分秒、干支年和生效年的输出调用。1.2.2(DrawCalendar)此函数是日历表的输出函数,它实现了日历表的输出阳历时间和阴历时间,生肖与干支年的输出。1.2.3(用到的API函数)API函数参考:GetLocalTime:获得当前时间(公历:年、月、日、周);MoveToEx:移动划线的起点;LineTo:绘制到某一点;SetTextColor:设置要绘制的文字颜色;TextOut:绘制文字;GetLocalTime:获得当前系统的本地时间;结构体类型参考:SYSTEMTIME:描述时间类型,包括年月日、时分秒、周;系统调用:根据已给样本的提示,绘制了日历的矩形背景,并且也根据公历日期来计算出农历日期,并且标注了一些重要节日,像“春节、元宵节、国庆节、端午节、中秋节”等一些重要的节日,并且将节假日的字体颜色设置为红色,然后又写了获取当前系统本机时间的函数,成功的获得了当前本机的时间,这在日历中就可以观察到。41.2.4本程序是在基于c语言下实现的,用到的工具就是microsoftvisualstudio2008。2.软件需求2.1功能性需求2.1.1voidSunToLunar(conststDateTime*pSunDay,stDateTime*pLunarDay)此调用函数实现了将一个公立日期转为一个阴历日期,目前此函数还有一些错误。2.1.2intGetDayOfWeek(conststDateTime*pSunDay)此函数将一个阳历日期输进去,判断这一天为星期几,然后返回一个整型数据。2.1.3voidDrawCalendar(HDChDC)此函数是是日历表的输出,标出了当天时间,并且在每天下都对应着当天的阴历时间。2.1.4voidCalendarButtonEvent(UINTnID)此函数实现了日历的年份和月份按钮的增加或者减少。2.1.5voidDrawClockText(HDChDC)此函数实现了表盘的输出,年月日时分秒,生效年,干支年,星期几。3.软件架构设计设计该万年历建了一个项目CalendarApp,该项目下有个头文件,源文件,资源文件,源文件中包括主程序main.c以及被调用的程序,资源文件中包括设置的万年历的外观,按钮设置……。该软件调用外部图片,图片在image中。在日期设置上:(1)根据公历日期获得农历日期,调用判断是不是闰年的函数,把一年中的农历所有月份的天数分为四5类(28,29,30,31)。(2)用FOR循环输出各月份的日历,并把周末的字体设为红色。其余为黑色。(3)在钟表上获得当前本地的系统时间。(5)显示出星期、天干地支及农历日期。详细设计过程:1、首先绘制日历的矩形背景,用CreateSolidBrush(函数做出矩形的背景颜色,在日历的上端和下端分别输出阳历的年月份,及阴历的天干地支年等。2、判断农历的每月有多少天,调用判断是否为闰年的函数,若为闰年,则定义二月为29天,通过一switch函数输出十二个月的天数。3、调用公历转为农历的函数并用for循环获得每日的农历日期,并调用CreateSolidBrush(函数标出当天的日期,并设置了五个法定节假日提醒。4、对日历上的几个按钮进行设置,使得当年月份发生改变时,日历表可以正常显示。5、获得本地系统时间,在表盘上的正确位置输出当天的年月日(调用CreateFont函数按角度输出)及当地时间和星期。6、用指针数组存放十二个月的英文和星期的英文缩写。4.软件详细设计与实现4.1主要模块的流程图流程图为阳历和阴历的转换过程示意图。6获得当日公历日期输出当日的农历日期判断该月的天数输出星期几输出天地干支和生肖日历绘制判断是否为节假日4.2核心代码#includepublic.h/**********************************************************API函数参考:GetLocalTime:获得当前时间(公历:年、月、日、周)MoveToEx:移动划线的起点LineTo:绘制到某一点SetTextColor:设置要绘制的文字颜色TextOut:绘制文字GetLocalTime:获得当前系统的本地时间结构体类型参考:SYSTEMTIME:描述时间类型,包括年月日、时分秒、周*********************************************************7*/HINSTANCEg_hInst;//保存操作系统传递进来的应用程序实例句柄typedefstruct_stDateTime{intnYear;intnMonth;intnDay;}stDateTime;//定义表格,存储年-2099年的农历信息:每年的大小月、闰月信息、春节所在的公历日期unsignedintLunarCalendarTable[199]={0x04AE53,0x0A5748,0x5526BD,0x0D2650,0x0D9544,0x46AAB9,0x056A4D,0x09AD42,0x24AEB6,0x04AE4A,/*1901-1910*/0x6A4DBE,0x0A4D52,0x0D2546,0x5D52BA,0x0B544E,0x0D6A43,0x296D37,0x095B4B,0x749BC1,0x049754,/*1911-1920*/0x0A4B48,0x5B25BC,0x06A550,0x06D445,0x4ADAB8,0x02B64D,0x095742,0x2497B7,0x04974A,0x664B3E,/*1921-1930*/0x0D4A51,0x0EA546,0x56D4BA,0x05AD4E,0x02B644,0x393738,0x092E4B,0x7C96BF,0x0C9553,0x0D4A48,/*1931-1940*/0x6DA53B,0x0B554F,0x056A45,0x4AADB9,0x025D4D,0x092D42,0x2C95B6,0x0A954A,0x7B4ABD,0x06CA51,/*1941-1950*/0x0B5546,0x555ABB,0x04DA4E,0x0A5B43,0x352BB8,0x052B4C,0x8A953F,0x0E9552,0x06AA48,0x6AD53C,/*1951-1960*/0x0AB54F,0x04B645,0x4A5739,0x0A574D,0x052642,0x3E9335,0x0D9549,0x75AABE,0x056A51,0x096D46,/*1961-1970*/0x54AEBB,0x04AD4F,0x0A4D43,0x4D26B7,0x0D254B,0x8D52BF,0x0B5452,0x0B6A47,0x696D3C,0x095B50,/*1971-1980*/0x049B45,0x4A4BB9,0x0A4B4D,0xAB25C2,0x06A554,0x06D449,0x6ADA3D,0x0AB651,0x093746,0x5497BB,/*1981-1990*/0x04974F,0x064B44,0x36A537,0x0EA54A,0x86B2BF,0x05AC53,0x0AB647,0x5936BC,0x092E50,0x0C9645,/*1991-2000*/0x4D4AB8,0x0D4A4C,0x0DA541,0x25AAB6,0x056A49,0x7AADBD,0x025D52,0x092D47,0x5C95BA,0x0A954E,/*2001-2010*/0x0B4A43,0x4B5537,0x0AD54A,0x955ABF,0x04BA53,0x0A5B48,0x652BBC,0x052B50,0x0A9345,0x474AB9,/*2011-2020*/0x06AA4C,0x0AD541,0x24DAB6,0x04B64A,0x69573D,0x0A4E51,0x0D2646,0x5E933A,0x0D534D,0x05AA43,/*2021-2030*/0x36B537,0x096D4B,0xB4AEBF,0x04AD53,0x0A4D48,0x6D25BC,0x0D254F,0x0D5244,0x5DAA38,0x0B5A4C,/*2031-2040*/0x056D41,0x24ADB6,0x049B4A,0x7A4BBE,0x0A4B51,0x0AA546,0x5B52BA,0x06D24E,0x0ADA42,0x355B37,/*2041-2050*/0x09374B,0x8497C1,0x049753,0x064B48,0x66A53C,0x0EA54F,0x06B244,0x4AB638,0x0AAE4C,0x092E42,/*2051-2060*/80x3C9735,0x0C9649,0x7D4ABD,0x0D4A51,0x0

1 / 22
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功