Code: Select all
MyGui := Gui()
MyGui.Add("DateTime", , "ShortDate")
MyGui.Add("DateTime").SetFormat("ShortDate")
MyGui.Show()
Code: Select all
MyGui := Gui()
MyGui.Add("DateTime", , "ShortDate")
MyGui.Add("DateTime").SetFormat("ShortDate")
MyGui.Show()
The last parameter is a format string, as described in the SetFormat method below.
The last parameter is a format string, as described in the SetFormat method below, except for ShortDate since it is the default and is indicated by leaving the option blank.
Code: Select all
#Requires AutoHotkey v2.0
#SingleInstance Force
DateFormats := ["ShortDate", "LongDate"]
ChosenFormat := 1
MyGui := Gui()
MyGui.Add("DateTime", "vMyDateTime", DateFormats[ChosenFormat])
MyGui.Add("Text", , "Choose Format: ")
For DateFormat in DateFormats
MyGui.Add("Button", "x+10 vFormat" A_Index, DateFormat).OnEvent("Click", ChangeFormat)
MyGui.Show()
ChangeFormat(GuiCtl, *) {
ChosenFormat := Number(SubStr(GuiCtl.Name, StrLen("Format")+1))
MyGui["MyDateTime"].SetFormat(DateFormats[ChosenFormat])
}
The code needed to handle it in SetFormat already exists. It is not prohibited in Add; it is simply not implemented.
DTS_SHORTDATEFORMAT shows the century only if the format selected in the system's regional settings includes the century, whereas DTS_SHORTDATECENTURYFORMAT always shows the century but otherwise matches the system setting.// DTS_SHORTDATECENTURYFORMAT is applied by default because it should make results more consistent
// across old and new systems. This is because new systems display a 4-digit year even without
// this style, but older ones might display a two digit year. This should make any system capable
// of displaying a 4-digit year display it in the locale's customary format. On systems that don't
// support DTS_SHORTDATECENTURYFORMAT, it should be ignored, resulting in DTS_SHORTDATEFORMAT taking
// effect automatically (untested).
Users browsing this forum: No registered users and 18 guests