Function Reference

_GUICtrlDTP_Create

DTPコントロールを作成します。

#Include <GuiDateTimePicker.au3>
_GUICtrlDTP_Create($hWnd, $iX, $iY[, $iWidth = 120[, $iHeight = 21[, $iStyle = 0x00000000[, $iExStyle = 0x00000000]]]])

 

パラメータ

$hWnd 親ウィンドウまたはオーナーウィンドウのハンドル
$iX コントロールの水平位置
$iY コントロールの垂直位置
$iWidth [オプション]コントロールの幅
$iHeight [オプション]コントロールの高さ
$iStyle [オプション]コントロールのスタイル:
$DTS_APPCANPARSE - オーナーにユーザー入力の一時停止と動作処理を許可します
$DTS_LONGDATEFORMAT - 長い形式で日付を表示します
$DTS_RIGHTALIGN - カレンダーが右揃えになります
$DTS_SHOWNONE - 日付を入力するとチェックされるチェックボックスを表示します
$DTS_SHORTDATEFORMAT - 短い形式で日付を表示します
$DTS_SHORTDATECENTURYFORMAT - 年を4桁で表示します
$DTS_TIMEFORMAT - 時刻を表示します
$DTS_UPDOWN - コントロールの右側にアップダウンコントロールを配置します
強制: $WS_CHILD、$WS_VISIBLE
$iExStyle [オプション]コントロールの外部スタイル

 

返し値

成功: DTPコントロールのハンドル
失敗: 0

 

注意

この関数は上級者、コントロール動作学習用です。

 

関連

_GUICtrlDTP_Destroy

 


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

Opt('MustDeclareVars', 1)

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

Global $hDTP

_Main()

Func _Main()
    Local $hGUI

    ; GUIを作成
    $hGUI = GUICreate("(UDF Created) DateTimePick Create", 400, 300)
    $hDTP = _GUICtrlDTP_Create($hGUI, 2, 6, 190)
    GUISetState()

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

    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, $tBuffer, $tBuffer2

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hDTP
            Switch $iCode
                Case $DTN_CLOSEUP ; ユーザーがドロップダウン月カレンダーを閉じた際に日付け時刻ピッカー(DTP)コントロールによって送信される
                    _DebugPrint("$DTN_CLOSEUP" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; この通知の返し値は使用されない
                Case $DTN_DATETIMECHANGE ; 変化が発生した際に日付け時刻ピッカー(DTP)コントロールによって送信される
                    $tInfo = DllStructCreate($tagNMDATETIMECHANGE, $ilParam)
                    _DebugPrint("$DTN_DATETIMECHANGE" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
                            "-->Flag:" & @TAB & DllStructGetData($tInfo, "Flag") & @LF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @LF & _
                            "-->月:" & @TAB & DllStructGetData($tInfo, "月") & @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"))
                    Return 0
                Case $DTN_DROPDOWN ; ユーザーがドロップダウン月カレンダーをアクティブにした際に日付け時刻ピッカー(DTP)コントロールによって送信される
                    _DebugPrint("$DTN_DROPDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
                            "-->IDFrom:" & @TAB & $iIDFrom & @LF & _
                            "-->Code:" & @TAB & $iCode)
                    ; この通知の返し値は使用されない
                Case $DTN_FORMAT ; コールバックフィールドに表示されるテキストを要求するために日付け時刻ピッカー(DTP)コントロールによって送信される
                    $tInfo = DllStructCreate($tagNMDATETIMEFORMAT, $ilParam)
                    $tBuffer = DllStructCreate("char Format[128]", DllStructGetData($tInfo, "Format"))
                    $tBuffer2 = DllStructCreate("char Display[64]", DllStructGetData($tInfo, "pDisplay"))
                    _DebugPrint("$DTN_FORMAT" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
                            "-->Format:" & @TAB & DllStructGetData($tBuffer, "Format") & @LF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @LF & _
                            "-->月:" & @TAB & DllStructGetData($tInfo, "月") & @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 & _
                            "-->Display:" & @TAB & DllStructGetData($tBuffer2, "Display"))
                    Return 0
                Case $DTN_FORMATQUERY ; コールバックフィールドに表示される文字列の最大許容サイズを取得するために日付け時刻ピッカー(DTP)コントロールによって送信される
                    $tInfo = DllStructCreate($tagNMDATETIMEFORMATQUERY, $ilParam)
                    $tBuffer = DllStructCreate("char Format[128]", DllStructGetData($tInfo, "Format"))
                    _DebugPrint("$DTN_FORMATQUERY" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
                            "-->Format:" & @TAB & DllStructGetData($tBuffer, "Format") & @LF & _
                            "-->SizeX:" & @TAB & DllStructGetData($tInfo, "SizeX") & @LF & _
                            "-->SizeY:" & @TAB & DllStructGetData($tBuffer2, "SizeY"))
                    DllStructSetData($tInfo, "SizeX", 64)
                    DllStructSetData($tInfo, "SizeY", 10)
                    Return 0
                Case $DTN_USERSTRING ; ユーザーがコントロール内の文字列編集を終了した際に日付け時刻ピッカー(DTP)コントロールによって送信される
                    $tInfo = DllStructCreate($tagNMDATETIMESTRING, $ilParam)
                    $tBuffer = DllStructCreate("char UserString[128]", DllStructGetData($tInfo, "UserString"))
                    _DebugPrint("$DTN_USERSTRING" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
                            "-->UserString:" & @TAB & DllStructGetData($tBuffer, "UserString") & @LF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @LF & _
                            "-->月:" & @TAB & DllStructGetData($tInfo, "月") & @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 & _
                            "-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
                    Return 0
                Case $DTN_WMKEYDOWN ; ユーザーがコールバックフィールドに入力した際に日付け時刻ピッカー(DTP)コントロールによって送信される
                    $tInfo = DllStructCreate($tagNMDATETIMEFORMATQUERY, $ilParam)
                    $tBuffer = DllStructCreate("char Format[128]", DllStructGetData($tInfo, "Format"))
                    _DebugPrint("$DTN_WMKEYDOWN" & @LF & "--> hWndFrom:" & @TAB & DllStructGetData($tInfo, "hWndFrom") & @LF & _
                            "-->IDFrom:" & @TAB & DllStructGetData($tInfo, "IDFrom") & @LF & _
                            "-->Code:" & @TAB & DllStructGetData($tInfo, "Code") & @LF & _
                            "-->VirtKey:" & @TAB & DllStructGetData($tInfo, "VirtKey") & @LF & _
                            "-->Format:" & @TAB & DllStructGetData($tBuffer, "Format") & @LF & _
                            "-->Year:" & @TAB & DllStructGetData($tInfo, "Year") & @LF & _
                            "-->月:" & @TAB & DllStructGetData($tInfo, "月") & @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"))
                    Return 0
            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