Sign in to follow this  
Followers 0
4Eyes

Can't change time in a Date control

6 posts in this topic

Folks,

According to the help file I should be able to change the time in a date control with GUICtrlSetData(), but using the code below the GUICtrlSetData() actually fails. I'd prefer not to use a DTP control as this is far more than what I want. Is there a solution to this?

Regards,

4Eyes

#include <DateTimeConstants.au3>

$Form1 = GUICreate("Test", 319, 290, 198, 114)
$n = GUICtrlCreateDate("", 100, 108, 100, 25, $DTS_TIMEFORMAT)
GUISetState(@SW_SHOW)
$temp = GUICtrlRead($n)
$rc = GUICtrlSetData($n, "11:30:00 AM")         ; This returns 0 and doesn't change control
MsgBox(0, "", "Tried to set time to 11:30:00 AM, $rc from GUICtrlSetData() = " & $rc)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



Try this :

_rundos ("time 11:30:00")

Hi,

maybe not a good idea, because this changes computertime.

;-))

Stefan

Share this post


Link to post
Share on other sites

Well, thanks guys, but I thought there'd be a real answer to this as it seems to be a bug.

what I've come up with is to read the current system time, change it to be an hour ahead (or as far in the future as I'd like), set the control from that, then restore the original time.

4Eyes

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

@4Eyes,

#include <GuiConstantsEx.au3>
#include <DateTimeConstants.au3>

$Form1 = GUICreate("Test", 319, 290, 198, 114)
$n = GUICtrlCreateDate("", 100, 108, 100, 25, $DTS_TIMEFORMAT)
GUISetState(@SW_SHOW)
$temp = GUICtrlRead($n)
GUICtrlSetState($n, $GUI_FOCUS)
$rc = ControlSend($Form1,"", GUICtrlGetHandle($n), "11:30:00:AM")
MsgBox(0, "", "Tried to set time to 11:30:00 AM, $rc from GUICtrlSetData() = " & $rc)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

:)

Edit: Changed $rc = ControlSend($Form1,"", GUICtrlGetHandle($n), "11:30:00{RIGHT}AM") to "11:30:00:AM" , easier syntax and works too.

Edited by ResNullius

Share this post


Link to post
Share on other sites

This works for me. Changes time displayed in GUICtrlCreateDate control to "11:30:00 a.m."

$rc = GUICtrlSetData($n, "2009/10/03 11:30:00 a.m.")

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0