DateTime control - LongDate with UpDown

Report problems with documented functionality
User avatar
Ragnar
Posts: 613
Joined: 30 Sep 2013, 15:25

DateTime control - LongDate with UpDown

24 Oct 2013, 13:46

Versions

OS: Windows 7 x64
AHK: affects all versions

Bug Description

For a DateTime control, if specify 1 in the options and LongDate in the last parameter, no UpDown appears. Neither in MSDN nor in the AHK documentation I've found something, why the styles cancel each other out.
Apparently there are problems with DTS_SHORTDATECENTURYFORMAT (0xC), which is enforced for this control. Instead, WinSpy++ displays DTS_LONGDATEFORMAT and 00000008 (?) as active styles (0x4 + 0x8 = 0xC). If this is not a bug, it should be mentioned in the documentation.

Steps to Reproduce

Code: Select all

; 0x1 = DTS_UPDOWN (1)

Gui, Add, DateTime, +0x1, LongDate
Gui, Show
Workaround

Code: Select all

; 0x1 = DTS_UPDOWN (1)
; 0x4 = DTS_LONGDATEFORMAT (LongDate)
; 0xC = DTS_SHORTDATECENTURYFORMAT (omitted)

Gui, Add, DateTime, -0xC +0x1 hwndDT
WinSet, Style, +0x4, ahk_id %DT%
Gui, Show
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: DateTime control - LongDate with UpDown

24 Oct 2013, 16:55

LongDate and DTS_UPDOWN are mutually exclusive by consequence of the fact that DTS_TIMEFORMAT = 8|1.
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: DateTime control - LongDate with UpDown

26 Oct 2013, 01:04

This is working for me:

Code: Select all

#NoEnv
Gui, Margin, 20, 20
Gui, Add, DateTime, -0x08 +0x05 ; DTS_LONGDATEFORMAT := 0x04
Gui, Show, , DateTime
Return
GuiClose:
ExitApp
Win 7 x64 - AHK U64

Edit:
The help file wrote:DateTime styles
  • default:
    DTS_SHORTDATECENTURYFORMAT and WS_TABSTOP (+/-Tabstop)
  • DTS_SHORTDATECENTURYFORMAT:
    Format option blank/omitted. Displays the date in short format with four-digit year. In some locales, it looks like 6/1/2005. If the system's version of Comctl32.dll is older than 5.8, this style is not supported and DTS_SHORTDATEFORMAT is automatically substituted.
So it behaves not as documented / is a bug.

Edit2:
Can't get DTS_SHORTDATECENTURYFORMAT using

Code: Select all

#NoEnv
Gui, Margin, 20, 20
Gui, Add, DateTime, 1 hwndHDT, LongDate
WinGet, Styles, Style, ahk_id %HDT%
Gui, Show, , DateTime
MsgBox, 0, Styles, %Styles%
Return
GuiClose:
ExitApp
but

Code: Select all

---------------------------
Styles
---------------------------
0x52010004
---------------------------
OK
---------------------------
The option 1 (or +0x01) is ignored, but shouldn't.
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: DateTime control - LongDate with UpDown

26 Oct 2013, 05:58

[OT]
Well, it's one of those ingenious Microsoft ideas. They simply defined DTS_TIMEFORMAT = 0x0009, but that's only 8/9 of the truth. Actually you can get the time format by setting styles to 0x0008:

Code: Select all

#NoEnv
Gui, Margin, 20, 20
Gui, Add, DateTime, -0x04 +0x08 hwndHDT
WinGet, Styles, Style, ahk_id %HDT%
Gui, Add, Text, xm wp, Styles: %Styles%
Gui, Show, , DateTime
Return
GuiClose:
ExitApp
but it's useless to show a calendar with the time format. So they combined 0x0008 and DTS_UPDOWN (0x0001) and called it DTS_TIMEFORMAT.
[/OT]
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: DateTime control - LongDate with UpDown

15 Jan 2014, 11:39

Still not fixed!

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 17 guests