Function Reference

_GUICtrlDTP_GetSystemTimeEx

現在選択されている日付けと時刻を取得します。

#Include <GuiDateTimePicker.au3>
_GUICtrlDTP_GetSystemTimeEx($hWnd)

 

パラメータ

$hWnd コントロールのハンドル

 

返し値

成功: $tagSYSTEMTIME構造体

 

注意

時刻情報が正常に返された場合は$GDT_VALIDが、
コントロールに$DTS_SHOWNONEスタイルが設定され、チェックボックスが選択されていない場合は$GDT_NONEが、
エラーが発生した場合は $GDT_ERRORが、
@Errorに設定されます。

 

関連

_GUICtrlDTP_GetSystemTime, _GUICtrlDTP_SetSystemTimeEx, $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 Get 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