GUICtrlCreateDate
创建日期控件.
GUICtrlCreateDate ( "text", left, top [, width [, height [, style = -1 [, exStyle = -1]]]] )
参数
text
|
预选的日期.(总是为 "yyyy/mm/dd" 格式).
|
left
|
控件左侧的位置. 若此值为 -1, 则根据 GUICoordMode() 的设置计算左侧位置.
|
top
|
控件上方的位置. 若此值为 -1, 则根据 GUICoordMode() 的设置计算顶部位置.
|
width
|
[可选] 控件的宽度(默认使用先前的宽度).
|
height
|
[可选] 控件的高度(默认使用先前的高度).
|
style
|
[可选] 控件的样式. 查看附录 GUI 控件样式表.
默认样式 (-1) : $DTS_LONGDATEFORMAT
强制样式 : $WS_TABSTOP
|
exStyle
|
[可选] 控件的扩展样式. 查看附录 扩展样式表.
默认扩展样式 (-1) : WS_EX_CLIENTEDGE
|
返回值
成功:
|
返回控件标识符(控件ID).
|
失败:
|
返回 0.
|
备注
要获得控件的值, 查看 GUICtrlRead().
设置或者修改控件信息, 参考 GUICtrlUpdate...() 函数.
要在默认样式上添加新样式, 可使用 BitOR($GUI_SS_DEFAULT_DATE, 新样式,...) 语句.
使用上面列出的值必须将 #include <DateTimeConstants.au3> 语句写入脚本中.
要格式化日期/时间, 请查看例子 3 了解怎么使用 GUICtrlSendMsg() 与 $DTM_SETFORMAT.
默认大小 $GUI_DOCKHEIGHT.
相关
GUICoordMode (Option), GUICtrlRead, GUICtrlSetState, GUIGetMsg
函数示例
示例 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
示例 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
示例 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
示例 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
----------------------------------------
|