设置月日历控件特定日期的选择范围
#Include <GuiMonthCal.au3>
_GUICtrlMonthCal_SetSelRange($hWnd, $iMinYear, $iMinMonth, $iMinDay, $iMaxYear, $iMaxMonth, $iMaxDay)
$hWnd | 控件句柄 |
$iMinYear | 最低年 |
$iMinMonth | 最低月 |
$iMinDay | 最低天 |
$iMaxYear | 最大年 |
$iMaxMonth | 最大月 |
$iMaxDay | 最大天 |
成功: | 返回 True |
失败: | 返回 False |
#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 $iMemo
_Main()
Func _Main()
Local $tRange, $hMonthCal
; 创建 GUI
GUICreate("Month Calendar Set Sel Range", 400, 300)
$hMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_MULTISELECT), 0x00000000)
; 创建 memo 控件
$iMemo = GUICtrlCreateEdit("", 4, 168, 392, 128, 0)
GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
GUISetState()
; Get/Set selection
_GUICtrlMonthCal_SetSelRange($hMonthCal, @YEAR, @MON, 1, @YEAR, @MON, 7)
$tRange = _GUICtrlMonthCal_GetSelRange($hMonthCal)
MemoWrite("Start date: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MinMonth"), _
DllStructGetData($tRange, "MinDay"), _
DllStructGetData($tRange, "MinYear")))
MemoWrite("End date .: " & StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "MaxMonth"), _
DllStructGetData($tRange, "MaxDay"), _
DllStructGetData($tRange, "MaxYear")))
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
; 写入消息到 memo
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite