如何用AU3开发一个日历
本帖最后由 Windows8 于 2012-5-27 14:54 编辑最近要单独做一个大工程,想开发一个日历,像日历控件一样,但它太小了,我要一个全屏的,不需要农历(如果有能力的话劳驾帮帮忙),只要有星期就行。不用万年历,从2010~2020十年。主要是想要Merto风格。那位高人能做出来,感谢帮忙?
PS的概念图PS的概念图
非常感谢! 额额 额,楼主的提问交流。。。。 回复 1# Windows8
既然你连大工程都做得出来,这样的小样功能,对你来说难道不是小菜吗? PS的概念图很想windows 8的风格嘛,试试可不可以从Windows 8中提取吧! 这个效果图要P的好 本帖最后由 298311657 于 2012-5-28 00:46 编辑
对于伸手党,我是很鄙视的!不过刚好我无聊,就随便写一个玩。
#cs ____________________________________
Au3 版本: 3.3.9.4
脚本作者: CrossDoor
电子邮件: 382869232@qq.com
QQ/TM: 382869232
脚本版本: 0.0.0.0
脚本功能: 万年历
#ce _______________脚本开始_________________
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#Include <Date.au3>
#include <GuiEdit.au3>
;~ Global $aMonthName = ["01月","02月","03月","04月","05月","06月","07月","08月","09月","10月","11月","12月"]
Global $aWeekName = ["周日","周一","周二","周三","周四","周五","周六"]
Global $aDayName
Global $hFocusText
$hForm = GUICreate("日历控件",600,400,-1,-1,$WS_POPUP)
GUISetBkColor(0x009944)
GUICtrlCreateLabel("○",30,12,50,50)
GUICtrlSetFont(-1, 42, 800)
GUICtrlSetColor(-1,0xFEFEFE)
GUICtrlSetBkColor(-1,-2)
GUICtrlCreateLabel("←",39,19,50,50)
GUICtrlSetFont(-1, 32, 800)
GUICtrlSetColor(-1,0xFEFEFE)
GUICtrlSetBkColor(-1,-2)
GUICtrlCreateLabel("日历",90,17,250,45)
GUICtrlSetFont(-1, 35, 800)
GUICtrlSetColor(-1,0xFEFEFE)
GUICtrlSetBkColor(-1,-2)
Global $hCalendarText = GUICtrlCreateLabel(GetDate(),70,75,380,25)
GUICtrlSetFont(-1, 19, 800)
GUICtrlSetColor(-1,0xFEFEFE)
GUICtrlSetBkColor(-1,-2)
Global $hPrevText = GUICtrlCreateLabel("<",95,120,15,20)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xDFDFDF)
GUICtrlSetBkColor(-1,-2)
GUICtrlSetCursor(-1, 0)
Global $hYearText = GUICtrlCreateInput(@YEAR,230,117,58,25)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xDFDFDF)
GUICtrlSetBkColor(-1,0x009944)
GUICtrlSetLimit(-1,4)
GUICtrlCreateLabel("年",288,120,20,25)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xDFDFDF)
GUICtrlSetBkColor(-1,-2)
Global $hMonthText = GUICtrlCreateInput(@MON,308,117,32,25)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xDFDFDF)
GUICtrlSetBkColor(-1,0x009944)
GUICtrlSetLimit(-1,2)
GUICtrlCreateLabel("月",340,120,20,25)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xDFDFDF)
GUICtrlSetBkColor(-1,-2)
Global $hNextText = GUICtrlCreateLabel(">",485,120,15,20)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xDFDFDF)
GUICtrlSetBkColor(-1,-2)
GUICtrlSetCursor(-1, 0)
For $i = 0 To 6
GUICtrlCreateLabel($aWeekName[$i],90+$i*60,155,50,22,$SS_CENTER)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xFEFEFE)
GUICtrlSetBkColor(-1,-2)
Next
Local $k=1
For $i = 1 To 6
For $j =0 To 6
$aDayName[$k-1] = GUICtrlCreateLabel("",90+$j*60,155+$i*30,50,22,$SS_CENTER)
GUICtrlSetFont(-1, 16, 800)
GUICtrlSetColor(-1,0xFEFEFE)
GUICtrlSetBkColor(-1,-2)
$k+=1
Next
Next
SetCalendar(@YEAR, @MON)
GUICtrlSetState($aDayName,$GUI_FOCUS)
GUISetState()
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
AdlibRegister("GetDate", 60000)
Do
Until GUIGetMsg() = -3
AdlibUnRegister("SetDate")
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
Local $iIDFrom, $iCode, $iYear, $iMonth
$iIDFrom = BitAND($iwParam, 0x0000FFFF)
$iCode = BitShift($iwParam, 16)
Switch $iIDFrom
Case $hYearText,$hMonthText
Switch $iCode
Case $EN_UPDATE
$iYear = Int(GUICtrlRead($hYearText))
$iMonth = Int(GUICtrlRead($hMonthText))
If SetCalendar($iYear, $iMonth) Then
If $iMonth < 10 Then GUICtrlSetData($hMonthText,"0"&$iMonth)
EndIf
Case $EN_SETFOCUS
$hFocusText = $iIDFrom
Case $EN_KILLFOCUS
$hFocusText = ""
EndSwitch
Case $hPrevText
$iYear = Int(GUICtrlRead($hYearText))
$iMonth = Int(GUICtrlRead($hMonthText))
If $hFocusText = $hYearText Then
$iYear-=1
GUICtrlSetData($hYearText,$iYear)
SetCalendar($iYear, $iMonth)
Else
$iMonth-=1
If $iMonth < 1 Then
$iMonth = 12
$iYear-=1
GUICtrlSetData($hYearText,$iYear)
EndIf
GUICtrlSetData($hMonthText,$iMonth)
If SetCalendar($iYear, $iMonth) Then
If $iMonth < 10 Then GUICtrlSetData($hMonthText,"0"&$iMonth)
EndIf
EndIf
Case $hNextText
$iYear = Int(GUICtrlRead($hYearText))
$iMonth = Int(GUICtrlRead($hMonthText))
If $hFocusText = $hYearText Then
$iYear+=1
GUICtrlSetData($hYearText,$iYear)
SetCalendar($iYear, $iMonth)
Else
$iMonth+=1
If $iMonth > 12 Then
$iMonth = 1
$iYear+=1
GUICtrlSetData($hYearText,$iYear)
EndIf
GUICtrlSetData($hMonthText,$iMonth)
If SetCalendar($iYear, $iMonth) Then
If $iMonth < 10 Then GUICtrlSetData($hMonthText,"0"&$iMonth)
EndIf
EndIf
Case $hCalendarText
SetCalendar(@YEAR, @MON)
GUICtrlSetData($hYearText,@YEAR)
GUICtrlSetData($hMonthText,@MON)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Func SetCalendar($iYear, $iMonth)
If $iYear < 999 Or $iYear > 9998 Or $iMonth < 1 And $iMonth > 12 Then Return False
Local $k=1, $l = 0, $iWeekday = _DateToDayOfWeek($iYear, $iMonth, 1)
Local $iDays = _DateDaysInMonth($iYear, $iMonth)
For $i = 1 To 6
For $j =0 To 6
If $k >= $iWeekday And $l < $iDays Then
$l+=1
GUICtrlSetData($aDayName[$k-1],$l)
Else
GUICtrlSetData($aDayName[$k-1],"")
EndIf
If @YEAR = $iYear And @MDAY = $l And @MON = $iMonth Then
GUICtrlSetColor($aDayName[$k-1], 0xFFA0A0)
Else
GUICtrlSetColor($aDayName[$k-1], 0xFEFEFE)
EndIf
$k+=1
Next
Next
Return True
EndFunc
Func SetDate()
GUICtrlSetData($hCalendarText, GetDate())
EndFunc
Func GetDate()
If @HOUR > 12 Then
Return (@YEAR & "年 " & @MON & "月 " & @MDAY & "日 下午 " & @HOUR & ":" & @MIN)
Else
Return (@YEAR & "年 " & @MON & "月 " & @MDAY & "日 上午 " & @HOUR & ":" & @MIN)
EndIf
EndFunc
Func WM_NCHITTEST($HWND, $IMSG, $IWPARAM, $ILPARAM)
If ($HWND = $hForm) And ($IMSG = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc
LS真厉害,一下子就写出来了 LS 厉害,直接就写出来了{:face (190):} 回复 6# 298311657
楼上的代码值得参考 果然厉害啊 表示 上面的代码 两个文本框不能直接修改 回复 6# 298311657
真帅气 回复 6# 298311657
太厉害了,我觉得那个做大工程的包工头要给你一部分工程费用,你觉得呢? 回复 13# xms77
恩,这个可以有,哈哈 回复 6# 298311657
太厉害啦{:face (88):}
页:
[1]
2