haodd 发表于 2011-10-17 11:48:55

GUICtrlCreateDate 样式的疑问【已解决】

本帖最后由 haodd 于 2011-10-17 18:12 编辑

$Date2 = GUICtrlCreateDate(@YEAR&"/"&@MON&"/"&@MDAY, 226, 13, 106, 21,$DTS_SHOWNONE)怎么获取 勾选 和 不勾选的 结果

我试了我知道的 GUICtrlRead 和 GUICtrlgetstat 都不行呀

happytc 发表于 2011-10-17 12:54:39

本帖最后由 happytc 于 2011-10-17 12:57 编辑

看微软的说明:DTS_SHOWNONE
DTS_SHOWNONEIt 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

haodd 发表于 2011-10-17 18:12:35

回复 2# happytc


    这正是我要的 谢谢结贴咯 谢谢

xyhqqaa 发表于 2012-4-25 10:56:49

留个记号。。谢谢分享

kk_lee69 发表于 2017-7-21 23:57:29

這個不錯喔留個腳印 macgyver
页: [1]
查看完整版本: GUICtrlCreateDate 样式的疑问【已解决】