現在選択されている日付けと時刻を設定します。
#Include <GuiDateTimePicker.au3>
_GUICtrlDTP_SetSystemTimeEx($hWnd, ByRef $tDate[, $fFlag = False])
パラメータ
$hWnd | コントロールのハンドル |
$tDate | $tagSYSTEMTIME構造体 |
$fFlag | [オプション]日付けなし設定: True - コントロールに"日付けなし"が設定されます。 False - コントロールに日付けと時刻の値が設定されます。 |
返し値
成功: | True |
失敗: | False |
注意
なし。
関連
_GUICtrlDTP_GetSystemTimeEx, $tagSYSTEMTIME
例
#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, $tDate
_Main()
Func _Main()
Local $hDTP
; GUIを作成
GUICreate("DateTimePick Set System TimeEx", 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")
; システム時刻を設定
$tDate = DllStructCreate($tagDTPTIME)
DllStructSetData($tDate, "Year", @YEAR)
DllStructSetData($tDate, "月", 8)
DllStructSetData($tDate, "Day", 19)
DllStructSetData($tDate, "Hour", 21)
DllStructSetData($tDate, "Minute", 57)
DllStructSetData($tDate, "Second", 34)
_GUICtrlDTP_SetSystemTimeEx($hDTP, $tDate)
; システム時刻を表示
$tDate = _GUICtrlDTP_GetSystemTimeEx($hDTP)
MemoWrite("Current date: " & GetDateStr())
MemoWrite("Current time: " & GetTimeStr())
; ユーザーが終了するまでループ
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
; 日付け部分を返す
Func GetDateStr()
Return StringFormat("%02d/%02d/%04d", DllStructGetData($tDate, "月"), DllStructGetData($tDate, "Day"), DllStructGetData($tDate, "Year"))
EndFunc ;==>GetDateStr
; 時刻部分を返す
Func GetTimeStr()
Return StringFormat("%02d:%02d:%02d", DllStructGetData($tDate, "Hour"), DllStructGetData($tDate, "Minute"), DllStructGetData($tDate, "Second"))
EndFunc ;==>GetTimeStr
; メモコントロールに1行書き込み
Func MemoWrite($sMessage)
GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc ;==>MemoWrite