Sign in to follow this  
Followers 0
john925

GUIRead("date control") return value

5 posts in this topic

I'm not sure if this is a bug or a Microsoft feature. A program I wrote last July broke when I updated Windows XP sp1 to sp2. I'm using a date control for input to set an expiration date. With sp1 installed using GUIRead() with the control returns a string containing the day of the week, the month, the day of the month, and the year. With xp2 installed the returned string only contains the month, the day of the month, and the year. I separate the components using stringsplit() and losing the day of the week as an array element was causing the problem.

The program has to work with both sp1 and sp2 so I've updated it to test for the number of array elements then act accordingly. But should reading the date control do this? If it's a strictly Microsoft thing then a warning in the help entry for GUICtrlCreateDate() and/or GUIRead() would keep other people from having the same problem.

john925

ps. I'm using a 103 beta version downloaded yesterday.

Share this post


Link to post
Share on other sites



Yeah it might be something in the "Regional and Language" settings like Larry said. These settings can vary not only from computer to computer, but from profile to profile. For instance, if I log in and open a cmd.exe and type "echo %date%"

Then it returns "02/11/2004"

But if my mother types the same thing when she logs in, it returns: "Tue 11/02/2004"

I don't know how you could compensate for this behaviour though.

Share this post


Link to post
Share on other sites

check your "Regional and Language" settings in Control Panel. Something must have been reset by the service pack...

Lar.

<{POST_SNAPBACK}>

Thank You! My long date format is different. I need to think about the hidden potential problem that was there all the time. The joys of customization! I suppose I can get the long date format string out of the registry to see what goes where.

Thanks again,

john925

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Too bad AutoIt doesn't return a different format entirely. I wonder if that would be possible? To make the control return every possible field, perhaps even split by pipes or slashes. Then you could just parse through that and use what you need.

Or maybe a UNIX style timestamp. That reminds me, I need to write some functions that can parse timestamps...

Edited by Saunders

Share this post


Link to post
Share on other sites

The solution is GUISendMsg(). The problem was finding the right parameters but I found them on Microsoft's MSDN web site. In this case I needed:

GUISendMsg($control_handle, $message_constant, 0, "date format string")

I copied an example out of the AU3 help to make a quick date control that outputs it's return value in a message box for testing. Without using GUISendMsg() the return value is: month day, year. Using GUISendMsG() the return value changed to: day-of-the-week, month day, year. A format string of "yyyyMMdd" would return the date in the exact format I need. Unfortunately, the message makes the control display the date in the same format so it would look odd.

#include <GUIConstants.au3>

$DTM_SETFORMAT = 0x1000 + 5 ;+50 instead of +5 for UniCode

GUICreate ( "My GUI get date", 200,200,800,200)
$date=GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )
$n = GUISendMsg($date, $DTM_SETFORMAT ,0, "ddd, MMMM dd, yyyy")

john925

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