Sign in to follow this  
Followers 0
heryisme

GUICtrlSet for Date

5 posts in this topic

Hi,

As Subject,

I Want to change the date value, from the active GUI, by using Button

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

GUICreate("My GUI get date", 200, 200, 800, 200)
Local $idDate = GUICtrlCreateDate("2014/04/25", 10, 10, 185, 20, 0)
$input1 = GUICtrlCreateInput("", 10, 30, 185, 20)
GUICtrlSetData($idDate, $input1)
; to select a specific default format
Local $sStyle = "yyyy/MM/dd"
GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)
$button1 = GUICtrlCreateButton("OK", 10, 50, 185, 20)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            GUICtrlDelete($idDate)
            GUICtrlRead($input1)
            $idDate = GUICtrlCreateDate("", 10, 10, 185, 20, 0)
            GUICtrlSetData($idDate, $input1)
            $sStyle = "yyyy/MM/dd HH:mm:ss"
            GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)
            GUISetState()
    EndSwitch
WEnd

Can Somebody help me

Thankyou

 

Share this post


Link to post
Share on other sites



Something like this here?

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

GUICreate("My GUI get date", 200, 200, 800, 200)
Local $idDate = GUICtrlCreateDate("2014/04/25", 10, 10, 185, 20, 0)
$input1 = GUICtrlCreateInput("", 10, 30, 185, 20)
GUICtrlSetData($idDate, $input1)
; to select a specific default format
Local $sStyle = "yyyy/MM/dd"
GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)
$button1 = GUICtrlCreateButton("OK", 10, 50, 185, 20)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, "yyyy/MM/dd HH:mm:ss")
            GUICtrlSetData($idDate, GUICtrlRead($input1))
    EndSwitch
WEnd

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks,UES

In my example code before, the style for date are "yyyy/MM/dd"

but, in my complete code I use style format for my date are using "MM/dd/yyyy"

This the code using "MM/dd/yyyy" format

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

GUICreate("My GUI get date", 200, 200, 800, 200)
Local $idDate = GUICtrlCreateDate("04/25/2014", 10, 10, 185, 20, 0)
$input1 = GUICtrlCreateInput("", 10, 30, 185, 20)
GUICtrlSetData($idDate, $input1)
; to select a specific default format
Local $sStyle = "MM/dd/yyyy"
GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)
$button1 = GUICtrlCreateButton("OK", 10, 50, 185, 20)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, "MM/dd/yyyy HH:mm:ss")
            GUICtrlSetData($idDate, GUICtrlRead($input1))
    EndSwitch
WEnd

Cause the format are "MM/dd/yyyy" format, so I'll input to the $Input1 for example 12/10/2013, but nothing changes

If I entering 2013/12/10 to the $Input1, and it's work

 

The Question is, why there is different format between the Input Format and date set format?

Do we always must using "yyyy/MM/dd" format to makes change for GUICtrlCreateDate?

Thanks,

Hery

Edited by heryisme

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

It seems so that the format must be in format yyyy/MM/dd.

#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

GUICreate("My GUI get date", 200, 200, 800, 200)
Local $idDate = GUICtrlCreateDate("1953/04/25", 10, 10, 185, 20, 0)
$input1 = GUICtrlCreateInput("", 10, 30, 185, 20)
$button1 = GUICtrlCreateButton("OK", 10, 50, 185, 20)
GUISetState(@SW_SHOW)
; to select a specific default format
Local $sStyle = "MM/dd/yyyy"
GUICtrlSendMsg($idDate, $DTM_SETFORMATW, 0, $sStyle)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            GUICtrlSetData($idDate,StringRegExpReplace( GUICtrlRead($input1), "(\d+)\/(\d+)\/(\d+)", "$3/$1/$2"))
    EndSwitch
WEnd

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Ok, Seems need to add the explanation about the "yyyy/MM/dd" format to the help file for next version

cause I've try to googling about GUICtrlSet for Date before I ask to the forum, and there is no body talking bout formation of inputting the date or maybe I don't find it :)

Thanks for helping me UEZ

Regards,

Hery

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