Jump to content
Sign in to follow this  
Zaxon

Changing Time Format of date control

Recommended Posts

Zaxon

I've used code forever that changes the format of a date control, and although my script hasn't changed, a more recent version of AutoIt breaks the functionality. Currently using autoit-v3.2.9.11.

I've written a test script by way of example:

#include <GUIConstants.au3>

GUICreate("")

$date=GUICtrlCreateDate("",5,5,100,20,$dts_timeformat)
$style = "hh:mm tt" ; or
;$style = "hh':'mm' 'tt"
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style) ; or 
;GUICtrlSendMsg($date, 0x1005, 0, $style)

GUISetState(@SW_SHOW)
sleep(5000)

This creates a time (date) control and attempts to change it's format to one which excludes the seconds. The two different format ($style = ) lines show testing attempts with the way it used to work in a previous version of AutoIt and the way given in examples in this forum. Same with the two SendMsg lines, one showing the way my script uses it, the other the way it's currently shown in forum examples.

What I end up with is a date control showing a single number, eg: "5" for the actual time "5:24 PM", no minutes etc are shown. I've played around with the format of the $style string - pretty much everything I could think of - but I keep getting just a single digit shown instead of a properly formatted time.

Now, I don't know what changed in AutoIt to break this functionality. How can I now correctly change the time format?

Share this post


Link to post
Share on other sites
Lazycat

Now, I don't know what changed in AutoIt to break this functionality. How can I now correctly change the time format?

As stated in this thread:

http://www.autoitscript.com/forum/index.php?showtopic=45919

you should use $DTM_SETFORMATW = 0x1032 instead $DTM_SETFORMAT for unicode version. For me this solution work fine.

Share this post


Link to post
Share on other sites
Zaxon

you should use $DTM_SETFORMATW = 0x1032 instead $DTM_SETFORMAT for unicode version. For me this solution work fine.

Thanks. Works like a charm.

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  

×