Sign in to follow this  
Followers 0
mark2004

Changing a date control

6 posts in this topic

I'm having a bit of trouble changing the date of a date control. Seems like Guictrlsetdata should do it but it doesn't.

Here is a portion of my code for the date control. I've actually tried many variations of data/default with guictrlsetdata but

up to now nothing has done the trick.

#include <GUIConstants.au3>
#include <date.au3>

GUICreate("My GUI", 1016, 687, 2, 11) ; will create a dialog box that when displayed is centered

$Date = GUICtrlCreateDate("01/01/2006", 32, 138, 177, 25,$DTS_SHORTDATEFORMAT)
GUISetState()
GUICtrlSetData($Date,"","01/24/2006")


While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

Any suggestions????

Share this post


Link to post
Share on other sites



re-read the help on the date control

#include <GUIConstants.au3>

GUICreate("My GUI", 1016, 687, 2, 11) ; will create a dialog box that when displayed is centered

$Date = GUICtrlCreateDate("2006/01/01", 32, 138, 177, 25,$DTS_SHORTDATEFORMAT)
GUISetState()
GUICtrlSetData($Date,"2006/01/24")


While 1
    $msg = GUIGetMsg()
   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

re-read the help on the date control

#include <GUIConstants.au3>

GUICreate("My GUI", 1016, 687, 2, 11) ; will create a dialog box that when displayed is centered

$Date = GUICtrlCreateDate("2006/01/01", 32, 138, 177, 25,$DTS_SHORTDATEFORMAT)
GUISetState()
GUICtrlSetData($Date,"2006/01/24")
While 1
    $msg = GUIGetMsg()
   
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
I've read the help many times. It does not explain how to change the date of the control.

It gives a link to a list of functions to "set or change information in the control". GuiCtrlSetData and GUICtrlSend Message

are the only ones in the list that look like they would be appropriate for changing the text of the control.

The remainder of the date help shows 3 examples. example 1 shows how to create and read from the date control. example

2 shows how to get the system time using the $DTS_TIMEFORMAT style. Example 3 shows how to send a windows api message

to the control. In this case it is $DTM_SETFORMAT so it is just to modify the format of the control's date. As I said in my previous post, I have tried Guictrlset data in many different ways by changing the "data" and "default" fields to no avail.

I've gone over all the windows messages for this control on the MSDN site and nothing seems able to change the text of the

control. So, I'm not sure how to proceed with the GUIctrlsendmessage function.

I don't know how many more times I can read through the AUTOIT help documentation. That is why I posted my question here.

I am obviously missing something. Usually, what you're missing is dead in front of your face. I'm hoping that is the case here.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <date.au3>

GUICreate("My GUI", 1016, 687, 2, 11); will create a dialog box that when displayed is centered

$Date = GUICtrlCreateDate("2006/01/01", 32, 138, 177, 25,$DTS_SHORTDATEFORMAT)
GUISetState()
GUICtrlSetData($Date,"2006/01/24")


While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

That's working on my system. I think that's depend of how your date is displayed on your system

Your main bug come from the extra ,"" in the GUICtrlSetData

Share this post


Link to post
Share on other sites

I've read the help many times. It does not explain how to change the date of the control.

It gives a link to a list of functions to "set or change information in the control". GuiCtrlSetData and GUICtrlSend Message

are the only ones in the list that look like they would be appropriate for changing the text of the control.

The remainder of the date help shows 3 examples. example 1 shows how to create and read from the date control. example

2 shows how to get the system time using the $DTS_TIMEFORMAT style. Example 3 shows how to send a windows api message

to the control. In this case it is $DTM_SETFORMAT so it is just to modify the format of the control's date. As I said in my previous post, I have tried Guictrlset data in many different ways by changing the "data" and "default" fields to no avail.

I've gone over all the windows messages for this control on the MSDN site and nothing seems able to change the text of the

control. So, I'm not sure how to proceed with the GUIctrlsendmessage function.

I don't know how many more times I can read through the AUTOIT help documentation. That is why I posted my question here.

I am obviously missing something. Usually, what you're missing is dead in front of your face. I'm hoping that is the case here.

If you're interested in working with the date control at a lower level, you might want to take a look at the A3LDateTimePick module in Auto3Lib. It maps all of the windows API messages for the control and allows you to specify custom date formats. There is a demo script that shows how to manipulate the control and use all of the messages.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

I didn't realize that GaFrost's reply included new code. I thought that was a reprint of my original code. Yes, when I try that

it works on my system too. The reason my code wasn't working was I was inputting a date as "01/24/2006" instead of "2006/01/24". (I had tried taking out the "" from the data field). The system didn't like the format so it never updated itself.

I knew it was right in front of my face!! Thanks very much for clearing it up.

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