Jump to content
Sign in to follow this  
leegold

GUICtrlCreateDate style and format

Recommended Posts

leegold

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

Share this post


Link to post
Share on other sites
Malkey

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

Share this post


Link to post
Share on other sites
leegold

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
 

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.