4Eyes Posted October 2, 2009 Posted October 2, 2009 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
99ojo Posted October 2, 2009 Posted October 2, 2009 Try this : _rundos ("time 11:30:00") Hi, maybe not a good idea, because this changes computertime. ;-)) Stefan
4Eyes Posted October 3, 2009 Author Posted October 3, 2009 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
ResNullius Posted October 3, 2009 Posted October 3, 2009 (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 WEndEdit: Changed $rc = ControlSend($Form1,"", GUICtrlGetHandle($n), "11:30:00{RIGHT}AM") to "11:30:00:AM" , easier syntax and works too. Edited October 3, 2009 by ResNullius
picaxe Posted October 3, 2009 Posted October 3, 2009 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.")
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now