Jump to content
Sign in to follow this  

Problem with GUICtrlCreateDate and GUICtrlSetData

Recommended Posts


hi!, First, I searched the forum but not found the solution to my problem. The problem is I can not change the day. This is a piece of my code.

$hdate = GUICtrlCreateDate("", 125, $iTop - 50, 150, -1, $DTS_SHORTDATEFORMAT)
$hWndDate = ControlGetHandle($hGui, "", $hdate)
_GUICtrlDTP_SetFormat($hWndDate, "dd/MM/yyyy - HH:mm:ss")
If ($sTipo == "Editar") Then
     GUICtrlSetState($hdate, 128)
     GUICtrlSetData($hdate, $aDatosParaModificar[5])
     GUICtrlSetData($hWndDate, $aDatosParaModificar[5])

$aDatosParaModificar[5] is a string with format "dd/MM/yyyy - HH:mm:ss" (Ej: 30/12/ 2000 - 22:10:35)

Edited by avechuche

Share this post

Link to post
Share on other sites


You will get better response to queries if you post runnable code.  

I wrapped your code to make it runnable and included comments where appropriate.

; *** Start added by AutoIt3Wrapper ***
#include <DateTimeConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
; *** End added by AutoIt3Wrapper ***
#include <GuiDateTimePicker.au3>


local $hGUI = guicreate('Date Control Format Test')

local $itop = 100, $sTipo = 'Editar', $aDatosParaModificar[6] = ['','','','','',"'My new date format = ' MM/dd/yyyy - HH:mm:ss"]

$hdate = GUICtrlCreateDate("", 125, $iTop - 50, 250, -1, $DTS_SHORTDATEFORMAT)
$hWndDate = ControlGetHandle($hGui, "", $hdate)
_GUICtrlDTP_SetFormat($hWndDate, "dd/MM/yyyy - HH:mm:ss")


If ($sTipo == "Editar") Then
     ;GUICtrlSetState($hdate, 128)                              don't disable the control
     _guictrldtp_setformat($hWndDate, $aDatosParaModificar[5])
     ;GUICtrlSetData($hWndDate, $aDatosParaModificar[5])        date formats cannot be changed with guictrlsetdata, only the date value

while 1
    switch guigetmsg()
        case $gui_event_close


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.