Jump to content

GUICtrlCreateDate


Recommended Posts

Hi,

When I run the following date control example from the help file using AutoIt 3.2.3.14, the date does not display in the specified format. On my PC, it just shows "1953" in the date control.

#include <GUIConstants.au3>

GUICreate ( "My GUI get date", 200,200,800,200)
$date = GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )

; to select a specific default format
$DTM_SETFORMAT = 0x1005
$style = "yyyy/MM/dd HH:mm:s"
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

MsgBox(0,"Time", GUICtrlRead($date))

Does anyone else have the same problem?

Regards,

Jonny

Link to comment
Share on other sites

Works fine at my. I have Win 2000.

i542

Thanks for testing it.

I am still having the problem on both Windows 2000 and Windows XP. It happened when I moved from AutoIt 3.2.3.2 to 3.2.3.14. If I go back to 3.2.3.2, the problem goes away.

Regards,

Jonny

Link to comment
Share on other sites

The problem is with GUICtrlSendMsg. If I send the $DTM_SETFORMAT message using DllCall and the SendMessage API function, then it works.

Solution:

#include <GUIConstants.au3>

$form = GUICreate ( "My GUI get date", 200,200,800,200)
$date = GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )

; to select a specific default format
$DTM_SETFORMAT = 0x1005
$style = "yyyy/MM/dd HH:mm:s"
DllCall("user32.dll", _
        "int", "SendMessage", _
        "hwnd", ControlGetHandle($form, "", $date), _
        "int", $DTM_SETFORMAT, _
        "int", 0, _
        "str", $style)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Regards,

Jonny

Link to comment
Share on other sites

The problem is with GUICtrlSendMsg. If I send the $DTM_SETFORMAT message using DllCall and the SendMessage API function, then it works.

Solution:

#include <GUIConstants.au3>

$form = GUICreate ( "My GUI get date", 200,200,800,200)
$date = GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )

; to select a specific default format
$DTM_SETFORMAT = 0x1005
$style = "yyyy/MM/dd HH:mm:s"
DllCall("user32.dll", _
        "int", "SendMessage", _
        "hwnd", ControlGetHandle($form, "", $date), _
        "int", $DTM_SETFORMAT, _
        "int", 0, _
        "str", $style)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Regards,

Jonny

Yes, looks like a bug. Have you tried reporting it?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 2 weeks later...

As I wrote in the bug-forum.

Use the unicode function value then you will be happy:

#include <GUIConstants.au3>

GUICreate ( "My GUI get date", 200,200,800,200)
$date = GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )

; to select a specific default format
$DTM_SETFORMATW = 0x1032
$style = "yyyy/MM/dd HH:mm:s"
GuiCtrlSendMsg($date, $DTM_SETFORMATW, 0, $style)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

MsgBox(0,"Time", GUICtrlRead($date))

Maybe the most forgot that from beta version 3.2.3.3 on the default Autoit.exe is compiled in unicode...

Link to comment
Share on other sites

  • Administrators

This works fine on unicode and ansi versions.

#include <GUIConstants.au3>

If @UNICODE Then
 const $DTM_SETFORMAT = 0x1032
Else
 const $DTM_SETFORMAT = 0x1005
Endif

GUICreate ( "My GUI get date", 200,200,800,200)
$date = GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )

$style = "yyyy/MM/dd HH:mm:s"
GuiCtrlSendMsg($date, $DTM_SETFORMAT, 0, $style)

GuiSetState()
While GuiGetMsg() <> $GUI_EVENT_CLOSE
WEnd

MsgBox(0,"Time", GUICtrlRead($date))

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...