leegold Posted July 9, 2013 Posted July 9, 2013 Hi, GUICtrlCreateDate("", 350, 325, 100, 40, $DTS_TIMEFORMAT) creates a time "widget" the user can manipulate, and I read it in with $t = GUICtrlRead(11). The user sees a time ithey can edit n the form of eg. "5:09:20 .PM" in the GUI Is there a way to have them only see 5:09 PM. That is, I only want them to be able to select down to the minute. Seconds would not show and not be changable and would be locked at "00". Can GUICtrlCreateDate do this with some modification? Thanks
Malkey Posted July 9, 2013 Posted July 9, 2013 In this example:- Use $style = "HH:mm tt" to have only 5:09 PM visible, or; Use $style = "HH:mm:00 tt" to have the seconds locked at "00". #include <GUIConstantsEx.au3> #include <DateTimeConstants.au3> Example() Func Example() Local $n, $msg GUICreate("My GUI4 get time", 200, 200, 800, 200) $n = GUICtrlCreateDate("", 20, 20, 100, 20, $DTS_TIMEFORMAT) $DTM_SETFORMAT_ = 0x1032 $style = "HH:mm tt" ; or "HH:mm:00 tt" GUICtrlSendMsg($n, $DTM_SETFORMAT_, 0, $style) GUISetState() ; Run the GUI until the dialog is closed Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE MsgBox(0, "Time", GUICtrlRead($n)) GUIDelete() EndFunc ;==>Example
leegold Posted July 11, 2013 Author Posted July 11, 2013 Hi, Thanks. This does indeed lock or eliminate seconds. But when it's PM I am getting a 24hr time. Is there a way to say 11:07 PM ? or 11:07:00 PM with seconds locked at 00 is OK too. I'm getting 21:07:00 PM....Thanks. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <DateTimeConstants.au3> #include <StaticConstants.au3> #include <Date.au3> GUICreate("My GUI list", 667, 407) $dc = GUICtrlCreateDate("", 50, 50, 200, 200, $DTS_TIMEFORMAT) $DTM_SETFORMAT_ = 0x1032 $style = "HH:mm:00 tt" GUICtrlSendMsg($dc, $DTM_SETFORMAT_, 0, $style) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd
Malkey Posted July 11, 2013 Posted July 11, 2013 For 12 hr time use lower case "hh" $style = "hh:mm:00 tt" See "Custom Date and Time Format strings". This link has all the format specifiers available.
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