Function Reference

GUICtrlCreateDate

Creates a date control for the GUI.

GUICtrlCreateDate ( "text", left, top [, width [, height [, style [, exStyle]]]] )

 

Parameters

text The preselected date.
left The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width [optional] The width of the control (default is the previously used width).
height [optional] The height of the control (default is the previously used height).
style [optional] Defines the style of the control. See GUI Control Styles Appendix.

default (-1) : $DTS_LONGDATEFORMAT
forced style : $WS_TABSTOP
exStyle [optional] Defines the extended style of the control. See Extended Style Table.
default (-1) : WS_EX_CLIENTEDGE

 

Return Value

Success: Returns the identifier (controlID) of the new control.
Failure: Returns 0.

 

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To combine styles with the default style use BitOr($GUI_SS_DEFAULT_DATE, newstyle,...).

To Format the date/time see example 3 to understand how to use a GuiCtrlSendMsg with a $DTM_SETFORMAT.

To use the values specified above you must #include <DateTimeConstants.au3> in your script.

Default resizing is $GUI_DOCKHEIGHT.

 

Related

GUICoordMode (Option), GUICtrlSetState, GUIGetMsg, GUICtrlRead

 

Example


#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>

Opt('MustDeclareVars', 1)

Example1()
Example2()
Example3()

; example1
Func Example1()
    Local $date, $msg

    GUICreate("My GUI get date", 200, 200, 800, 200)
    $date = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20)
    GUISetState()

    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE

    MsgBox(0, "Date", GUICtrlRead($date))
    GUIDelete()
EndFunc   ;==>Example1

; example2
Func Example2()
    Local $n, $msg

    GUICreate("My GUI get time")
    $n = GUICtrlCreateDate("", 20, 20, 100, 20, $DTS_TIMEFORMAT)
    GUISetState()

    ; Run the GUI until the dialog is closed
    Do
        $msg = GUIGetMsg()
    Until $msg = $GUI_EVENT_CLOSE

    MsgBox(0, "Time", GUICtrlRead($n))
    GUIDelete()
EndFunc   ;==>Example2

; example3
Func Example3()
    Local $date, $msg, $DTM_SETFORMAT_, $style
   
    GUICreate("My GUI get date", 200, 200, 800, 200)
    $date = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20)

    ; to select a specific default format
    If @Unicode Then
        $DTM_SETFORMAT_ = 0x1032
    Else
        $DTM_SETFORMAT_ = 0x1005
    EndIf
    $style = "yyyy/MM/dd HH:mm:s"
    GUICtrlSendMsg($date, $DTM_SETFORMAT_, 0, $style)

    GUISetState()
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

    MsgBox(0, "Time", GUICtrlRead($date))
EndFunc   ;==>Example3