创建月份日历控件
#Include <GuiMonthCal.au3>
_GUICtrlMonthCal_Create($hWnd, $iX, $iY[, $iStyle = 0x00000000[, $iExStyle = 0x00000000]])
$hWnd | 父窗或所有者窗口句柄 |
$iX | 控件的水平位置 |
$iY | 控件的垂直位置 |
$iStyle | [可选参数] 控件样式: $MCS_DAYSTATE - 控件将发送 $MCN_GETDAYSTATE 通知消息 要求有关天应以粗体显示 $MCS_MULTISELECT - 允许用户选择控件的日期范围 $MCS_WEEKNUMBERS - 控件将在日历行的左侧显示周数 $MCS_NOTODAYCIRCLE - 控件将不对“今天”日期作重圆点标示 $MCS_NOTODAY - 控件将不在底部显示“今天”日期 [可选参数] 强制: $WS_CHILD, $WS_VISIBLE |
$iExStyle | [可选参数] 控件扩展样式(译注:原文无相关说明) |
成功: | 返回月日历窗口句柄 |
失败: | 返回 0 |
#include <GUIConstantsEx.au3>
#include <GuiMonthCal.au3>
#include <WindowsConstants.au3>
$Debug_MC = False ; Check ClassName being passed to MonthCal functions, set to True and use a handle to another control to see it work
Global $hMonthCal
_Main()
Func _Main()
Local $hGUI
; 创建 GUI
$hGUI = GUICreate("Month Calendar Create", 400, 300)
$hMonthCal = _GUICtrlMonthCal_Create($hGUI, 4, 4, $WS_BORDER)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hMonthCal
Switch $iCode
Case $MCN_GETDAYSTATE ; Sent by a month calendar control to request information about how individual days should be displayed
$tInfo = DllStructCreate($tagNMDAYSTATE, $ilParam)
_DebugPrint("$MCN_GETDAYSTATE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @LF & _
"-->Month:" & @TAB & DllStructGetData($tInfo, "Month") & @LF & _
"-->DOW:" & @TAB & DllStructGetData($tInfo, "DOW") & @LF & _
"-->Day:" & @TAB & DllStructGetData($tInfo, "Day") & @LF & _
"-->Hour:" & @TAB & DllStructGetData($tInfo, "Hour") & @LF & _
"-->Minute:" & @TAB & DllStructGetData($tInfo, "Minute") & @LF & _
"-->Second:" & @TAB & DllStructGetData($tInfo, "Second") & @LF & _
"-->MSecond:" & @TAB & DllStructGetData($tInfo, "MSecond") & @LF & _
"-->DayState:" & @TAB & DllStructGetData($tInfo, "DayState") & @LF & _
"-->pDayState:" & @TAB & DllStructGetData($tInfo, "pDayState"))
; Address of an array of MONTHDAYSTATE (DWORD bit field that holds the state of each day in a month)
; Each bit (1 through 31) represents the state of a day in a month. If a bit is on, the corresponding day will
; be displayed in bold; otherwise it will be displayed with no emphasis.
; 没有返回值
Case $MCN_SELCHANGE ; Sent by a month calendar control when the currently selected date or range of dates changes
$tInfo = DllStructCreate($tagNMSELCHANGE, $ilParam)
_DebugPrint("$MCN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->BegYear:" & @TAB & DllStructGetData($tInfo, "BegYear") & @LF & _
"-->BegMonth:" & @TAB & DllStructGetData($tInfo, "BegMonth") & @LF & _
"-->BegDOW:" & @TAB & DllStructGetData($tInfo, "BegDOW") & @LF & _
"-->BegDay:" & @TAB & DllStructGetData($tInfo, "BegDay") & @LF & _
"-->BegHour:" & @TAB & DllStructGetData($tInfo, "BegHour") & @LF & _
"-->BegMinute:" & @TAB & DllStructGetData($tInfo, "BegMinute") & @LF & _
"-->BegSecond:" & @TAB & DllStructGetData($tInfo, "BegSecond") & @LF & _
"-->BegMSeconds:" & @TAB & DllStructGetData($tInfo, "BegMSeconds") & @LF & _
"-->EndYear:" & @TAB & DllStructGetData($tInfo, "EndYear") & @LF & _
"-->EndMonth:" & @TAB & DllStructGetData($tInfo, "EndMonth") & @LF & _
"-->EndDOW:" & @TAB & DllStructGetData($tInfo, "EndDOW") & @LF & _
"-->EndDay:" & @TAB & DllStructGetData($tInfo, "EndDay") & @LF & _
"-->EndHour:" & @TAB & DllStructGetData($tInfo, "EndHour") & @LF & _
"-->EndMinute:" & @TAB & DllStructGetData($tInfo, "EndMinute") & @LF & _
"-->EndSecond:" & @TAB & DllStructGetData($tInfo, "EndSecond") & @LF & _
"-->EndMSeconds:" & @TAB & DllStructGetData($tInfo, "EndMSeconds"))
; 没有返回值
Case $MCN_SELECT ; Sent by a month calendar control when the user makes an explicit date selection within a month calendar control
$tInfo = DllStructCreate($tagNMSELCHANGE, $ilParam)
_DebugPrint("$MCN_SELECT" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->BegYear:" & @TAB & DllStructGetData($tInfo, "BegYear") & @LF & _
"-->BegMonth:" & @TAB & DllStructGetData($tInfo, "BegMonth") & @LF & _
"-->BegDOW:" & @TAB & DllStructGetData($tInfo, "BegDOW") & @LF & _
"-->BegDay:" & @TAB & DllStructGetData($tInfo, "BegDay") & @LF & _
"-->BegHour:" & @TAB & DllStructGetData($tInfo, "BegHour") & @LF & _
"-->BegMinute:" & @TAB & DllStructGetData($tInfo, "BegMinute") & @LF & _
"-->BegSecond:" & @TAB & DllStructGetData($tInfo, "BegSecond") & @LF & _
"-->BegMSeconds:" & @TAB & DllStructGetData($tInfo, "BegMSeconds") & @LF & _
"-->EndYear:" & @TAB & DllStructGetData($tInfo, "EndYear") & @LF & _
"-->EndMonth:" & @TAB & DllStructGetData($tInfo, "EndMonth") & @LF & _
"-->EndDOW:" & @TAB & DllStructGetData($tInfo, "EndDOW") & @LF & _
"-->EndDay:" & @TAB & DllStructGetData($tInfo, "EndDay") & @LF & _
"-->EndHour:" & @TAB & DllStructGetData($tInfo, "EndHour") & @LF & _
"-->EndMinute:" & @TAB & DllStructGetData($tInfo, "EndMinute") & @LF & _
"-->EndSecond:" & @TAB & DllStructGetData($tInfo, "EndSecond") & @LF & _
"-->EndMSeconds:" & @TAB & DllStructGetData($tInfo, "EndMSeconds"))
; 没有返回值
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
EndFunc ;==>_DebugPrint