Function Reference


GUICtrlCreateDate

Creates a date control for the GUI.

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

Parameters

text The preselected date (always as "yyyy/mm/dd").
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: the identifier (controlID) of the new control.
Failure: 0.

Remarks

To obtain the value of the control see GUICtrlRead().
To set or change information in the control see GUICtrlUpdate...() functions.

To combine styles with the default style use BitOR($GUI_SS_DEFAULT_DATE, newstyle, ... ).
To use the values specified above you must #include <DateTimeConstants.au3> in your script.

To format the date/time see example 3 to understand how to use a GUICtrlSendMsg() with a $DTM_SETFORMAT.

Default resizing is $GUI_DOCKHEIGHT.

Related

GUICoordMode (Option), GUICtrlRead, GUICtrlSetState, GUIGetMsg

Example

Example 1

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
        GUICreate("My GUI get date", 200, 200, 800, 200)
        Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20)
        GUISetState(@SW_SHOW)

        ; Loop until the user exits.
        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                ExitLoop

                EndSwitch
        WEnd

        MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate))
        GUIDelete()
EndFunc   ;==>Example

Example 2

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

Example()

Func Example()
        GUICreate("My GUI get date", 200, 200, 800, 200)
        Local $idDate = GUICtrlCreateDate("", 10, 10, 100, 20, $DTS_SHORTDATEFORMAT)
        GUISetState(@SW_SHOW)

        ; Loop until the user exits.
        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                ExitLoop

                EndSwitch
        WEnd

        MsgBox($MB_SYSTEMMODAL, "Date", GUICtrlRead($idDate))
        GUIDelete()
EndFunc   ;==>Example

Example 3

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

Example()

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

        ; to select a specific default format
        Local $sStyle = "yyyy/MM/dd HH:mm:ss"
        GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)

        GUISetState(@SW_SHOW)

        ; Loop until the user exits.
        While GUIGetMsg() <> $GUI_EVENT_CLOSE
        WEnd

        MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate))
EndFunc   ;==>Example

Example 4

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

Example()

Func Example()
        GUICreate("My GUI get time", 200, 200, 800, 200)
        Local $idDate = GUICtrlCreateDate("", 20, 20, 100, 20, $DTS_TIMEFORMAT)
        GUISetState(@SW_SHOW)

        ; Loop until the user exits.
        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                ExitLoop

                EndSwitch
        WEnd

        MsgBox($MB_SYSTEMMODAL, "Time", GUICtrlRead($idDate))
        GUIDelete()
EndFunc   ;==>Example