本帖最后由 happytc 于 2011-10-17 12:57 编辑
看微软的说明:DTS_SHOWNONE
DTS_SHOWNONE It is possible to have no date currently selected in the control. With this style, the control displays a check box that is automatically selected whenever a date is picked or entered. If the check box is subsequently deselected, the application cannot retrieve the date from the control because, in essence, the control has no date. The state of the check box can be set with the DTM_SETSYSTEMTIME message or queried with the DTM_GETSYSTEMTIME message.
所以不能从控件上获得这个状态,只能用消息DTM_GETSYSTEMTIME来得到。另外从上面说明中,我们还可以设置这个Pseu-CheckBox默认设为不选中状态。
#include <GUIConstants.au3>
#include <DateTimeConstants.au3>
#Include <GuiDateTimePicker.au3>
TestDateCheckbox()
Func TestDateCheckbox()
Local $hGui, $Date, $hDate, $tDate, $Button, $msg, $lParam
$hGui = GUICreate("Date Test", 200, 200)
$Date = GUICtrlCreateDate ("", 10, 10, 100, 20, BitOR($DTS_SHORTDATEFORMAT, $DTS_SHOWNONE))
$hDate = GUICtrlGetHandle($date)
$tDate = 0
_GUICtrlDTP_SetSystemTimeEx($hDate, $tDate, True)
$Button = GUICtrlCreateButton ("get", 10, 80, 60, 20)
GUISetState()
Do
$msg = GUIGetMsg()
If $msg == $Button Then
$lParam = GUICtrlRecvMsg($date, $DTM_GETSYSTEMTIME, 0, 1)
If $lParam == 0 Then
MsgBox(0, 0, "Is Checked")
Else
MsgBox(0, 0,"Not Checked")
EndIf
EndIf
until $msg == $GUI_EVENT_CLOSE
GUIDelete($hGui)
EndFunc
|