Jump to content
Sign in to follow this  
Jewtus

Trouble setting date with GUICtrlSetData

Recommended Posts

Jewtus

I'm trying to update the date control inside a GUI and I cannot seem to figure out what is going wrong.

This is the code:

#include <GUIConstantsEx.au3>

$PopUp = GUICreate("Entry", 623, 349, 192, 111)
$DateIn = GUICtrlCreateDate("", 272, 39, 154, 21)
ConsoleWrite(GUICtrlRead($DateIn))
GUICtrlSetData($DateIn,'Thursday, September 04, 2014')
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($PopUp)
            Exit
    EndSwitch
WEnd

This is what I would like to have done:

#include <GUIConstantsEx.au3>

$PopUp = GUICreate("Entry", 623, 349, 192, 111)
$DateIn = GUICtrlCreateDate("", 272, 39, 154, 21, 0x00)
ConsoleWrite(GUICtrlRead($DateIn))
GUICtrlSetData($DateIn,'9/4/2014')
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($PopUp)
            Exit
    EndSwitch
WEnd

But no matter what I seem to try for reformatting the date, it doesn't seem to be updating the GUI control. Anyone have ideas?

Share this post


Link to post
Share on other sites
Valuater

You can set the format.. from the help file

#include <GUIConstantsEx.au3>
#include <DateTimeConstants.au3>
 
 Local $date, $DTM_SETFORMAT_, $style
 
    GUICreate("My GUI get date", 200, 200, 800, 200)
    $date = GUICtrlCreateDate(@MON & "/" & @MDAY & "/" & @YEAR , 10, 10, 185, 20)
 
    ; to select a specific default format
    $DTM_SETFORMAT_ = 0x1032 ; $DTM_SETFORMATW
    $style = "MM/dd/yyyy" ; HH:mm:ss"
    GUICtrlSendMsg($date, $DTM_SETFORMAT_, 0, $style)
 
    GUISetState()
    While GUIGetMsg() <> $GUI_EVENT_CLOSE
    WEnd

NEWHeader1.png

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  

×