Sign in to follow this  
Followers 0
Vakari

GuiCtrlCreateDate

3 posts in this topic

#Include <GUIConstants.au3>

$ThisApp = "Test: Date Input and Retrieval"

$Ini = "Test.ini"

GUICreate($ThisApp, 250, 50)
$Date = GUICtrlCreateDate("", 15, 15, 220, 20)
GUISetState(@SW_SHOW)

$SelectedDate = IniRead($Ini, "Date", "Selected", "")
GUICtrlSetData($Date, $SelectedDate); GUICtrlSendMsg ?

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        IniWrite($Ini, "Date", "Selected", GUICtrlRead($Date))
        Exit
    EndIf
Wend

When this is run, it will show a window with today's date. Select any date, then close the window. The date selected is saved to an ini.

The plan is to recover the last date chosen from the ini and set the date in the box to that date. I can't seem to figure out how to get this to work.

I read somewhere that GuiCtrlSendMsg might be required for a date control, but I don't remember where I saw it, and I can't grasp the concept of GuiCtrlSendMsg.

Can anyone help me figure this one out? I would appreciate your time. I'm still pretty new to the AutoIT scene, and am in the process of learning. I'm using v3.2.10.0 if that helps. (It's the only version I have ever used since I discovered AutoIT.)

Thank you very much.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I didn't searched too much but ... i think you should use _GUICtrlDTP - functions in UDF section ...

Hope it helped !

Best regards, L|M|TER

Edited by LIMITER

Share this post


Link to post
Share on other sites

... i think you should use _GUICtrlDTP...

Nice! I didn't even know about _GuiCtrl stuff. I can't believe I missed it. Thank you so much.

I played around with it a bit and this is what I came up with, it seems to be working alright:

#include <GuiConstantsEx.au3>
#include <GuiDateTimePicker.au3>
#Include <GUIConstants.au3>

$ThisApp = "Test: Date Input and Retrieval"

$Ini = "Test.ini"

$App = GUICreate($ThisApp, 250, 50)
$Date = _GUICtrlDTP_Create($App, 15, 15, 220)
_GUICtrlDTP_SetFormat($Date, "dddd,  MM/dd/yy")
GUISetState(@SW_SHOW)

$IniStartMonth = IniRead($Ini, "Date", "Start Month", "")
$IniStartDate = IniRead($Ini, "Date", "Start Date", "")
$IniStartYear = IniRead($Ini, "Date", "Start Year", "")
Global $SelectedDate[7] = [False, $IniStartYear, $IniStartMonth, $IniStartDate, 0, 0, 0]
_GUICtrlDTP_SetSystemTime($Date, $SelectedDate)

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then
        $SelectedDate = _GUICtrlDTP_GetSystemTime($Date)
        IniWrite($Ini, "Date", "Start Month", $SelectedDate[1])
        IniWrite($Ini, "Date", "Start Date", $SelectedDate[2])
        IniWrite($Ini, "Date", "Start Year", $SelectedDate[0])
        Exit
    EndIf
Wend

I'm sure most won't think it's pretty, but it's working for me. Anything else you think I should be throwing into the mix?

Thanks again L|M|TER

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