Function Reference

_GUICtrlDTP_SetRangeEx

現在の最小、最大許容システム時刻を設定します。

#Include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetRangeEx($hWnd, ByRef $tRange)

 

パラメータ

$hWnd コントロールのハンドル
$tRange $tagDTPRANGE構造体

 

返し値

成功: True
失敗: False

 

注意

なし。

 

関連

_GUICtrlDTP_GetRangeEx, $tagDTPRANGE

 


#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiDateTimePicker.au3>

Opt('MustDeclareVars', 1)

$Debug_DTP = False ; DTP関数に渡されるClassNameを調べる。動作を確認するにはTrueを設定し、他のコントロールのハンドルを使用

Global $iMemo, $tRange

_Main()

Func _Main()
    Local $hDTP

    ; GUIを作成
    GUICreate("DateTimePick Set RangeEx", 400, 300)
    $hDTP = GUICtrlGetHandle(GUICtrlCreateDate("", 2, 6, 190))
    $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; 表示形式を設定
    _GUICtrlDTP_SetFormat($hDTP, "ddd MMM dd, yyyy hh:mm ttt")

    ; 日付け範囲を設定
    $tRange = DllStructCreate($tagDTPRANGE)
    DllStructSetData($tRange, "MinValid", True)
    DllStructSetData($tRange, "MinYear", @YEAR)
    DllStructSetData($tRange, "Min月", 1)
    DllStructSetData($tRange, "MinDay", 1)
    DllStructSetData($tRange, "MaxValid", True)
    DllStructSetData($tRange, "MaxYear", @YEAR)
    DllStructSetData($tRange, "Max月", 12)
    DllStructSetData($tRange, "MaxDay", 31)
    DllStructSetData($tRange, "MaxHour", 12)
    DllStructSetData($tRange, "MaxMinute", 59)
    DllStructSetData($tRange, "MaxSecond", 59)
    _GUICtrlDTP_SetRangeEx($hDTP, $tRange)

    ; 日付け範囲を表示
    $tRange = _GUICtrlDTP_GetRangeEx($hDTP)
    MemoWrite("Minimum date: " & GetDateStr("Min"))
    MemoWrite("Maximum date: " & GetDateStr("Max"))
    MemoWrite("Minimum time: " & GetTimeStr("Min"))
    MemoWrite("Maximum time: " & GetTimeStr("Max"))

    ; ユーザーが終了するまでループ
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

; 日付け部分を返す
Func GetDateStr($sPrefix)
    If $sPrefix = "Min" Then
        Return StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "Min月"), DllStructGetData($tRange, "MinDay"), DllStructGetData($tRange, "MinYear"))
    Else
        Return StringFormat("%02d/%02d/%04d", DllStructGetData($tRange, "Max月"), DllStructGetData($tRange, "MaxDay"), DllStructGetData($tRange, "MaxYear"))
    EndIf
EndFunc   ;==>GetDateStr

; 時刻部分を返す
Func GetTimeStr($sPrefix)
    If $sPrefix = "Min" Then
        Return StringFormat("%02d:%02d:%02d", DllStructGetData($tRange, "MinHour"), DllStructGetData($tRange, "MinMinute"), DllStructGetData($tRange, "MinSecond"))
    Else
        Return StringFormat("%02d:%02d:%02d", DllStructGetData($tRange, "MaxHour"), DllStructGetData($tRange, "MaxMinute"), DllStructGetData($tRange, "MaxSecond"))
    EndIf
EndFunc   ;==>GetTimeStr

; メモコントロールに1行書き込み
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite