Jump to content

GuiCtrlCreateDate and GuiCtrlSetData [Resolved]


Recommended Posts

Hi all,

So here is my delima I'm using:

$Date_Input_1 = GUICtrlCreateDate("", 10, -1, 150,25,$DTS_SHORTDATEFORMAT)

Then i use guictrlread to and save the read date to a ini file.

After wards i want to be able to read from the ini file and use

GUICtrlSetData($Date_Input_1, $Data1)

The fun is that the guisetdata wants it in format:

yyyy/mm/dd

and the read data saves as:

dd/mm/yyyy

is there any easy was to change this without manually manipulating the strings?

Thanks,

-1

Edit1:

Thank you GEO and Ninja

Edited by Negative1

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

So here is my delima I'm using:

$Date_Input_1 = GUICtrlCreateDate("", 10, -1, 150,25,$DTS_SHORTDATEFORMAT)

GuiCtrlCreateDate creates a date in the yyyy/mm/dd format by default, is there a reason you are setting the style to $DTS_SHORTDATEFORMAT to change that format?

Edit: Sorry, I was misreading the function description for GUICtrlCreateDate

Edited by NinjaGeek
Link to comment
Share on other sites

GuiCtrlCreateDate creates a date in the yyyy/mm/dd format by default, is there a reason you are setting the style to $DTS_SHORTDATEFORMAT to change that format?

my default without $DTS_SHORTDATEFORMAT is "Friday, June 06 2010" or something close to that

I used the style cause I just need the short date.

What are we going to do tonight Brain?Same thing we do every night Pinky try to automate the world.

Link to comment
Share on other sites

The default is a long date as shown by Negative1

That appears to be an inconsistancy between $DTS_SHORTDATEFORMAT and what's reguired for GUICtrlSetData.

For now I suggest that you run it through this first

$sDate = "04/06/2010"
$sDate = StringRegExpReplace($sDate, "(\d+)/(\d+)/(\d+)", "$3/$2/$1")

If course the $sDate can be all done in the one line if you prefer

$sDate = StringRegExpReplace("04/06/2010", "(\d+)/(\d+)/(\d+)", "$3/$2/$1")

To do it properly the 04/06/2010 in the StringRegExpReplace would just be an IniRead()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You can use GuiCtrlSendMsg to change the format:

$DTM_SETFORMAT_ = 0x1032
$style = "yyyy/mm/dd"
GUICtrlSendMsg($Date, $DTM_SETFORMAT_, 0, $style) ;this converts the information in $Date to the format specified in $style
GUICtrlRead($Date)

Above is not complete code, but shows necessary parts to do the conversion.

Edit: Here's a full example that can be run to try it out:

#include <GUIConstantsEx.au3>

$DTM_SETFORMAT_ = 0x1032    ; $DTM_SETFORMATW
$style = "yyyy/mm/dd"

$test = GUICreate("test",200,100)
$Date = GUICtrlCreateDate("2009/01/10", 10, 10, 150,25,0x00000010)
$button = GUICtrlCreateButton("End",10,40,100)
GUISetState()

while 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE
        Exit
    Case $button
        ExitLoop
    EndSwitch
WEnd

GUICtrlSendMsg($Date, $DTM_SETFORMAT_, 0, $style)
$ConvertedDate = GUICtrlRead($Date1)

GUIDelete($test)

msgbox(0,"test",$ConvertedDate)
Edited by NinjaGeek
Link to comment
Share on other sites

Reported as a bug. Ticket #1666

Edit: Reported even though it may be a Windows bug that is at the heart of the problem, GuiCtrlSetData should still be fixed to handle it properly.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

I just checked TRAC and apparently this has now been fixed for version 3.3.7.0. In the meantime I suggest you just do the conversion as I suggested above.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...